November 21, 20168 yr Author okay this is firing everytick, how would I put make it so it only updates when placed / when the TE is placed next to it, and have it reset if it is destroyed. Not new to java >> New to modding.
November 21, 20168 yr okay this is firing everytick, how would I put make it so it only updates when placed / when the TE is placed next to it, and have it reset if it is destroyed. Use neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) and getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, ItemStack stack) VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
November 21, 20168 yr Author Okay, so I get a crash: [21:12:40] [server thread/FATAL]: Error executing task java.util.concurrent.ExecutionException: net.minecraft.util.ReportedException: Exception while updating neighbours at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_101] at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_101] at net.minecraft.util.Util.runTask(Util.java:26) [util.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:742) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) [integratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_101] Caused by: net.minecraft.util.ReportedException: Exception while updating neighbours at net.minecraft.world.World.notifyBlockOfStateChange(World.java:605) ~[World.class:?] at net.minecraft.world.World.notifyNeighborsOfStateChange(World.java:531) ~[World.class:?] at net.minecraft.world.World.notifyNeighborsRespectDebug(World.java:482) ~[World.class:?] at net.minecraft.world.World.markAndNotifyBlock(World.java:421) ~[World.class:?] at net.minecraft.world.World.setBlockState(World.java:402) ~[World.class:?] at net.minecraft.block.Block.removedByPlayer(Block.java:1324) ~[block.class:?] at net.minecraft.server.management.PlayerInteractionManager.removeBlock(PlayerInteractionManager.java:298) ~[PlayerInteractionManager.class:?] at net.minecraft.server.management.PlayerInteractionManager.removeBlock(PlayerInteractionManager.java:292) ~[PlayerInteractionManager.class:?] at net.minecraft.server.management.PlayerInteractionManager.tryHarvestBlock(PlayerInteractionManager.java:339) ~[PlayerInteractionManager.class:?] at net.minecraft.server.management.PlayerInteractionManager.onBlockClicked(PlayerInteractionManager.java:175) ~[PlayerInteractionManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayerDigging(NetHandlerPlayServer.java:658) ~[NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketPlayerDigging.processPacket(CPacketPlayerDigging.java:56) ~[CPacketPlayerDigging.class:?] at net.minecraft.network.play.client.CPacketPlayerDigging.processPacket(CPacketPlayerDigging.java:12) ~[CPacketPlayerDigging.class:?] at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_101] at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_101] at net.minecraft.util.Util.runTask(Util.java:25) ~[util.class:?] ... 5 more Caused by: java.lang.NullPointerException at com.lambda.PlentifulMisc.blocks.tile.TileEntitySolarGenerator.updateFromNeighbor(TileEntitySolarGenerator.java:34) ~[TileEntitySolarGenerator.class:?] at com.lambda.PlentifulMisc.blocks.BlockSolarGenerator.neighborChanged(BlockSolarGenerator.java:35) ~[blockSolarGenerator.class:?] at net.minecraft.block.state.BlockStateContainer$StateImplementation.neighborChanged(BlockStateContainer.java:480) ~[blockStateContainer$StateImplementation.class:?] at net.minecraft.world.World.notifyBlockOfStateChange(World.java:584) ~[World.class:?] at net.minecraft.world.World.notifyNeighborsOfStateChange(World.java:531) ~[World.class:?] at net.minecraft.world.World.notifyNeighborsRespectDebug(World.java:482) ~[World.class:?] at net.minecraft.world.World.markAndNotifyBlock(World.java:421) ~[World.class:?] at net.minecraft.world.World.setBlockState(World.java:402) ~[World.class:?] at net.minecraft.block.Block.removedByPlayer(Block.java:1324) ~[block.class:?] at net.minecraft.server.management.PlayerInteractionManager.removeBlock(PlayerInteractionManager.java:298) ~[PlayerInteractionManager.class:?] at net.minecraft.server.management.PlayerInteractionManager.removeBlock(PlayerInteractionManager.java:292) ~[PlayerInteractionManager.class:?] at net.minecraft.server.management.PlayerInteractionManager.tryHarvestBlock(PlayerInteractionManager.java:339) ~[PlayerInteractionManager.class:?] at net.minecraft.server.management.PlayerInteractionManager.onBlockClicked(PlayerInteractionManager.java:175) ~[PlayerInteractionManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayerDigging(NetHandlerPlayServer.java:658) ~[NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketPlayerDigging.processPacket(CPacketPlayerDigging.java:56) ~[CPacketPlayerDigging.class:?] at net.minecraft.network.play.client.CPacketPlayerDigging.processPacket(CPacketPlayerDigging.java:12) ~[CPacketPlayerDigging.class:?] at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_101] at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_101] at net.minecraft.util.Util.runTask(Util.java:25) ~[util.class:?] ... 5 more 0 0 0 0 0 everytime I update it / place it. Also how would I tell if the TE is destroyed and minus connectedTile. here is the block class & te: package com.lambda.PlentifulMisc.blocks; import com.lambda.PlentifulMisc.Reference; import com.lambda.PlentifulMisc.blocks.tile.TileEntitySolarGenerator; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class BlockSolarGenerator extends Block implements ITileEntityProvider{ TileEntitySolarGenerator tileEntitySolarGenerator = new TileEntitySolarGenerator(); public BlockSolarGenerator() { super(Material.ROCK); setUnlocalizedName(Reference.PlentifulMiscBlocks.SOLARGENERATOR.getUnlocalizedName()); setRegistryName(Reference.PlentifulMiscBlocks.SOLARGENERATOR.getRegistryName()); setHardness(2); } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntitySolarGenerator(); } @Override public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) { tileEntitySolarGenerator.updateFromNeighbor(); } @Override public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, ItemStack stack) { tileEntitySolarGenerator.updateFromPlaced(); return super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, stack); } //small upgrades, size of torches, act like torches. } package com.lambda.PlentifulMisc.blocks.tile; import com.lambda.PlentifulMisc.init.ModBlocks; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class TileEntitySolarGenerator extends TileEntity implements ITickable{ public int energyOutput; public int connectedTiles; public boolean canSendEnergy; @Override public void update() { System.out.println(connectedTiles); if(worldObj.isDaytime()) { canSendEnergy = true; } else { canSendEnergy = false; } } public void updateFromNeighbor() { for (EnumFacing face : EnumFacing.values()) { BlockPos pos = getPos().offset(face); if (getWorld().getTileEntity(pos) instanceof TileEnityCrystallizer) { connectedTiles += 1; } else { } } } public void updateFromPlaced() { for (EnumFacing face : EnumFacing.values()) { BlockPos pos = getPos().offset(face); if (getWorld().getTileEntity(pos) instanceof TileEnityCrystallizer) { connectedTiles += 1; } else { } } } } Not new to java >> New to modding.
November 21, 20168 yr First off this is not going to work in your block class TileEntitySolarGenerator tileEntitySolarGenerator = new TileEntitySolarGenerator(); instead use world.getTileEntity(pos) Next pass in a World and BlockPos variable into updateFromPlaced() and updateFromNeighbor() VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
November 21, 20168 yr Author But the methods are Block methods, not TE. Not new to java >> New to modding.
November 21, 20168 yr But the methods are Block methods, not TE. Both methods neighborChanged and getStateForPlacement have a world and a BlockPos parameter. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
November 21, 20168 yr Author So then : package com.lambda.PlentifulMisc.blocks.tile; import com.lambda.PlentifulMisc.init.ModBlocks; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class TileEntitySolarGenerator extends TileEntity implements ITickable{ public int energyOutput; public int connectedTiles; public boolean canSendEnergy; @Override public void update() { System.out.println(connectedTiles); if(worldObj.isDaytime()) { canSendEnergy = true; } else { canSendEnergy = false; } } public void updateFromNeighbor() { } public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) { for (EnumFacing face : EnumFacing.values()) { BlockPos posN = getPos().offset(face); if (getWorld().getTileEntity(posN) instanceof TileEnityCrystallizer) { connectedTiles += 1; } else { } } } public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, ItemStack stack) { for (EnumFacing face : EnumFacing.values()) { BlockPos posState = getPos().offset(face); if (getWorld().getTileEntity(posState) instanceof TileEnityCrystallizer) { connectedTiles += 1; } else { } } return null; } } Not new to java >> New to modding.
November 21, 20168 yr So then : package com.lambda.PlentifulMisc.blocks.tile; import com.lambda.PlentifulMisc.init.ModBlocks; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class TileEntitySolarGenerator extends TileEntity implements ITickable{ public int energyOutput; public int connectedTiles; public boolean canSendEnergy; @Override public void update() { System.out.println(connectedTiles); if(worldObj.isDaytime()) { canSendEnergy = true; } else { canSendEnergy = false; } } public void updateFromNeighbor() { } public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) { for (EnumFacing face : EnumFacing.values()) { BlockPos posN = getPos().offset(face); if (getWorld().getTileEntity(posN) instanceof TileEnityCrystallizer) { connectedTiles += 1; } else { } } } public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, ItemStack stack) { for (EnumFacing face : EnumFacing.values()) { BlockPos posState = getPos().offset(face); if (getWorld().getTileEntity(posState) instanceof TileEnityCrystallizer) { connectedTiles += 1; } else { } } return null; } } You only need the World and BlockPos ones,and what does your Block file look like now? VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
November 21, 20168 yr Author here is the updated te: package com.lambda.PlentifulMisc.blocks.tile; import com.lambda.PlentifulMisc.init.ModBlocks; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class TileEntitySolarGenerator extends TileEntity implements ITickable{ public int energyOutput; public int connectedTiles; public boolean canSendEnergy; @Override public void update() { System.out.println(connectedTiles); if(worldObj.isDaytime()) { canSendEnergy = true; } else { canSendEnergy = false; } } public void neighborChanged(World worldIn, BlockPos pos) { for (EnumFacing face : EnumFacing.values()) { BlockPos posN = getPos().offset(face); if (getWorld().getTileEntity(posN) instanceof TileEnityCrystallizer) { connectedTiles += 1; } else { } } } public IBlockState getStateForPlacement(World world, BlockPos pos) { for (EnumFacing face : EnumFacing.values()) { BlockPos posS = getPos().offset(face); if (getWorld().getTileEntity(posS) instanceof TileEnityCrystallizer) { connectedTiles += 1; } else { } } return null; } } and block package com.lambda.PlentifulMisc.blocks; import com.lambda.PlentifulMisc.Reference; import com.lambda.PlentifulMisc.blocks.tile.TileEntitySolarGenerator; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class BlockSolarGenerator extends Block implements ITileEntityProvider{ TileEntitySolarGenerator tileEntitySolarGenerator = new TileEntitySolarGenerator(); public BlockSolarGenerator() { super(Material.ROCK); setUnlocalizedName(Reference.PlentifulMiscBlocks.SOLARGENERATOR.getUnlocalizedName()); setRegistryName(Reference.PlentifulMiscBlocks.SOLARGENERATOR.getRegistryName()); setHardness(2); } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntitySolarGenerator(); } //small upgrades, size of torches, act like torches. } Not new to java >> New to modding.
November 21, 20168 yr First don't implement ITileEntityProvider instead override hasTileEntity(IBlockState) and createTileEntity(World, IBlockState) Then you removed the methods neighborChanged()and getStateForPlacement() VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
November 21, 20168 yr Author So just this in the block class: public class BlockSolarGenerator extends Block { TileEntitySolarGenerator tileEntitySolarGenerator = new TileEntitySolarGenerator(); public BlockSolarGenerator() { super(Material.ROCK); setUnlocalizedName(Reference.PlentifulMiscBlocks.SOLARGENERATOR.getUnlocalizedName()); setRegistryName(Reference.PlentifulMiscBlocks.SOLARGENERATOR.getRegistryName()); setHardness(2); } @Override public boolean hasTileEntity() { return true; } @Override public TileEntity createTileEntity(World world, IBlockState state) { return new TileEnityCrystallizer(); } //small upgrades, size of torches, act like torches. } te just staying the same Not new to java >> New to modding.
November 21, 20168 yr That is not the correct hasTileEntity() method. You want hasTileEntity(IBlockState state). Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
November 21, 20168 yr Author So this: public class BlockSolarGenerator extends Block { TileEntitySolarGenerator tileEntitySolarGenerator = new TileEntitySolarGenerator(); public BlockSolarGenerator() { super(Material.ROCK); setUnlocalizedName(Reference.PlentifulMiscBlocks.SOLARGENERATOR.getUnlocalizedName()); setRegistryName(Reference.PlentifulMiscBlocks.SOLARGENERATOR.getRegistryName()); setHardness(2); } @Override public boolean hasTileEntity(IBlockState state) { return true; } @Override public TileEntity createTileEntity(World world, IBlockState state) { return new TileEnityCrystallizer(); } @Override public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) { tileEntitySolarGenerator.neighborChanged(worldIn, pos); } @Override public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY,float hitZ, int meta, EntityLivingBase placer, ItemStack stack) { tileEntitySolarGenerator.getStateForPlacement(world, pos); return super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, stack); } //small upgrades, size of torches, act like torches. } Also, what should I be returning on getStateForPlacement in the te & block Not new to java >> New to modding.
November 22, 20168 yr You can't do this. TileEntitySolarGenerator tileEntitySolarGenerator = new TileEntitySolarGenerator(); tileEntitySolarGenerator.neighborChanged(worldIn, pos) You need to do worldIn.getTileEntity(pos) to get the Tile Entity. And you would just use the super.getStateForPlacement(...) VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.