Skip to content

Commit

Permalink
Merge pull request #71 from German-Immersive-Railroading-Community/de…
Browse files Browse the repository at this point in the history
…pendabot/gradle/1.18-master/net.minecraftforge-forge-1.18.2-40.1.0

Bump forge from 1.18.2-40.0.46 to 1.18.2-40.1.0
  • Loading branch information
MrTroble authored Apr 19, 2022
2 parents 76686d7 + c7d0b2f commit 4faf20d
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 58 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ repositories {
}

dependencies {
minecraft 'net.minecraftforge:forge:1.18.2-40.0.46'
minecraft 'net.minecraftforge:forge:1.18.2-40.1.0'
}

jar {
Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [Internal]

* ref: Added final modifier
* deps: Updatet dependencies

## [Internal] 04.13.2022 - 1

* Internal forge update
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/eu/gir/gircredstone/block/BlockBasic.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
24 changes: 11 additions & 13 deletions src/main/java/eu/gir/gircredstone/block/BlockRedstoneAcceptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Block, BlockState> builder) {
builder.add(POWER);
}

@Override
protected void createBlockStateDefinition(Builder<Block, BlockState> builder) {
builder.add(POWER);
}


}
22 changes: 9 additions & 13 deletions src/main/java/eu/gir/gircredstone/block/BlockRedstoneEmitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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);
Expand All @@ -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);
}
}
10 changes: 5 additions & 5 deletions src/main/java/eu/gir/gircredstone/init/GIRCInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,24 @@ public class GIRCInit {
private static final List<Block> blocks = new ArrayList<>();

@SubscribeEvent
public static void registerBlock(RegistryEvent.Register<Block> event) {
IForgeRegistry<Block> registry = event.getRegistry();
public static void registerBlock(final RegistryEvent.Register<Block> event) {
final IForgeRegistry<Block> 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<Item> event) {
IForgeRegistry<Item> registry = event.getRegistry();
public static void registerItem(final RegistryEvent.Register<Item> event) {
final IForgeRegistry<Item> 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());
}

public static BlockEntityType<?> EMITER_TILE;

@SubscribeEvent
public static void registerTE(RegistryEvent.Register<BlockEntityType<?>> evt) {
public static void registerTE(final RegistryEvent.Register<BlockEntityType<?>> evt) {
EMITER_TILE = BlockEntityType.Builder.of(TileRedstoneEmitter::new, RS_EMITTER).build(null);
EMITER_TILE.setRegistryName(GIRCRedstoneMain.MODID, "emitter");
evt.getRegistry().register(EMITER_TILE);
Expand Down
25 changes: 12 additions & 13 deletions src/main/java/eu/gir/gircredstone/item/Linkingtool.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,34 @@
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());
compound.putInt(ID_Z, pos.getZ());
}
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();
Expand Down Expand Up @@ -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;
Expand All @@ -93,9 +92,9 @@ public InteractionResult onItemUseFirst(ItemStack stack, UseOnContext ctx) {
}
return InteractionResult.FAIL;
}

@Override
public void appendHoverText(ItemStack stack, @Nullable Level LevelIn, List<Component> tooltip, TooltipFlag flagIn) {
public void appendHoverText(final ItemStack stack, @Nullable final Level LevelIn, final List<Component> tooltip, final TooltipFlag flagIn) {
final CompoundTag nbt = stack.getTag();
if (nbt != null) {
final BlockPos pos = Linkingtool.readBlockPosFromNBT(nbt);
Expand All @@ -107,5 +106,5 @@ public void appendHoverText(ItemStack stack, @Nullable Level LevelIn, List<Compo
tooltip.add(new TranslatableComponent("lt.notlinked"));
tooltip.add(new TranslatableComponent("lt.notlinked.msg"));
}

}
22 changes: 11 additions & 11 deletions src/main/java/eu/gir/gircredstone/tile/TileRedstoneEmitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,43 @@
import net.minecraft.world.level.block.state.BlockState;

public class TileRedstoneEmitter extends BlockEntity {

public TileRedstoneEmitter(BlockPos pos, BlockState state) {
public TileRedstoneEmitter(final BlockPos pos, final BlockState state) {
super(GIRCInit.EMITER_TILE, pos, state);
}

private BlockPos linkedpos = null;

@Override
public void load(CompoundTag compound) {
public void load(final CompoundTag compound) {
super.load(compound);
this.linkedpos = Linkingtool.readBlockPosFromNBT(compound);
}

@Override
protected void saveAdditional(CompoundTag compound) {
protected void saveAdditional(final CompoundTag compound) {
super.saveAdditional(compound);
Linkingtool.writeBlockPosToNBT(linkedpos, compound);
}

public boolean link(final BlockPos pos) {
if (pos == null)
return false;
this.linkedpos = pos;
return true;
}

public boolean unlink() {
if (this.linkedpos == null)
return false;
this.linkedpos = null;
return true;
}

public BlockPos getLinkedPos() {
return this.linkedpos;
}

public void redstoneUpdate(final boolean enabled) {
if (linkedpos != null) {
final BlockState state = level.getBlockState(linkedpos);
Expand All @@ -54,5 +54,5 @@ public void redstoneUpdate(final boolean enabled) {
}
}
}

}

0 comments on commit 4faf20d

Please sign in to comment.