1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-15 04:30:29 +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
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
30 changed files with 62 additions and 63 deletions

View File

@ -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

View File

@ -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<AddressRule> httpRules = Collections.unmodifiableList( Arrays.asList(
public static List<AddressRule> 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;

View File

@ -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

View File

@ -43,7 +43,7 @@ public class NoTermComputerScreen<T extends ContainerComputerBase> 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<T extends ContainerComputerBase> 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 );

View File

@ -93,7 +93,7 @@ public class DynamicImageButton extends Button
List<Component> tooltip = this.tooltip.get();
if( !tooltip.isEmpty() )
{
screen.renderComponentToolTip( stack, tooltip, mouseX, mouseY, screen.getMinecraft().font );
screen.renderComponentTooltip( stack, tooltip, mouseX, mouseY );
}
}
}

View File

@ -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.

View File

@ -24,7 +24,7 @@ class ResultInterpreterFunction extends ResumableVarArgFunction<ResultInterprete
static class Container
{
ILuaCallback callback;
int errorAdjust;
final int errorAdjust;
Container( ILuaCallback callback, int errorAdjust )
{

View File

@ -44,7 +44,7 @@ public final class ComputerMBean implements DynamicMBean, Tracker
add( "task", TrackingField.TOTAL_TIME, attributes, TrackingField.TASKS );
add( "serverTask", TrackingField.SERVER_TIME, attributes, TrackingField.SERVER_COUNT );
this.info = new MBeanInfo(
info = new MBeanInfo(
ComputerMBean.class.getSimpleName(),
"metrics about all computers on the server",
attributes.toArray( new MBeanAttributeInfo[0] ), null, null, null
@ -69,7 +69,7 @@ public final class ComputerMBean implements DynamicMBean, Tracker
}
@Override
public Object getAttribute( String attribute ) throws AttributeNotFoundException, MBeanException, ReflectionException
public Object getAttribute( String attribute ) throws AttributeNotFoundException
{
LongSupplier value = attributes.get( attribute );
if( value == null ) throw new AttributeNotFoundException();
@ -95,7 +95,7 @@ public final class ComputerMBean implements DynamicMBean, Tracker
}
@Override
public Object invoke( String actionName, Object[] params, String[] signature ) throws MBeanException, ReflectionException
public Object invoke( String actionName, Object[] params, String[] signature )
{
return null;
}
@ -149,7 +149,7 @@ public final class ComputerMBean implements DynamicMBean, Tracker
private static class Counter
{
AtomicLong value = new AtomicLong();
AtomicLong count = new AtomicLong();
final AtomicLong value = new AtomicLong();
final AtomicLong count = new AtomicLong();
}
}

View File

@ -110,9 +110,8 @@ public class BlockModelProvider extends BlockStateProvider
BlockModelBuilder model = models()
.getBuilder( name( block ) )
.customLoader( BasicCustomLoader.makeFactory( new ResourceLocation( ComputerCraft.MOD_ID, "turtle" ), x -> {
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() )

View File

@ -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
{

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;
}

View File

@ -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"