From 0e94355a85af2d648c3b769cd645836ce1bfa885 Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Wed, 13 Oct 2021 17:46:29 +0100 Subject: [PATCH] Some post-1.17 cleanup - Fix broken Javadoc references - Apply a couple of refactoring suggestions from IDEA --- gradle.properties | 2 +- .../java/dan200/computercraft/ComputerCraft.java | 6 ++---- .../dan200/computercraft/api/ComputerCraftAPI.java | 4 ++-- .../client/gui/NoTermComputerScreen.java | 4 ++-- .../client/gui/widgets/DynamicImageButton.java | 2 +- .../core/filesystem/ResourceMount.java | 2 +- .../core/lua/ResultInterpreterFunction.java | 2 +- .../computercraft/core/tracking/ComputerMBean.java | 10 +++++----- .../computercraft/data/BlockModelProvider.java | 5 ++--- .../computercraft/data/LootTableProvider.java | 2 +- .../java/dan200/computercraft/shared/Config.java | 6 ++---- .../shared/computer/blocks/ComputerProxy.java | 2 +- .../computer/recipe/ComputerUpgradeRecipe.java | 2 +- .../shared/peripheral/diskdrive/TileDiskDrive.java | 2 +- .../shared/peripheral/generic/data/ItemData.java | 2 +- .../generic/methods/InventoryMethods.java | 8 +++++--- .../shared/peripheral/modem/wired/BlockCable.java | 7 ++++--- .../modem/wireless/BlockWirelessModem.java | 7 ++++--- .../shared/peripheral/monitor/MonitorWatcher.java | 2 +- .../shared/turtle/blocks/BlockTurtle.java | 7 ++++--- .../shared/turtle/core/TurtlePlaceCommand.java | 7 ++++--- .../shared/turtle/recipes/TurtleRecipe.java | 2 +- .../shared/turtle/upgrades/TurtleSpeaker.java | 2 +- .../shared/util/BasicRecipeSerializer.java | 2 +- .../computercraft/shared/util/ColourUtils.java | 3 --- .../computercraft/shared/util/ImpostorRecipe.java | 3 ++- .../shared/util/ImpostorShapelessRecipe.java | 3 ++- .../shared/util/InventoryDelegate.java | 3 ++- .../shared/util/WaterloggableHelpers.java | 14 ++++++-------- src/main/resources/META-INF/mods.toml | 2 +- 30 files changed, 62 insertions(+), 63 deletions(-) diff --git a/gradle.properties b/gradle.properties index 50b4e80d8..de85ac7f5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,5 +6,5 @@ mod_version=1.98.2 # Minecraft properties (update mods.toml when changing) mc_version=1.17.1 mapping_version=2021.09.05 -forge_version=37.0.82 +forge_version=37.0.85 # NO SERIOUSLY, UPDATE mods.toml WHEN CHANGING diff --git a/src/main/java/dan200/computercraft/ComputerCraft.java b/src/main/java/dan200/computercraft/ComputerCraft.java index 8648d6ed2..d23013b91 100644 --- a/src/main/java/dan200/computercraft/ComputerCraft.java +++ b/src/main/java/dan200/computercraft/ComputerCraft.java @@ -19,8 +19,6 @@ import net.minecraftforge.fml.common.Mod; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.concurrent.TimeUnit; @@ -43,10 +41,10 @@ public final class ComputerCraft public static boolean httpEnabled = true; public static boolean httpWebsocketEnabled = true; - public static List httpRules = Collections.unmodifiableList( Arrays.asList( + public static List httpRules = List.of( AddressRule.parse( "$private", null, Action.DENY.toPartial() ), AddressRule.parse( "*", null, Action.ALLOW.toPartial() ) - ) ); + ); public static int httpMaxRequests = 16; public static int httpMaxWebsockets = 4; diff --git a/src/main/java/dan200/computercraft/api/ComputerCraftAPI.java b/src/main/java/dan200/computercraft/api/ComputerCraftAPI.java index 31debe64b..34f8b1f16 100644 --- a/src/main/java/dan200/computercraft/api/ComputerCraftAPI.java +++ b/src/main/java/dan200/computercraft/api/ComputerCraftAPI.java @@ -62,7 +62,7 @@ public final class ComputerCraftAPI * * eg: if createUniqueNumberedSaveDir( world, "computer/disk" ) was called returns 42, then "computer/disk/42" is now * available for writing. - * @see #createSaveDirMount(World, String, long) + * @see #createSaveDirMount(Level, String, long) */ public static int createUniqueNumberedSaveDir( @Nonnull Level world, @Nonnull String parentSubPath ) { @@ -81,7 +81,7 @@ public final class ComputerCraftAPI * @param capacity The amount of data that can be stored in the directory before it fills up, in bytes. * @return The mount, or null if it could be created for some reason. Use IComputerAccess.mount() or IComputerAccess.mountWritable() * to mount this on a Computers' file system. - * @see #createUniqueNumberedSaveDir(World, String) + * @see #createUniqueNumberedSaveDir(Level, String) * @see IComputerAccess#mount(String, IMount) * @see IComputerAccess#mountWritable(String, IWritableMount) * @see IMount diff --git a/src/main/java/dan200/computercraft/client/gui/NoTermComputerScreen.java b/src/main/java/dan200/computercraft/client/gui/NoTermComputerScreen.java index 452f67fdb..225a119a4 100644 --- a/src/main/java/dan200/computercraft/client/gui/NoTermComputerScreen.java +++ b/src/main/java/dan200/computercraft/client/gui/NoTermComputerScreen.java @@ -43,7 +43,7 @@ public class NoTermComputerScreen extends Scree @Override protected void init() { - this.passEvents = true; // to allow gui click events pass through mouseHelper protection (see MouseHelper.OnPres:105 code string) + passEvents = true; // Pass mouse vents through to the game's mouse handler. minecraft.mouseHandler.grabMouse(); minecraft.screen = this; @@ -103,7 +103,7 @@ public class NoTermComputerScreen extends Scree } @Override - public void render( PoseStack transform, int mouseX, int mouseY, float partialTicks ) + public void render( @Nonnull PoseStack transform, int mouseX, int mouseY, float partialTicks ) { super.render( transform, mouseX, mouseY, partialTicks ); diff --git a/src/main/java/dan200/computercraft/client/gui/widgets/DynamicImageButton.java b/src/main/java/dan200/computercraft/client/gui/widgets/DynamicImageButton.java index d059ef1bd..ce6046dfe 100644 --- a/src/main/java/dan200/computercraft/client/gui/widgets/DynamicImageButton.java +++ b/src/main/java/dan200/computercraft/client/gui/widgets/DynamicImageButton.java @@ -93,7 +93,7 @@ public class DynamicImageButton extends Button List tooltip = this.tooltip.get(); if( !tooltip.isEmpty() ) { - screen.renderComponentToolTip( stack, tooltip, mouseX, mouseY, screen.getMinecraft().font ); + screen.renderComponentTooltip( stack, tooltip, mouseX, mouseY ); } } } diff --git a/src/main/java/dan200/computercraft/core/filesystem/ResourceMount.java b/src/main/java/dan200/computercraft/core/filesystem/ResourceMount.java index efaa1f7b0..2e6283066 100644 --- a/src/main/java/dan200/computercraft/core/filesystem/ResourceMount.java +++ b/src/main/java/dan200/computercraft/core/filesystem/ResourceMount.java @@ -292,7 +292,7 @@ public final class ResourceMount implements IMount } /** - * A {@link ISelectiveResourceReloadListener} which reloads any associated mounts. + * A {@link ResourceManagerReloadListener} which reloads any associated mounts. * * While people should really be keeping a permanent reference to this, some people construct it every * method call, so let's make this as small as possible. diff --git a/src/main/java/dan200/computercraft/core/lua/ResultInterpreterFunction.java b/src/main/java/dan200/computercraft/core/lua/ResultInterpreterFunction.java index 495d1a2d1..b2cbb021c 100644 --- a/src/main/java/dan200/computercraft/core/lua/ResultInterpreterFunction.java +++ b/src/main/java/dan200/computercraft/core/lua/ResultInterpreterFunction.java @@ -24,7 +24,7 @@ class ResultInterpreterFunction extends ResumableVarArgFunction { - x.addProperty( "model", base.getLocation().toString() ); - } ) ) + .customLoader( BasicCustomLoader.makeFactory( new ResourceLocation( ComputerCraft.MOD_ID, "turtle" ), + x -> x.addProperty( "model", base.getLocation().toString() ) ) ) .end(); for( Direction facing : BlockTurtle.FACING.getPossibleValues() ) diff --git a/src/main/java/dan200/computercraft/data/LootTableProvider.java b/src/main/java/dan200/computercraft/data/LootTableProvider.java index ba501b36f..e77cef96e 100644 --- a/src/main/java/dan200/computercraft/data/LootTableProvider.java +++ b/src/main/java/dan200/computercraft/data/LootTableProvider.java @@ -26,7 +26,7 @@ import java.util.Map; import java.util.function.BiConsumer; /** - * An alternative to {@link net.minecraft.data.LootTableProvider}, with a more flexible interface. + * An alternative to {@link net.minecraft.data.loot.LootTableProvider}, with a more flexible interface. */ public abstract class LootTableProvider implements DataProvider { diff --git a/src/main/java/dan200/computercraft/shared/Config.java b/src/main/java/dan200/computercraft/shared/Config.java index 45af41efe..f0331f9f1 100644 --- a/src/main/java/dan200/computercraft/shared/Config.java +++ b/src/main/java/dan200/computercraft/shared/Config.java @@ -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(); diff --git a/src/main/java/dan200/computercraft/shared/computer/blocks/ComputerProxy.java b/src/main/java/dan200/computercraft/shared/computer/blocks/ComputerProxy.java index b877387db..1b95cd78d 100644 --- a/src/main/java/dan200/computercraft/shared/computer/blocks/ComputerProxy.java +++ b/src/main/java/dan200/computercraft/shared/computer/blocks/ComputerProxy.java @@ -22,7 +22,7 @@ public final class ComputerProxy this.get = get; } - protected TileComputerBase getTile() + TileComputerBase getTile() { return get.get(); } diff --git a/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerUpgradeRecipe.java b/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerUpgradeRecipe.java index 28b4d6e20..b0705effa 100644 --- a/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerUpgradeRecipe.java +++ b/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerUpgradeRecipe.java @@ -36,7 +36,7 @@ public class ComputerUpgradeRecipe extends ComputerFamilyRecipe return SERIALIZER; } - public static final RecipeSerializer SERIALIZER = new Serializer() + public static final RecipeSerializer SERIALIZER = new Serializer<>() { @Override protected ComputerUpgradeRecipe create( ResourceLocation identifier, String group, int width, int height, NonNullList ingredients, ItemStack result, ComputerFamily family ) diff --git a/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/TileDiskDrive.java b/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/TileDiskDrive.java index cb9e1b061..1edd21072 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/TileDiskDrive.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/TileDiskDrive.java @@ -152,7 +152,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory return super.save( nbt ); } - protected void serverTick() + void serverTick() { // Ejection if( ejectQueued ) diff --git a/src/main/java/dan200/computercraft/shared/peripheral/generic/data/ItemData.java b/src/main/java/dan200/computercraft/shared/peripheral/generic/data/ItemData.java index 36a4e9129..aa6759ffb 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/generic/data/ItemData.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/generic/data/ItemData.java @@ -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> enchants ) { diff --git a/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java b/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java index 84db4d9d7..362e22481 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java @@ -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`. diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/BlockCable.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/BlockCable.java index 537f382a6..d731e855a 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/BlockCable.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/BlockCable.java @@ -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 ) { diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/BlockWirelessModem.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/BlockWirelessModem.java index 1541ed412..efffefb8e 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/BlockWirelessModem.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/BlockWirelessModem.java @@ -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 ) ); } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorWatcher.java b/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorWatcher.java index 4e85952c2..d70862b44 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorWatcher.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorWatcher.java @@ -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; } diff --git a/src/main/java/dan200/computercraft/shared/turtle/blocks/BlockTurtle.java b/src/main/java/dan200/computercraft/shared/turtle/blocks/BlockTurtle.java index 8e618a7f7..a3b12f7ce 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/blocks/BlockTurtle.java +++ b/src/main/java/dan200/computercraft/shared/turtle/blocks/BlockTurtle.java @@ -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 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 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 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; } diff --git a/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java b/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java index 6c3c8b45c..8e8529c1d 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java +++ b/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java @@ -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 diff --git a/src/main/java/dan200/computercraft/shared/turtle/recipes/TurtleRecipe.java b/src/main/java/dan200/computercraft/shared/turtle/recipes/TurtleRecipe.java index 26c3624e8..7e6f8db1d 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/recipes/TurtleRecipe.java +++ b/src/main/java/dan200/computercraft/shared/turtle/recipes/TurtleRecipe.java @@ -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 SERIALIZER = new Serializer() + public static final RecipeSerializer SERIALIZER = new Serializer<>() { @Override protected TurtleRecipe create( ResourceLocation identifier, String group, int width, int height, NonNullList ingredients, ItemStack result, ComputerFamily family ) diff --git a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleSpeaker.java b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleSpeaker.java index 406e48c59..7f91cd197 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleSpeaker.java +++ b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleSpeaker.java @@ -30,7 +30,7 @@ public class TurtleSpeaker extends AbstractTurtleUpgrade private static class Peripheral extends UpgradeSpeakerPeripheral { - ITurtleAccess turtle; + final ITurtleAccess turtle; Peripheral( ITurtleAccess turtle ) { diff --git a/src/main/java/dan200/computercraft/shared/util/BasicRecipeSerializer.java b/src/main/java/dan200/computercraft/shared/util/BasicRecipeSerializer.java index 7535adaca..d955279d7 100644 --- a/src/main/java/dan200/computercraft/shared/util/BasicRecipeSerializer.java +++ b/src/main/java/dan200/computercraft/shared/util/BasicRecipeSerializer.java @@ -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 The reciep serializer */ diff --git a/src/main/java/dan200/computercraft/shared/util/ColourUtils.java b/src/main/java/dan200/computercraft/shared/util/ColourUtils.java index e1ed23b34..3eac338b6 100644 --- a/src/main/java/dan200/computercraft/shared/util/ColourUtils.java +++ b/src/main/java/dan200/computercraft/shared/util/ColourUtils.java @@ -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 ) diff --git a/src/main/java/dan200/computercraft/shared/util/ImpostorRecipe.java b/src/main/java/dan200/computercraft/shared/util/ImpostorRecipe.java index 9de877242..068e75208 100644 --- a/src/main/java/dan200/computercraft/shared/util/ImpostorRecipe.java +++ b/src/main/java/dan200/computercraft/shared/util/ImpostorRecipe.java @@ -57,8 +57,9 @@ public final class ImpostorRecipe extends ShapedRecipe return SERIALIZER; } - public static final RecipeSerializer SERIALIZER = new BasicRecipeSerializer() + public static final RecipeSerializer SERIALIZER = new BasicRecipeSerializer<>() { + @Nonnull @Override public ImpostorRecipe fromJson( @Nonnull ResourceLocation identifier, @Nonnull JsonObject json ) { diff --git a/src/main/java/dan200/computercraft/shared/util/ImpostorShapelessRecipe.java b/src/main/java/dan200/computercraft/shared/util/ImpostorShapelessRecipe.java index 211ebd71e..72b8b1021 100644 --- a/src/main/java/dan200/computercraft/shared/util/ImpostorShapelessRecipe.java +++ b/src/main/java/dan200/computercraft/shared/util/ImpostorShapelessRecipe.java @@ -59,8 +59,9 @@ public final class ImpostorShapelessRecipe extends ShapelessRecipe return SERIALIZER; } - public static final RecipeSerializer SERIALIZER = new BasicRecipeSerializer() + public static final RecipeSerializer SERIALIZER = new BasicRecipeSerializer<>() { + @Nonnull @Override public ImpostorShapelessRecipe fromJson( @Nonnull ResourceLocation id, @Nonnull JsonObject json ) { diff --git a/src/main/java/dan200/computercraft/shared/util/InventoryDelegate.java b/src/main/java/dan200/computercraft/shared/util/InventoryDelegate.java index c1bce8450..2f4aa9fd2 100644 --- a/src/main/java/dan200/computercraft/shared/util/InventoryDelegate.java +++ b/src/main/java/dan200/computercraft/shared/util/InventoryDelegate.java @@ -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 diff --git a/src/main/java/dan200/computercraft/shared/util/WaterloggableHelpers.java b/src/main/java/dan200/computercraft/shared/util/WaterloggableHelpers.java index a49f1335c..12f9a1ed1 100644 --- a/src/main/java/dan200/computercraft/shared/util/WaterloggableHelpers.java +++ b/src/main/java/dan200/computercraft/shared/util/WaterloggableHelpers.java @@ -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; } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 8d15381c8..582f8581b 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -20,6 +20,6 @@ CC: Tweaked is a fork of ComputerCraft, adding programmable computers, turtles a [[dependencies.computercraft]] modId="forge" mandatory=true - versionRange="[37.0.82,38)" + versionRange="[37.0.85,38)" ordering="NONE" side="BOTH"