1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-11-18 14:15:12 +00:00

Some post-1.17 cleanup

- Fix broken Javadoc references
 - Apply a couple of refactoring suggestions from IDEA
This commit is contained in:
Jonathan Coates
2021-10-13 17:46:29 +01:00
parent 0d35331b82
commit 0e94355a85
30 changed files with 62 additions and 63 deletions

View File

@@ -25,11 +25,9 @@ import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.config.ModConfigEvent;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD )
public final class Config
@@ -337,8 +335,8 @@ public final class Config
// HTTP
ComputerCraft.httpEnabled = httpEnabled.get();
ComputerCraft.httpWebsocketEnabled = httpWebsocketEnabled.get();
ComputerCraft.httpRules = Collections.unmodifiableList( httpRules.get().stream()
.map( AddressRuleConfig::parseRule ).filter( Objects::nonNull ).collect( Collectors.toList() ) );
ComputerCraft.httpRules = httpRules.get().stream()
.map( AddressRuleConfig::parseRule ).filter( Objects::nonNull ).toList();
ComputerCraft.httpMaxRequests = httpMaxRequests.get();
ComputerCraft.httpMaxWebsockets = httpMaxWebsockets.get();

View File

@@ -22,7 +22,7 @@ public final class ComputerProxy
this.get = get;
}
protected TileComputerBase getTile()
TileComputerBase getTile()
{
return get.get();
}

View File

@@ -36,7 +36,7 @@ public class ComputerUpgradeRecipe extends ComputerFamilyRecipe
return SERIALIZER;
}
public static final RecipeSerializer<ComputerUpgradeRecipe> SERIALIZER = new Serializer<ComputerUpgradeRecipe>()
public static final RecipeSerializer<ComputerUpgradeRecipe> SERIALIZER = new Serializer<>()
{
@Override
protected ComputerUpgradeRecipe create( ResourceLocation identifier, String group, int width, int height, NonNullList<Ingredient> ingredients, ItemStack result, ComputerFamily family )

View File

@@ -152,7 +152,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
return super.save( nbt );
}
protected void serverTick()
void serverTick()
{
// Ejection
if( ejectQueued )

View File

@@ -148,7 +148,7 @@ public class ItemData
*
* @param rawEnchants The raw NBT list of enchantments
* @param enchants The enchantment map to add it to.
* @see net.minecraft.enchantment.EnchantmentHelper
* @see EnchantmentHelper
*/
private static void addEnchantments( @Nonnull ListTag rawEnchants, @Nonnull ArrayList<Map<String, Object>> enchants )
{

View File

@@ -7,6 +7,7 @@ package dan200.computercraft.shared.peripheral.generic.methods;
import dan200.computercraft.ComputerCraft;
import dan200.computercraft.api.lua.GenericSource;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.lua.LuaFunction;
import dan200.computercraft.api.peripheral.IComputerAccess;
@@ -60,9 +61,10 @@ public class InventoryMethods implements GenericSource
* List all items in this inventory. This returns a table, with an entry for each slot.
*
* Each item in the inventory is represented by a table containing some basic information, much like
* {@link dan200.computercraft.shared.turtle.apis.TurtleAPI#getItemDetail} includes. More information can be fetched
* with {@link #getItemDetail}. The table contains the item `name`, the `count` and an a (potentially nil) hash of
* the item's `nbt.` This NBT data doesn't contain anything useful, but allows you to distinguish identical items.
* {@link dan200.computercraft.shared.turtle.apis.TurtleAPI#getItemDetail(ILuaContext, Optional, Optional)}
* includes. More information can be fetched with {@link #getItemDetail}. The table contains the item `name`, the
* `count` and an a (potentially nil) hash of the item's `nbt.` This NBT data doesn't contain anything useful, but
* allows you to distinguish identical items.
*
* The returned table is sparse, and so empty slots will be `nil` - it is recommended to loop over using `pairs`
* rather than `ipairs`.

View File

@@ -9,6 +9,7 @@ import com.google.common.collect.ImmutableMap;
import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.shared.Registry;
import dan200.computercraft.shared.common.BlockGeneric;
import dan200.computercraft.shared.util.WaterloggableHelpers;
import dan200.computercraft.shared.util.WorldUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@@ -176,7 +177,7 @@ public class BlockCable extends BlockGeneric implements SimpleWaterloggedBlock
@Deprecated
public FluidState getFluidState( @Nonnull BlockState state )
{
return getWaterloggedFluidState( state );
return WaterloggableHelpers.getFluidState( state );
}
@Nonnull
@@ -184,7 +185,7 @@ public class BlockCable extends BlockGeneric implements SimpleWaterloggedBlock
@Deprecated
public BlockState updateShape( @Nonnull BlockState state, @Nonnull Direction side, @Nonnull BlockState otherState, @Nonnull LevelAccessor world, @Nonnull BlockPos pos, @Nonnull BlockPos otherPos )
{
updateWaterloggedPostPlacement( state, world, pos );
WaterloggableHelpers.updateShape( state, world, pos );
// Should never happen, but handle the case where we've no modem or cable.
if( !state.getValue( CABLE ) && state.getValue( MODEM ) == CableModemVariant.None )
{
@@ -209,7 +210,7 @@ public class BlockCable extends BlockGeneric implements SimpleWaterloggedBlock
public BlockState getStateForPlacement( @Nonnull BlockPlaceContext context )
{
BlockState state = defaultBlockState()
.setValue( WATERLOGGED, getWaterloggedStateForPlacement( context ) );
.setValue( WATERLOGGED, getFluidStateForPlacement( context ) );
if( context.getItemInHand().getItem() instanceof ItemBlockCable.Cable )
{

View File

@@ -7,6 +7,7 @@ package dan200.computercraft.shared.peripheral.modem.wireless;
import dan200.computercraft.shared.common.BlockGeneric;
import dan200.computercraft.shared.peripheral.modem.ModemShapes;
import dan200.computercraft.shared.util.WaterloggableHelpers;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.item.context.BlockPlaceContext;
@@ -64,7 +65,7 @@ public class BlockWirelessModem extends BlockGeneric implements SimpleWaterlogge
@Deprecated
public FluidState getFluidState( @Nonnull BlockState state )
{
return getWaterloggedFluidState( state );
return WaterloggableHelpers.getFluidState( state );
}
@Nonnull
@@ -72,7 +73,7 @@ public class BlockWirelessModem extends BlockGeneric implements SimpleWaterlogge
@Deprecated
public BlockState updateShape( @Nonnull BlockState state, @Nonnull Direction side, @Nonnull BlockState otherState, @Nonnull LevelAccessor world, @Nonnull BlockPos pos, @Nonnull BlockPos otherPos )
{
updateWaterloggedPostPlacement( state, world, pos );
WaterloggableHelpers.updateShape( state, world, pos );
return side == state.getValue( FACING ) && !state.canSurvive( world, pos )
? state.getFluidState().createLegacyBlock()
: state;
@@ -92,6 +93,6 @@ public class BlockWirelessModem extends BlockGeneric implements SimpleWaterlogge
{
return defaultBlockState()
.setValue( FACING, placement.getClickedFace().getOpposite() )
.setValue( WATERLOGGED, getWaterloggedStateForPlacement( placement ) );
.setValue( WATERLOGGED, getFluidStateForPlacement( placement ) );
}
}

View File

@@ -101,7 +101,7 @@ public final class MonitorWatcher
if( !(world instanceof ServerLevel) ) continue;
LevelChunk chunk = world.getChunkAt( pos );
if( !((ServerLevel) world).getChunkSource().chunkMap.getPlayers( chunk.getPos(), false ).findAny().isPresent() )
if( ((ServerLevel) world).getChunkSource().chunkMap.getPlayers( chunk.getPos(), false ).findAny().isEmpty() )
{
continue;
}

View File

@@ -12,6 +12,7 @@ import dan200.computercraft.shared.computer.core.ComputerFamily;
import dan200.computercraft.shared.turtle.core.TurtleBrain;
import dan200.computercraft.shared.turtle.items.ITurtleItem;
import dan200.computercraft.shared.turtle.items.TurtleItemFactory;
import dan200.computercraft.shared.util.WaterloggableHelpers;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
@@ -98,7 +99,7 @@ public class BlockTurtle extends BlockComputerBase<TileTurtle> implements Simple
{
return defaultBlockState()
.setValue( FACING, placement.getHorizontalDirection() )
.setValue( WATERLOGGED, getWaterloggedStateForPlacement( placement ) );
.setValue( WATERLOGGED, getFluidStateForPlacement( placement ) );
}
@Nonnull
@@ -106,7 +107,7 @@ public class BlockTurtle extends BlockComputerBase<TileTurtle> implements Simple
@Deprecated
public FluidState getFluidState( @Nonnull BlockState state )
{
return getWaterloggedFluidState( state );
return WaterloggableHelpers.getFluidState( state );
}
@Nonnull
@@ -114,7 +115,7 @@ public class BlockTurtle extends BlockComputerBase<TileTurtle> implements Simple
@Deprecated
public BlockState updateShape( @Nonnull BlockState state, @Nonnull Direction side, @Nonnull BlockState otherState, @Nonnull LevelAccessor world, @Nonnull BlockPos pos, @Nonnull BlockPos otherPos )
{
updateWaterloggedPostPlacement( state, world, pos );
WaterloggableHelpers.updateShape( state, world, pos );
return state;
}

View File

@@ -17,6 +17,7 @@ import dan200.computercraft.shared.util.WorldUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.protocol.game.ServerboundInteractPacket;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.InteractionResultHolder;
@@ -149,8 +150,8 @@ public class TurtlePlaceCommand implements ITurtleCommand
* @param hitEntity The entity we're interacting with.
* @param hitPos The position our ray trace hit the entity.
* @return If this item was deployed.
* @see net.minecraft.network.play.ServerPlayNetHandler#handleInteract(CUseEntityPacket)
* @see net.minecraft.entity.player.PlayerEntity#interactOn(Entity, Hand)
* @see net.minecraft.server.network.ServerGamePacketListenerImpl#handleInteract(ServerboundInteractPacket)
* @see net.minecraft.world.entity.player.Player#interactOn(Entity, InteractionHand)
*/
private static boolean doDeployOnEntity( @Nonnull ItemStack stack, TurtlePlayer turtlePlayer, @Nonnull Entity hitEntity, @Nonnull Vec3 hitPos )
{
@@ -260,7 +261,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
* @param context The context of this place action.
* @param hit Where the block we're placing against was clicked.
* @return If this item was deployed.
* @see net.minecraft.server.management.PlayerInteractionManager#useItemOn For the original implementation.
* @see net.minecraft.server.level.ServerPlayerGameMode#useItemOn For the original implementation.
*/
private static InteractionResult doDeployOnBlock(
@Nonnull ItemStack stack, TurtlePlayer turtlePlayer, BlockPos position, UseOnContext context, BlockHitResult hit

View File

@@ -41,7 +41,7 @@ public final class TurtleRecipe extends ComputerFamilyRecipe
return TurtleItemFactory.create( computerID, label, -1, getFamily(), null, null, 0, null );
}
public static final RecipeSerializer<TurtleRecipe> SERIALIZER = new Serializer<TurtleRecipe>()
public static final RecipeSerializer<TurtleRecipe> SERIALIZER = new Serializer<>()
{
@Override
protected TurtleRecipe create( ResourceLocation identifier, String group, int width, int height, NonNullList<Ingredient> ingredients, ItemStack result, ComputerFamily family )

View File

@@ -30,7 +30,7 @@ public class TurtleSpeaker extends AbstractTurtleUpgrade
private static class Peripheral extends UpgradeSpeakerPeripheral
{
ITurtleAccess turtle;
final ITurtleAccess turtle;
Peripheral( ITurtleAccess turtle )
{

View File

@@ -10,7 +10,7 @@ import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraftforge.registries.ForgeRegistryEntry;
/**
* A {@link IRecipeSerializer} which implements all the Forge registry entries.
* A {@link RecipeSerializer} which implements all the Forge registry entries.
*
* @param <T> The reciep serializer
*/

View File

@@ -11,8 +11,6 @@ import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.Tags;
import javax.annotation.Nullable;
public final class ColourUtils
{
@SuppressWarnings( { "unchecked", "rawtypes" } )
@@ -35,7 +33,6 @@ public final class ColourUtils
Tags.Items.DYES_BLACK,
};
@Nullable
private ColourUtils() {}
public static DyeColor getStackColour( ItemStack stack )

View File

@@ -57,8 +57,9 @@ public final class ImpostorRecipe extends ShapedRecipe
return SERIALIZER;
}
public static final RecipeSerializer<ImpostorRecipe> SERIALIZER = new BasicRecipeSerializer<ImpostorRecipe>()
public static final RecipeSerializer<ImpostorRecipe> SERIALIZER = new BasicRecipeSerializer<>()
{
@Nonnull
@Override
public ImpostorRecipe fromJson( @Nonnull ResourceLocation identifier, @Nonnull JsonObject json )
{

View File

@@ -59,8 +59,9 @@ public final class ImpostorShapelessRecipe extends ShapelessRecipe
return SERIALIZER;
}
public static final RecipeSerializer<ImpostorShapelessRecipe> SERIALIZER = new BasicRecipeSerializer<ImpostorShapelessRecipe>()
public static final RecipeSerializer<ImpostorShapelessRecipe> SERIALIZER = new BasicRecipeSerializer<>()
{
@Nonnull
@Override
public ImpostorShapelessRecipe fromJson( @Nonnull ResourceLocation id, @Nonnull JsonObject json )
{

View File

@@ -9,6 +9,7 @@ import net.minecraft.world.Container;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
import javax.annotation.Nonnull;
import java.util.Set;
@@ -16,7 +17,7 @@ import java.util.Set;
/**
* Provides a delegate over inventories.
*
* This may be used both on {@link net.minecraft.tileentity.TileEntity}s to redirect the inventory to another tile,
* This may be used both on {@link BlockEntity}s to redirect the inventory to another tile,
* and by other interfaces to have inventories which change their backing store.
*/
@FunctionalInterface

View File

@@ -16,9 +16,7 @@ import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
/**
* Represents a block which can be filled with water
*
* I'm fairly sure this exists on 1.14, but it's a useful convenience wrapper to have on 1.13.
* Helpers for working with waterlogged blocks.
*/
public final class WaterloggableHelpers
{
@@ -29,24 +27,24 @@ public final class WaterloggableHelpers
}
/**
* Call from {@link net.minecraft.block.Block#getFluidState(BlockState)}.
* Call from {@link net.minecraft.world.level.block.Block#getFluidState(BlockState)}.
*
* @param state The current state
* @return This waterlogged block's current fluid
*/
public static FluidState getWaterloggedFluidState( BlockState state )
public static FluidState getFluidState( BlockState state )
{
return state.getValue( WATERLOGGED ) ? Fluids.WATER.getSource( false ) : Fluids.EMPTY.defaultFluidState();
}
/**
* Call from {@link net.minecraft.block.Block#updatePostPlacement(BlockState, Direction, BlockState, IWorld, BlockPos, BlockPos)}.
* Call from {@link net.minecraft.world.level.block.Block#updateShape(BlockState, Direction, BlockState, LevelAccessor, BlockPos, BlockPos)}.
*
* @param state The current state
* @param world The position of this block
* @param pos The world this block exists in
*/
public static void updateWaterloggedPostPlacement( BlockState state, LevelAccessor world, BlockPos pos )
public static void updateShape( BlockState state, LevelAccessor world, BlockPos pos )
{
if( state.getValue( WATERLOGGED ) )
{
@@ -54,7 +52,7 @@ public final class WaterloggableHelpers
}
}
public static boolean getWaterloggedStateForPlacement( BlockPlaceContext context )
public static boolean getFluidStateForPlacement( BlockPlaceContext context )
{
return context.getLevel().getFluidState( context.getClickedPos() ).getType() == Fluids.WATER;
}