From c7d0b2f68f06c0a14ec8329e738aa27bab2dcb66 Mon Sep 17 00:00:00 2001 From: Nico Froehlich Date: Tue, 19 Apr 2022 20:09:10 +0200 Subject: [PATCH] ref: Added final modifiers --- changelog.md | 5 ++++ .../eu/gir/gircredstone/block/BlockBasic.java | 4 +-- .../block/BlockRedstoneAcceptor.java | 24 ++++++++---------- .../block/BlockRedstoneEmitter.java | 22 +++++++--------- .../eu/gir/gircredstone/init/GIRCInit.java | 10 ++++---- .../eu/gir/gircredstone/item/Linkingtool.java | 25 +++++++++---------- .../tile/TileRedstoneEmitter.java | 22 ++++++++-------- 7 files changed, 55 insertions(+), 57 deletions(-) diff --git a/changelog.md b/changelog.md index 8169de6..b76a567 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,10 @@ # Changelog +## [Internal] + +* ref: Added final modifier +* deps: Updatet dependencies + ## [Internal] 04.13.2022 - 1 * Internal forge update diff --git a/src/main/java/eu/gir/gircredstone/block/BlockBasic.java b/src/main/java/eu/gir/gircredstone/block/BlockBasic.java index 499cfe9..4b54e69 100644 --- a/src/main/java/eu/gir/gircredstone/block/BlockBasic.java +++ b/src/main/java/eu/gir/gircredstone/block/BlockBasic.java @@ -5,10 +5,10 @@ import net.minecraft.world.level.material.Material; public class BlockBasic extends Block { - + public BlockBasic(final String name) { super(Properties.of(Material.METAL)); this.setRegistryName(GIRCRedstoneMain.MODID, name); } - + } diff --git a/src/main/java/eu/gir/gircredstone/block/BlockRedstoneAcceptor.java b/src/main/java/eu/gir/gircredstone/block/BlockRedstoneAcceptor.java index 5adc53e..ae445ec 100644 --- a/src/main/java/eu/gir/gircredstone/block/BlockRedstoneAcceptor.java +++ b/src/main/java/eu/gir/gircredstone/block/BlockRedstoneAcceptor.java @@ -11,32 +11,30 @@ public class BlockRedstoneAcceptor extends BlockBasic { public static final BooleanProperty POWER = BooleanProperty.create("power"); - + public BlockRedstoneAcceptor() { super("acceptor"); this.registerDefaultState(this.defaultBlockState().setValue(POWER, false)); } @Override - public boolean isSignalSource(BlockState p_149744_1_) { + public boolean isSignalSource(final BlockState p_149744_1_) { return true; } @Override - public int getSignal(BlockState p_180656_1_, BlockGetter p_180656_2_, BlockPos p_180656_3_, - Direction p_180656_4_) { + public int getSignal(final BlockState p_180656_1_, final BlockGetter p_180656_2_, final BlockPos p_180656_3_, final Direction p_180656_4_) { return this.getDirectSignal(p_180656_1_, p_180656_2_, p_180656_3_, p_180656_4_); } @Override - public int getDirectSignal(BlockState blockState, BlockGetter p_176211_2_, BlockPos p_176211_3_, - Direction p_176211_4_) { - return blockState.getValue(POWER) ? 15:0; + public int getDirectSignal(final BlockState blockState, final BlockGetter p_176211_2_, final BlockPos p_176211_3_, final Direction p_176211_4_) { + return blockState.getValue(POWER) ? 15 : 0; + } + + @Override + protected void createBlockStateDefinition(final Builder builder) { + builder.add(POWER); } - - @Override - protected void createBlockStateDefinition(Builder builder) { - builder.add(POWER); - } - + } diff --git a/src/main/java/eu/gir/gircredstone/block/BlockRedstoneEmitter.java b/src/main/java/eu/gir/gircredstone/block/BlockRedstoneEmitter.java index 332e301..cd25a88 100644 --- a/src/main/java/eu/gir/gircredstone/block/BlockRedstoneEmitter.java +++ b/src/main/java/eu/gir/gircredstone/block/BlockRedstoneEmitter.java @@ -17,14 +17,13 @@ import net.minecraft.world.phys.BlockHitResult; public class BlockRedstoneEmitter extends BlockBasic implements EntityBlock { - + public BlockRedstoneEmitter() { super("emitter"); } - + @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, - BlockHitResult hit) { + public InteractionResult use(final BlockState state, final Level world, final BlockPos pos, final Player player, final InteractionHand hand, final BlockHitResult hit) { if (world.isClientSide) return InteractionResult.PASS; if (player.getItemInHand(hand).getItem().equals(GIRCInit.RS_LINKER)) @@ -39,21 +38,18 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player } else { if (player.isCrouching()) { emitter.unlink(); - player.sendMessage(new TranslatableComponent("em.unlink", linkedpos.getX(), linkedpos.getY(), - linkedpos.getZ()), uuid); + player.sendMessage(new TranslatableComponent("em.unlink", linkedpos.getX(), linkedpos.getY(), linkedpos.getZ()), uuid); } else { - player.sendMessage(new TranslatableComponent("lt.linkedpos", linkedpos.getX(), linkedpos.getY(), - linkedpos.getZ()), uuid); + player.sendMessage(new TranslatableComponent("lt.linkedpos", linkedpos.getX(), linkedpos.getY(), linkedpos.getZ()), uuid); } } return InteractionResult.SUCCESS; } return InteractionResult.FAIL; } - + @Override - public void neighborChanged(BlockState state, Level world, BlockPos pos, Block blockIn, BlockPos fromPos, - boolean isMoving) { + public void neighborChanged(final BlockState state, final Level world, final BlockPos pos, final Block blockIn, final BlockPos fromPos, final boolean isMoving) { if (world.isClientSide) return; final BlockEntity entity = world.getBlockEntity(pos); @@ -62,9 +58,9 @@ public void neighborChanged(BlockState state, Level world, BlockPos pos, Block b emitter.redstoneUpdate(world.hasNeighborSignal(pos)); } } - + @Override - public BlockEntity newBlockEntity(BlockPos arg0, BlockState arg1) { + public BlockEntity newBlockEntity(final BlockPos arg0, final BlockState arg1) { return new TileRedstoneEmitter(arg0, arg1); } } diff --git a/src/main/java/eu/gir/gircredstone/init/GIRCInit.java b/src/main/java/eu/gir/gircredstone/init/GIRCInit.java index 1921c21..e0596c4 100644 --- a/src/main/java/eu/gir/gircredstone/init/GIRCInit.java +++ b/src/main/java/eu/gir/gircredstone/init/GIRCInit.java @@ -31,16 +31,16 @@ public class GIRCInit { private static final List blocks = new ArrayList<>(); @SubscribeEvent - public static void registerBlock(RegistryEvent.Register event) { - IForgeRegistry registry = event.getRegistry(); + public static void registerBlock(final RegistryEvent.Register event) { + final IForgeRegistry registry = event.getRegistry(); blocks.add(RS_ACCEPTOR = new BlockRedstoneAcceptor()); blocks.add(RS_EMITTER = new BlockRedstoneEmitter()); blocks.forEach(registry::register); } @SubscribeEvent - public static void registerItem(RegistryEvent.Register event) { - IForgeRegistry registry = event.getRegistry(); + public static void registerItem(final RegistryEvent.Register event) { + final IForgeRegistry registry = event.getRegistry(); blocks.forEach(block -> registry.register(new BlockItem(block, new Properties().tab(CreativeModeTab.TAB_REDSTONE)).setRegistryName(block.getRegistryName()))); registry.register(RS_LINKER = new Linkingtool()); } @@ -48,7 +48,7 @@ public static void registerItem(RegistryEvent.Register event) { public static BlockEntityType EMITER_TILE; @SubscribeEvent - public static void registerTE(RegistryEvent.Register> evt) { + public static void registerTE(final RegistryEvent.Register> evt) { EMITER_TILE = BlockEntityType.Builder.of(TileRedstoneEmitter::new, RS_EMITTER).build(null); EMITER_TILE.setRegistryName(GIRCRedstoneMain.MODID, "emitter"); evt.getRegistry().register(EMITER_TILE); diff --git a/src/main/java/eu/gir/gircredstone/item/Linkingtool.java b/src/main/java/eu/gir/gircredstone/item/Linkingtool.java index ace690c..bfe118a 100644 --- a/src/main/java/eu/gir/gircredstone/item/Linkingtool.java +++ b/src/main/java/eu/gir/gircredstone/item/Linkingtool.java @@ -24,17 +24,17 @@ import net.minecraft.world.level.block.Block; public class Linkingtool extends Item { - + public Linkingtool() { super(new Properties().tab(CreativeModeTab.TAB_REDSTONE)); this.setRegistryName(GIRCRedstoneMain.MODID, "linker"); } - + private static final String ID_X = "xLinkedPos"; private static final String ID_Y = "yLinkedPos"; private static final String ID_Z = "zLinkedPos"; - - public static CompoundTag writeBlockPosToNBT(BlockPos pos, CompoundTag compound) { + + public static CompoundTag writeBlockPosToNBT(final BlockPos pos, final CompoundTag compound) { if (pos != null && compound != null) { compound.putInt(ID_X, pos.getX()); compound.putInt(ID_Y, pos.getY()); @@ -42,16 +42,16 @@ public static CompoundTag writeBlockPosToNBT(BlockPos pos, CompoundTag compound) } return compound; } - - public static BlockPos readBlockPosFromNBT(CompoundTag compound) { + + public static BlockPos readBlockPosFromNBT(final CompoundTag compound) { if (compound != null && compound.contains(ID_X) && compound.contains(ID_Y) && compound.contains(ID_Z)) { return new BlockPos(compound.getInt(ID_X), compound.getInt(ID_Y), compound.getInt(ID_Z)); } return null; - } + } @Override - public InteractionResult onItemUseFirst(ItemStack stack, UseOnContext ctx) { + public InteractionResult onItemUseFirst(final ItemStack stack, final UseOnContext ctx) { final Level LevelIn = ctx.getLevel(); final Player player = ctx.getPlayer(); final BlockPos pos = ctx.getClickedPos(); @@ -81,8 +81,7 @@ public InteractionResult onItemUseFirst(ItemStack stack, UseOnContext ctx) { final CompoundTag comp = stack.getTag(); final BlockPos linkpos = Linkingtool.readBlockPosFromNBT(comp); if (emitter.link(linkpos)) { - player.sendMessage( - new TranslatableComponent("lt.linkedpos", linkpos.getX(), linkpos.getY(), linkpos.getZ()), uuid); + player.sendMessage(new TranslatableComponent("lt.linkedpos", linkpos.getX(), linkpos.getY(), linkpos.getZ()), uuid); stack.setTag(null); player.sendMessage(new TranslatableComponent("lt.reset"), uuid); return InteractionResult.SUCCESS; @@ -93,9 +92,9 @@ public InteractionResult onItemUseFirst(ItemStack stack, UseOnContext ctx) { } return InteractionResult.FAIL; } - + @Override - public void appendHoverText(ItemStack stack, @Nullable Level LevelIn, List tooltip, TooltipFlag flagIn) { + public void appendHoverText(final ItemStack stack, @Nullable final Level LevelIn, final List tooltip, final TooltipFlag flagIn) { final CompoundTag nbt = stack.getTag(); if (nbt != null) { final BlockPos pos = Linkingtool.readBlockPosFromNBT(nbt); @@ -107,5 +106,5 @@ public void appendHoverText(ItemStack stack, @Nullable Level LevelIn, List