From f817071dfde99baf8e15524688d212f639c54758 Mon Sep 17 00:00:00 2001 From: MrTroble Date: Fri, 6 Aug 2021 00:29:31 +0200 Subject: [PATCH] Inital 1.14 release --- build.gradle | 4 +- .../eu/gir/gircredstone/block/BlockBasic.java | 2 +- .../block/BlockRedstoneAcceptor.java | 12 ++-- .../block/BlockRedstoneEmitter.java | 27 ++++---- .../eu/gir/gircredstone/init/GIRCInit.java | 7 +- .../eu/gir/gircredstone/item/Linkingtool.java | 67 +++++++++---------- .../tile/TileRedstoneEmitter.java | 37 ++++++---- src/main/resources/META-INF/mods.toml | 2 +- 8 files changed, 84 insertions(+), 74 deletions(-) diff --git a/build.gradle b/build.gradle index 512bff5..9e0742b 100644 --- a/build.gradle +++ b/build.gradle @@ -39,7 +39,7 @@ archivesBaseName = 'GIRC-Redstone' sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' minecraft { - mappings channel: 'snapshot', version: '20180921-1.13' + mappings channel: 'snapshot', version: '20190719-1.14.3' runs { client { @@ -56,7 +56,7 @@ minecraft { } dependencies { - minecraft 'net.minecraftforge:forge:1.13.2-25.0.219' + minecraft 'net.minecraftforge:forge:1.14.4-28.2.0' } jar { diff --git a/src/main/java/eu/gir/gircredstone/block/BlockBasic.java b/src/main/java/eu/gir/gircredstone/block/BlockBasic.java index a07ec29..f5ea036 100644 --- a/src/main/java/eu/gir/gircredstone/block/BlockBasic.java +++ b/src/main/java/eu/gir/gircredstone/block/BlockBasic.java @@ -7,7 +7,7 @@ public class BlockBasic extends Block { public BlockBasic(final String name) { - super(Properties.create(Material.CIRCUITS)); + super(Properties.create(Material.MISCELLANEOUS)); 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 43ae703..e631da6 100644 --- a/src/main/java/eu/gir/gircredstone/block/BlockRedstoneAcceptor.java +++ b/src/main/java/eu/gir/gircredstone/block/BlockRedstoneAcceptor.java @@ -1,10 +1,10 @@ package eu.gir.gircredstone.block; import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; import net.minecraft.state.BooleanProperty; import net.minecraft.state.StateContainer.Builder; -import net.minecraft.util.EnumFacing; +import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; @@ -18,22 +18,22 @@ public BlockRedstoneAcceptor() { } @Override - public boolean canProvidePower(IBlockState state) { + public boolean canProvidePower(BlockState state) { return true; } @Override - public int getWeakPower(IBlockState blockState, IBlockReader blockAccess, BlockPos pos, EnumFacing side) { + public int getWeakPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) { return this.getStrongPower(blockState, blockAccess, pos, side); } @Override - public int getStrongPower(IBlockState blockState, IBlockReader blockAccess, BlockPos pos, EnumFacing side) { + public int getStrongPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) { return blockState.get(POWER) ? 15:0; } @Override - protected void fillStateContainer(Builder builder) { + protected void fillStateContainer(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 f6c312b..c1ee187 100644 --- a/src/main/java/eu/gir/gircredstone/block/BlockRedstoneEmitter.java +++ b/src/main/java/eu/gir/gircredstone/block/BlockRedstoneEmitter.java @@ -3,14 +3,14 @@ import eu.gir.gircredstone.init.GIRCInit; import eu.gir.gircredstone.tile.TileRedstoneEmitter; import net.minecraft.block.Block; +import net.minecraft.block.BlockState; import net.minecraft.block.ITileEntityProvider; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; +import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.TextComponentTranslation; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; @@ -22,13 +22,13 @@ public BlockRedstoneEmitter() { } @Override - public TileEntity createTileEntity(IBlockState state, IBlockReader world) { + public TileEntity createTileEntity(BlockState state, IBlockReader world) { return createNewTileEntity(world); } - + @Override - public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, EntityPlayer player, EnumHand hand, - EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, + BlockRayTraceResult hit) { if (world.isRemote) return true; if (player.getHeldItem(hand).getItem().equals(GIRCInit.RS_LINKER)) @@ -38,14 +38,14 @@ public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, En final TileRedstoneEmitter emitter = (TileRedstoneEmitter) entity; final BlockPos linkedpos = emitter.getLinkedPos(); if (linkedpos == null) { - player.sendMessage(new TextComponentTranslation("em.notlinked")); + player.sendMessage(new TranslationTextComponent("em.notlinked")); } else { if (player.isSneaking()) { emitter.unlink(); - player.sendMessage(new TextComponentTranslation("em.unlink", linkedpos.getX(), linkedpos.getY(), + player.sendMessage(new TranslationTextComponent("em.unlink", linkedpos.getX(), linkedpos.getY(), linkedpos.getZ())); } else { - player.sendMessage(new TextComponentTranslation("lt.linkedpos", linkedpos.getX(), linkedpos.getY(), + player.sendMessage(new TranslationTextComponent("lt.linkedpos", linkedpos.getX(), linkedpos.getY(), linkedpos.getZ())); } } @@ -55,7 +55,8 @@ public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, En } @Override - public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) { + public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, + boolean isMoving) { if (world.isRemote) return; final TileEntity entity = world.getTileEntity(pos); diff --git a/src/main/java/eu/gir/gircredstone/init/GIRCInit.java b/src/main/java/eu/gir/gircredstone/init/GIRCInit.java index 77ddf9f..8417e77 100644 --- a/src/main/java/eu/gir/gircredstone/init/GIRCInit.java +++ b/src/main/java/eu/gir/gircredstone/init/GIRCInit.java @@ -6,9 +6,9 @@ import eu.gir.gircredstone.item.Linkingtool; import eu.gir.gircredstone.tile.TileRedstoneEmitter; import net.minecraft.block.Block; +import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.Item.Properties; -import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemGroup; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.event.RegistryEvent; @@ -30,16 +30,15 @@ public static void registerBlock(RegistryEvent.Register event) { IForgeRegistry registry = event.getRegistry(); registry.register(RS_ACCEPTOR); registry.register(RS_EMITTER); - GIRCRedstoneMain.LOGGER.info("Hello!000000000000=========================================000000"); } @SubscribeEvent public static void registerItem(RegistryEvent.Register event) { IForgeRegistry registry = event.getRegistry(); - registry.register(new ItemBlock(RS_ACCEPTOR, new Properties().group(ItemGroup.REDSTONE)) + registry.register(new BlockItem(RS_ACCEPTOR, new Properties().group(ItemGroup.REDSTONE)) .setRegistryName(RS_ACCEPTOR.getRegistryName())); registry.register(RS_LINKER); - registry.register(new ItemBlock(RS_EMITTER, new Properties().group(ItemGroup.REDSTONE)) + registry.register(new BlockItem(RS_EMITTER, new Properties().group(ItemGroup.REDSTONE)) .setRegistryName(RS_EMITTER.getRegistryName())); } diff --git a/src/main/java/eu/gir/gircredstone/item/Linkingtool.java b/src/main/java/eu/gir/gircredstone/item/Linkingtool.java index b8016db..ed4e345 100644 --- a/src/main/java/eu/gir/gircredstone/item/Linkingtool.java +++ b/src/main/java/eu/gir/gircredstone/item/Linkingtool.java @@ -10,16 +10,16 @@ import eu.gir.gircredstone.tile.TileRedstoneEmitter; import net.minecraft.block.Block; import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumActionResult; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.ActionResultType; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentTranslation; +import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -35,78 +35,77 @@ public Linkingtool() { private static final String ID_Y = "yLinkedPos"; private static final String ID_Z = "zLinkedPos"; - public static void writeBlockPosToNBT(BlockPos pos, NBTTagCompound compound) { + public static void writeBlockPosToNBT(BlockPos pos, CompoundNBT compound) { if (pos != null && compound != null) { - compound.setInt(ID_X, pos.getX()); - compound.setInt(ID_Y, pos.getY()); - compound.setInt(ID_Z, pos.getZ()); + compound.putInt(ID_X, pos.getX()); + compound.putInt(ID_Y, pos.getY()); + compound.putInt(ID_Z, pos.getZ()); } } - public static BlockPos readBlockPosFromNBT(NBTTagCompound compound) { - if (compound != null && compound.hasKey(ID_X) && compound.hasKey(ID_Y) && compound.hasKey(ID_Z)) { + public static BlockPos readBlockPosFromNBT(CompoundNBT 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 EnumActionResult onItemUse(ItemUseContext ctx) { + public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext ctx) { final World worldIn = ctx.getWorld(); - final EntityPlayer player = ctx.getPlayer(); + final PlayerEntity player = ctx.getPlayer(); final BlockPos pos = ctx.getPos(); if (worldIn.isRemote) - return EnumActionResult.PASS; + return ActionResultType.PASS; final Block block = worldIn.getBlockState(pos).getBlock(); - final ItemStack stack = ctx.getItem(); if (player.isSneaking()) { if (Linkingtool.readBlockPosFromNBT(stack.getTag()) != null) { stack.setTag(null); - player.sendMessage(new TextComponentTranslation("lt.reset")); - return EnumActionResult.SUCCESS; + player.sendMessage(new TranslationTextComponent("lt.reset")); + return ActionResultType.SUCCESS; } } if (block instanceof BlockRedstoneAcceptor) { - final NBTTagCompound comp = new NBTTagCompound(); + final CompoundNBT comp = new CompoundNBT(); if (readBlockPosFromNBT(stack.getTag()) != null) - return EnumActionResult.FAIL; + return ActionResultType.FAIL; writeBlockPosToNBT(pos, comp); stack.setTag(comp); - player.sendMessage(new TextComponentTranslation("lt.setpos", pos.getX(), pos.getY(), pos.getZ())); - player.sendMessage(new TextComponentTranslation("lt.setpos.msg")); - return EnumActionResult.SUCCESS; + player.sendMessage(new TranslationTextComponent("lt.setpos", pos.getX(), pos.getY(), pos.getZ())); + player.sendMessage(new TranslationTextComponent("lt.setpos.msg")); + return ActionResultType.SUCCESS; } if (block instanceof BlockRedstoneEmitter) { final TileRedstoneEmitter emitter = (TileRedstoneEmitter) worldIn.getTileEntity(pos); - final NBTTagCompound comp = stack.getTag(); + final CompoundNBT comp = stack.getTag(); final BlockPos linkpos = Linkingtool.readBlockPosFromNBT(comp); if (emitter.link(linkpos)) { player.sendMessage( - new TextComponentTranslation("lt.linkedpos", linkpos.getX(), linkpos.getY(), linkpos.getZ())); + new TranslationTextComponent("lt.linkedpos", linkpos.getX(), linkpos.getY(), linkpos.getZ())); stack.setTag(null); - player.sendMessage(new TextComponentTranslation("lt.reset")); - return EnumActionResult.SUCCESS; + player.sendMessage(new TranslationTextComponent("lt.reset")); + return ActionResultType.SUCCESS; } - player.sendMessage(new TextComponentTranslation("lt.notlinked")); - player.sendMessage(new TextComponentTranslation("lt.notlinked.msg")); - return EnumActionResult.FAIL; + player.sendMessage(new TranslationTextComponent("lt.notlinked")); + player.sendMessage(new TranslationTextComponent("lt.notlinked.msg")); + return ActionResultType.FAIL; } - return EnumActionResult.FAIL; + return ActionResultType.FAIL; } @OnlyIn(Dist.CLIENT) @Override public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) { - final NBTTagCompound nbt = stack.getTag(); + final CompoundNBT nbt = stack.getTag(); if (nbt != null) { final BlockPos pos = Linkingtool.readBlockPosFromNBT(nbt); if (pos != null) { - tooltip.add(new TextComponentTranslation("lt.linkedpos", pos.getX(), pos.getY(), pos.getZ())); + tooltip.add(new TranslationTextComponent("lt.linkedpos", pos.getX(), pos.getY(), pos.getZ())); return; } } - tooltip.add(new TextComponentTranslation("lt.notlinked")); - tooltip.add(new TextComponentTranslation("lt.notlinked.msg")); + tooltip.add(new TranslationTextComponent("lt.notlinked")); + tooltip.add(new TranslationTextComponent("lt.notlinked.msg")); } } diff --git a/src/main/java/eu/gir/gircredstone/tile/TileRedstoneEmitter.java b/src/main/java/eu/gir/gircredstone/tile/TileRedstoneEmitter.java index 751b4dd..6590059 100644 --- a/src/main/java/eu/gir/gircredstone/tile/TileRedstoneEmitter.java +++ b/src/main/java/eu/gir/gircredstone/tile/TileRedstoneEmitter.java @@ -1,16 +1,16 @@ package eu.gir.gircredstone.tile; -import com.google.common.collect.Lists; +import java.util.concurrent.ExecutionException; import eu.gir.gircredstone.block.BlockRedstoneAcceptor; import eu.gir.gircredstone.init.GIRCInit; import eu.gir.gircredstone.item.Linkingtool; -import net.minecraft.block.state.IBlockState; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.block.BlockState; +import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.gen.ChunkProviderServer; +import net.minecraft.world.server.ServerChunkProvider; public class TileRedstoneEmitter extends TileEntity { @@ -21,13 +21,13 @@ public TileRedstoneEmitter() { private BlockPos linkedpos = null; @Override - public NBTTagCompound write(NBTTagCompound compound) { + public CompoundNBT write(CompoundNBT compound) { Linkingtool.writeBlockPosToNBT(linkedpos, compound); return super.write(compound); } @Override - public void read(NBTTagCompound compound) { + public void read(CompoundNBT compound) { super.read(compound); this.linkedpos = Linkingtool.readBlockPosFromNBT(compound); } @@ -51,22 +51,33 @@ public BlockPos getLinkedPos() { } public void accept(final boolean enabled) { - final IBlockState state = world.getBlockState(linkedpos); + final BlockState state = world.getBlockState(linkedpos); if (state.getBlock() instanceof BlockRedstoneAcceptor) { world.setBlockState(linkedpos, state.with(BlockRedstoneAcceptor.POWER, enabled)); } } + @SuppressWarnings("deprecation") public void redstoneUpdate(final boolean enabled) { if (linkedpos != null) { final boolean flag = !world.isBlockLoaded(linkedpos); if(flag) { - final Chunk chunk = world.getChunk(linkedpos); - final ChunkProviderServer provider = (ChunkProviderServer) world.getChunkProvider(); - provider.loadChunks(Lists.newArrayList(chunk.getPos()), ch -> { - accept(enabled); - provider.queueUnload(ch); - }); + final Chunk chunk = world.getChunkAt(linkedpos); + final ServerChunkProvider provider = (ServerChunkProvider) world.getChunkProvider(); + try { + provider.chunkManager.func_219188_b(chunk.getPos()).get().ifLeft(ch -> { + accept(enabled); + try { + provider.chunkManager.func_222973_a(chunk).get(); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + }); + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (ExecutionException e) { + e.printStackTrace(); + } return; } accept(enabled); diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 68356e7..bb14d10 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -24,6 +24,6 @@ Works in unloaded Chunks TM. [[dependencies.gircredstone]] modId="minecraft" mandatory=true - versionRange="[1.13.2]" + versionRange="[1.14.4]" ordering="NONE" side="BOTH" \ No newline at end of file