Jump to content

meee39

Members
  • Posts

    119
  • Joined

  • Last visited

Everything posted by meee39

  1. In my mod I have a TESR for a block that shows a floating spinning item from its inventory. There is also a boolean that states wether the block has a Nether Star inside it. In my TESR I try to render the Nether Star by using an if condition checking if it has the Nether Star, but it always equals false. I know that the function for setting the nether star in the block executes because I have put System.out.printLine() in various places. It seems like in the TESR the TE properties aren't being accessed properly because it never executes the Nether Star rendering code even though it should. package com.leo.mobsuppressors.tileentity; import org.lwjgl.opengl.GL11; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraftforge.client.ForgeHooksClient; public class TESRSuppressionTower extends TileEntitySpecialRenderer<TileEntitySuppressionTower> { @Override public void renderTileEntityAt(TileEntitySuppressionTower te, double x, double y, double z, float partialTicks, int destroyStage) { GlStateManager.enableRescaleNormal(); GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1f); GlStateManager.enableBlend(); RenderHelper.enableStandardItemLighting(); GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); ItemStack stack = te.itemStackHandler.getStackInSlot(0); if (!stack.isEmpty()) { GlStateManager.pushMatrix(); GlStateManager.translate(x + 0.5, y + 0.15, z + 0.5); GlStateManager.rotate((te.getWorld().getTotalWorldTime() + partialTicks) * 4, 0, 1, 0); IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(stack, te.getWorld(), null); model = ForgeHooksClient.handleCameraTransforms(model, ItemCameraTransforms.TransformType.GROUND, false); Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Minecraft.getMinecraft().getRenderItem().renderItem(stack, model); GlStateManager.popMatrix(); } if (te.hasNetherStar) { GlStateManager.pushMatrix(); GlStateManager.translate(x + 0.4, y + 0.5, z + 0.4); GlStateManager.scale(0.75, 0.75, 0.75); GlStateManager.rotate(90, 0, 0, 0); IBakedModel netherStarModel = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(new ItemStack(Items.NETHER_STAR), te.getWorld(), null); Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Minecraft.getMinecraft().getRenderItem().renderItem(new ItemStack(Items.NETHER_STAR, 1), netherStarModel); GlStateManager.popMatrix(); } GlStateManager.disableRescaleNormal(); GlStateManager.disableBlend(); } } package com.leo.mobsuppressors.tileentity; import javax.annotation.Nullable; import com.leo.mobsuppressors.MobSuppressors; import com.leo.mobsuppressors.network.PacketRequestUpdateTower; import com.leo.mobsuppressors.network.PacketUpdateTower; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemStackHandler; public class TileEntitySuppressionTower extends TileEntity { public ItemStackHandler itemStackHandler = new ItemStackHandler(1) { @Override protected void onContentsChanged(int slot) { if (!world.isRemote) { lastChangeTime = world.getTotalWorldTime(); MobSuppressors.network.sendToAllAround(new PacketUpdateTower(TileEntitySuppressionTower.this), new NetworkRegistry.TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 64)); } } }; public boolean hasNetherStar; public int netherStarUsesLeft; public long lastChangeTime; public TileEntitySuppressionTower() { this.hasNetherStar = false; this.netherStarUsesLeft = 0; } public void setHasNetherStar() { this.hasNetherStar = true; this.netherStarUsesLeft = 10; } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { compound.setTag("inventory", itemStackHandler.serializeNBT()); compound.setLong("lastChangeTime", lastChangeTime); compound.setBoolean("hasNetherStar", hasNetherStar); compound.setInteger("netherStarUsesLeft", netherStarUsesLeft); return super.writeToNBT(compound); } @Override public void readFromNBT(NBTTagCompound compound) { itemStackHandler.deserializeNBT(compound.getCompoundTag("inventory")); lastChangeTime = compound.getLong("lastChangeTime"); hasNetherStar = compound.getBoolean("hasNetherStar"); netherStarUsesLeft = compound.getInteger("netherStarUsesLeft"); super.readFromNBT(compound); } @Override public void onLoad() { if (world.isRemote) { MobSuppressors.network.sendToServer(new PacketRequestUpdateTower(this)); } } @Override public AxisAlignedBB getRenderBoundingBox() { return new AxisAlignedBB(getPos(), getPos().add(1, 2, 1)); } @Override public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); } @Nullable @Override public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ? (T)itemStackHandler : super.getCapability(capability, facing); } } package com.leo.mobsuppressors.blocks; import com.leo.mobsuppressors.CreativeTab; import com.leo.mobsuppressors.tileentity.TileEntitySuppressionTower; 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.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; public class BlockSuppressionTower extends Block implements ITileEntityProvider { public BlockSuppressionTower(String unlocalisedName, String registryName) { super(Material.ROCK); this.setUnlocalizedName(unlocalisedName); this.setRegistryName(registryName); this.setCreativeTab(CreativeTab.mobSuppressorCreativeTab); } public BlockSuppressionTower(Material materialIn) { super(materialIn); } @Override public boolean isOpaqueCube(IBlockState state) { return false; } @Override public boolean isFullCube(IBlockState state) { return false; } @Override public boolean isFullyOpaque(IBlockState state) { return false; } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntitySuppressionTower(); } @Override public void breakBlock(World world, BlockPos pos, IBlockState state) { super.breakBlock(world, pos, state); world.removeTileEntity(pos); TileEntitySuppressionTower tile = (TileEntitySuppressionTower)world.getTileEntity(pos); IItemHandler itemHandler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.NORTH); ItemStack stack = itemHandler.getStackInSlot(0); if (!stack.isEmpty()) { EntityItem item = new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), stack); world.spawnEntity(item); } } @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (!world.isRemote) { TileEntitySuppressionTower TEST = (TileEntitySuppressionTower)world.getTileEntity(pos); IItemHandler itemHandler = TEST.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side); if (player.getHeldItem(hand).isEmpty()) { player.setHeldItem(hand, itemHandler.extractItem(0, 64, false)); } else if (player.getHeldItem(hand).getItem() == Items.NETHER_STAR) { if (!TEST.hasNetherStar) { player.getHeldItem(hand).shrink(1); TEST.setHasNetherStar(); } } else { player.setHeldItem(hand, itemHandler.insertItem(0, player.getHeldItem(hand), false)); } TEST.markDirty(); } return true; } } What I want: What I get:
  2. That doesn't matter now as I have got it working.
  3. My custom block model is not rendering. All it comes up as is the black and purple cube. There are two reasons that I know that it is not a problem with the model fle: 1. I created it with Mr. Crayfish's Model Creator and used an online JSON validator (it was valid). 2. It does not show up as invisible. Code: package com.leo.mobsuppressors.blocks; import java.util.ArrayList; import com.leo.mobsuppressors.EnumMobSuppressorType; import com.leo.mobsuppressors.MobSuppressors; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraftforge.fml.common.registry.GameRegistry; public class ModBlocks { public static Block enderSuppressor; public static Block creeperSuppressor; public static Block suppressionPedestal; public static void createBlocks() { enderSuppressor = new BlockMobSuppressor("endersuppressor", "endersuppressor", EnumMobSuppressorType.ENDER); creeperSuppressor = new BlockMobSuppressor("creepersuppressor", "creepersuppressor", EnumMobSuppressorType.CREEPER); suppressionPedestal = new BlockSuppressionPedestal("suppressionpedestal", "suppressionpedestal"); } public static void init() { createBlocks(); GameRegistry.register(enderSuppressor); GameRegistry.register(new ItemBlock(enderSuppressor).setRegistryName("endersuppressor")); GameRegistry.register(creeperSuppressor); GameRegistry.register(new ItemBlock(creeperSuppressor).setRegistryName("creepersuppressor")); GameRegistry.register(suppressionPedestal); GameRegistry.register(new ItemBlock(suppressionPedestal).setRegistryName("suppressionpedestal")); } public static void registerRenderers() { registerRenderer(enderSuppressor); registerRenderer(creeperSuppressor); registerRenderer(suppressionPedestal); } public static void registerRenderer(Block block) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(MobSuppressors.modid + ":" + block.getUnlocalizedName().substring(5), "inventory")); } } package com.leo.mobsuppressors.blocks; import com.leo.mobsuppressors.CreativeTab; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; public class BlockSuppressionPedestal extends Block { public BlockSuppressionPedestal(String unlocalizedName, String registryName) { super(Material.ROCK); this.setCreativeTab(CreativeTab.mobSuppressorCreativeTab); this.setUnlocalizedName(unlocalizedName); this.setRegistryName(registryName); } public BlockSuppressionPedestal(Material materialIn) { super(materialIn); } } { "forge_marker": 1, "variants": { "normal" { "model": "mob:suppressors:suppressionpedestal" }, "inventory": { "model": "mobsuppressors:suppressionpedestal", "transform": "forge:default-block" } } } { "__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)", "textures": { "particle": "blocks/suppressionpedestal_bottom", "0": "blocks/suppressionpedestal_bottom" }, "elements": [ { "name": "Cube", "from": [ 0.0, 0.0, 1.0 ], "to": [ 16.0, 1.0, 16.0 ], "faces": { "north": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 1.0 ] }, "east": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 1.0 ] }, "south": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 1.0 ] }, "west": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 1.0 ] }, "up": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }, "down": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 16.0 ] } } } ] }
  4. It's fine now. I have fixed everything and I am now making my own progress with my mod. Thanks for helping :).
  5. I have made every change you suggested (except for the type enum) although the blocks still seem to be turning into each other. I also installed WAILA to see if it was a graphical error or if the blocks were actually changing type; and they were.
  6. package com.leo.mobsuppressors.tileentity; import java.util.Random; import com.leo.mobsuppressors.blocks.BlockMobSuppressor; import jline.internal.Nullable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.ITickable; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemStackHandler; public class TileEntityMobSuppressor extends TileEntity implements ITickable, IMobSuppressorTE { public static BlockMobSuppressor block; public boolean isPublic; public static final int maxTicks = 300; public int powerTicksLeft = 0; public Random RNG = new Random(); public String type; public ItemStackHandler itemStackHandler = new ItemStackHandler(1) { @Override protected void onContentsChanged(int slot) { markDirty(); } }; public TileEntityMobSuppressor() {} public TileEntityMobSuppressor(BlockMobSuppressor block, String type) { this.block = block; this.isPublic = true; this.type = type; } @Override public void update() { if (!(world.getBlockState(getPos()).getBlock() instanceof BlockMobSuppressor)) { return; } EnumParticleTypes particleType = EnumParticleTypes.CRIT; switch (type) { case "ender": particleType = EnumParticleTypes.PORTAL; case "creeper": particleType = EnumParticleTypes.EXPLOSION_NORMAL; } world.spawnParticle(particleType, RNG.nextFloat() + pos.getX(), RNG.nextFloat() + pos.getY(), RNG.nextFloat() + pos.getZ(), 0.1, 0.1, 0.1, 0); if (!world.isRemote) { updateInventory(); } } private void updateInventory() { if (powerTicksLeft > 0) { powerTicksLeft--; } else { if (itemStackHandler.getStackInSlot(0).getCount() > 0) { itemStackHandler.getStackInSlot(0).shrink(1); setToFullPowerTicks(); } } System.out.println(powerTicksLeft); world.markBlockRangeForRenderUpdate(pos, pos); world.setBlockState(getPos(), block.getDefaultState().withProperty(block.is_powered, powerTicksLeft > 0)); markDirty(); } public void sendUpdate(boolean powered) { if (!world.isRemote) { world.setBlockState(getPos(), world.getBlockState(getPos()).withProperty(block.is_powered, powered)); world.markBlockRangeForRenderUpdate(pos, pos); world.notifyBlockUpdate(pos, world.getBlockState(getPos()), world.getBlockState(getPos()).withProperty(block.is_powered, powered), 3); world.scheduleBlockUpdate(pos,this.getBlockType(),0,0); markDirty(); } } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setTag("items", itemStackHandler.serializeNBT()); compound.setBoolean("isPublic", isPublic); compound.setInteger("powerTicksLeft", powerTicksLeft); return compound; } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); if (compound.hasKey("items")) { itemStackHandler.deserializeNBT((NBTTagCompound)compound.getTag("items")); } isPublic = compound.getBoolean("isPublic"); powerTicksLeft = compound.getInteger("powerTicksLeft"); } @Override @Nullable public SPacketUpdateTileEntity getUpdatePacket() { return new SPacketUpdateTileEntity(this.pos, 3, this.getUpdateTag()); } @Override public NBTTagCompound getUpdateTag() { return this.writeToNBT(new NBTTagCompound()); } @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { super.onDataPacket(net, pkt); handleUpdateTag(pkt.getNbtCompound()); } @Override public boolean isPublic() { return isPublic; } @Override public void setToFullPowerTicks() { this.powerTicksLeft = maxTicks; } @Override public int getPowerTicksLeft() { return powerTicksLeft; } @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return true; } return super.hasCapability(capability, facing); } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return (T) itemStackHandler; } return super.getCapability(capability, facing); } public boolean canInteractWith(EntityPlayer playerIn) { return !isInvalid() && playerIn.getDistanceSq(pos.add(0.5D, 0.5D, 0.5D)) <= 64D; } }
  7. Oops. I'm very silly. There is another problem with it though. When the fuel is consumed setFullPowerTicks makes the power set to 300 for one tick.
  8. In my mod I have some blocks that are ver similar, and so they use the same class. The problem is that when I place the blocks from the same class next to each other they all start to use the texture and particle effects of the most recently placed one. package com.leo.mobsuppressors.blocks; import com.leo.mobsuppressors.CreativeTab; import com.leo.mobsuppressors.MobSuppressors; import com.leo.mobsuppressors.gui.ModGUIHandler; import com.leo.mobsuppressors.tileentity.IMobSuppressorTE; import com.leo.mobsuppressors.tileentity.TileEntityMobSuppressor; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockMobSuppressor extends Block implements ITileEntityProvider { public static final PropertyBool is_powered = PropertyBool.create("is_powered"); public static String type; protected BlockMobSuppressor(String unlocalizedName, String registryName, String type) { super(Material.IRON); this.setCreativeTab(CreativeTab.mobSuppressorCreativeTab); this.setUnlocalizedName(unlocalizedName); this.setRegistryName(registryName); this.setHardness(2); this.setResistance(6000f); this.setHarvestLevel("pickaxe", 3); this.setDefaultState(this.blockState.getBaseState().withProperty(is_powered, false)); this.type = type; } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, is_powered); } @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(is_powered, meta == 0); } @Override public int getMetaFromState(IBlockState state) { return state.getValue(is_powered) ? 1: 0; } @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { return state.withProperty(is_powered, state.getValue(is_powered)); } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityMobSuppressor(this, type); } @Override public void breakBlock(World world, BlockPos pos, IBlockState state) { super.breakBlock(world, pos, state); world.removeTileEntity(pos); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (!worldIn.isRemote) { playerIn.openGui(MobSuppressors.instance, ModGUIHandler.enderSuppressorGUIID, worldIn, pos.getX(), pos.getY(), pos.getZ()); } return true; } } package com.leo.mobsuppressors.blocks; import java.util.ArrayList; import com.leo.mobsuppressors.MobSuppressors; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraftforge.fml.common.registry.GameRegistry; public class ModBlocks { public static Block enderSuppressor; public static Block creeperSuppressor; public static void createBlocks() { enderSuppressor = new BlockMobSuppressor("endersuppressor", "endersuppressor", "ender"); creeperSuppressor = new BlockMobSuppressor("creepersuppressor", "creepersuppressor", "creeper"); } public static void init() { createBlocks(); GameRegistry.register(enderSuppressor); GameRegistry.register(new ItemBlock(enderSuppressor).setRegistryName("endersuppressor")); GameRegistry.register(creeperSuppressor); GameRegistry.register(new ItemBlock(creeperSuppressor).setRegistryName("creepersuppressor")); } public static void registerRenderers() { registerRenderer(enderSuppressor); registerRenderer(creeperSuppressor); } public static void registerRenderer(Block block) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(MobSuppressors.modid + ":" + block.getUnlocalizedName().substring(5), "inventory")); } }
  9. In my mod I have a block that you put fuel inside to make it do what it is meant to do. I have it partially working in two different ways: package com.leo.mobsuppressors.tileentity; import java.util.Random; import com.leo.mobsuppressors.blocks.BlockEnderSuppressor; import jline.internal.Nullable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemEnderPearl; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.ITickable; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemStackHandler; public class TileEntityEnderSuppressor extends TileEntity implements ITickable, IMobSuppressorTE { public static BlockEnderSuppressor block; public boolean isPublic; public static final int maxTicks = 300; public int powerTicksLeft = 0; public Random RNG = new Random(); public ItemStackHandler itemStackHandler = new ItemStackHandler(1) { @Override protected void onContentsChanged(int slot) { TileEntityEnderSuppressor.this.markDirty(); } }; public TileEntityEnderSuppressor() {} public TileEntityEnderSuppressor(BlockEnderSuppressor block) { this.block = block; this.isPublic = true; } @Override public void update() { if (!(world.getBlockState(getPos()).getBlock() instanceof BlockEnderSuppressor)) { return; } world.spawnParticle(EnumParticleTypes.PORTAL, RNG.nextFloat() + pos.getX(), RNG.nextFloat() + pos.getY(), RNG.nextFloat() + pos.getZ(), 0.1, 0.1, 0.1, 0); if (!world.isRemote) { world.setBlockState(this.getPos(), world.getBlockState(getPos()).withProperty(block.is_powered, true)); if (powerTicksLeft > 0) { powerTicksLeft--; sendUpdate(true); } else { if (itemStackHandler.getStackInSlot(0).isEmpty()) { world.setBlockState(this.getPos(), world.getBlockState(getPos()).withProperty(block.is_powered, false)); } else { if (itemStackHandler.getStackInSlot(0).getItem() instanceof ItemEnderPearl) { itemStackHandler.getStackInSlot(0).shrink(1); setFullPowerTicks(); sendUpdate(true); } } } } System.out.println(powerTicksLeft); } public void sendUpdate(boolean powered) { world.markBlockRangeForRenderUpdate(pos, pos); world.notifyBlockUpdate(pos, world.getBlockState(getPos()), world.getBlockState(getPos()).withProperty(block.is_powered, powered), 3); world.scheduleBlockUpdate(pos,this.getBlockType(),0,0); markDirty(); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setTag("items", itemStackHandler.serializeNBT()); compound.setBoolean("isPublic", isPublic); compound.setInteger("powerTicksLeft", powerTicksLeft); return compound; } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); if (compound.hasKey("items")) { itemStackHandler.deserializeNBT((NBTTagCompound)compound.getTag("items")); } isPublic = compound.getBoolean("isPublic"); powerTicksLeft = compound.getInteger("powerTicksLeft"); } @Override @Nullable public SPacketUpdateTileEntity getUpdatePacket() { return new SPacketUpdateTileEntity(this.pos, 3, this.getUpdateTag()); } @Override public NBTTagCompound getUpdateTag() { return this.writeToNBT(new NBTTagCompound()); } @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { super.onDataPacket(net, pkt); handleUpdateTag(pkt.getNbtCompound()); } @Override public boolean isPublic() { return isPublic; } @Override public void setFullPowerTicks() { this.powerTicksLeft = maxTicks; } @Override public int getPowerTicksLeft() { return powerTicksLeft; } @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return true; } return super.hasCapability(capability, facing); } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return (T) itemStackHandler; } return super.getCapability(capability, facing); } public boolean canInteractWith(EntityPlayer playerIn) { return !isInvalid() && playerIn.getDistanceSq(pos.add(0.5D, 0.5D, 0.5D)) <= 64D; } } In that way the fuel items look like they are consumed instantly by the block, but if you click on the slot again you will get the items back on your cursor. So the function of the block is not triggered because the fuel is not consumed. And when I get rid of the world.setBlock() and have the code like this: package com.leo.mobsuppressors.tileentity; import java.util.Random; import com.leo.mobsuppressors.blocks.BlockEnderSuppressor; import jline.internal.Nullable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemEnderPearl; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.ITickable; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemStackHandler; public class TileEntityEnderSuppressor extends TileEntity implements ITickable, IMobSuppressorTE { public static BlockEnderSuppressor block; public boolean isPublic; public static final int maxTicks = 300; public int powerTicksLeft = 0; public Random RNG = new Random(); public ItemStackHandler itemStackHandler = new ItemStackHandler(1) { @Override protected void onContentsChanged(int slot) { TileEntityEnderSuppressor.this.markDirty(); } }; public TileEntityEnderSuppressor() {} public TileEntityEnderSuppressor(BlockEnderSuppressor block) { this.block = block; this.isPublic = true; } @Override public void update() { if (!(world.getBlockState(getPos()).getBlock() instanceof BlockEnderSuppressor)) { return; } world.spawnParticle(EnumParticleTypes.PORTAL, RNG.nextFloat() + pos.getX(), RNG.nextFloat() + pos.getY(), RNG.nextFloat() + pos.getZ(), 0.1, 0.1, 0.1, 0); if (!world.isRemote) { //world.setBlockState(this.getPos(), world.getBlockState(getPos()).withProperty(block.is_powered, true)); if (powerTicksLeft > 0) { powerTicksLeft--; sendUpdate(true); } else { if (itemStackHandler.getStackInSlot(0).isEmpty()) { world.setBlockState(this.getPos(), world.getBlockState(getPos()).withProperty(block.is_powered, false)); } else { if (itemStackHandler.getStackInSlot(0).getItem() instanceof ItemEnderPearl) { itemStackHandler.getStackInSlot(0).shrink(1); setFullPowerTicks(); sendUpdate(true); } } } } System.out.println(powerTicksLeft); } public void sendUpdate(boolean powered) { world.markBlockRangeForRenderUpdate(pos, pos); world.notifyBlockUpdate(pos, world.getBlockState(getPos()), world.getBlockState(getPos()).withProperty(block.is_powered, powered), 3); world.scheduleBlockUpdate(pos,this.getBlockType(),0,0); markDirty(); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setTag("items", itemStackHandler.serializeNBT()); compound.setBoolean("isPublic", isPublic); compound.setInteger("powerTicksLeft", powerTicksLeft); return compound; } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); if (compound.hasKey("items")) { itemStackHandler.deserializeNBT((NBTTagCompound)compound.getTag("items")); } isPublic = compound.getBoolean("isPublic"); powerTicksLeft = compound.getInteger("powerTicksLeft"); } @Override @Nullable public SPacketUpdateTileEntity getUpdatePacket() { return new SPacketUpdateTileEntity(this.pos, 3, this.getUpdateTag()); } @Override public NBTTagCompound getUpdateTag() { return this.writeToNBT(new NBTTagCompound()); } @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { super.onDataPacket(net, pkt); handleUpdateTag(pkt.getNbtCompound()); } @Override public boolean isPublic() { return isPublic; } @Override public void setFullPowerTicks() { this.powerTicksLeft = maxTicks; } @Override public int getPowerTicksLeft() { return powerTicksLeft; } @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return true; } return super.hasCapability(capability, facing); } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return (T) itemStackHandler; } return super.getCapability(capability, facing); } public boolean canInteractWith(EntityPlayer playerIn) { return !isInvalid() && playerIn.getDistanceSq(pos.add(0.5D, 0.5D, 0.5D)) <= 64D; } } The fuel gets consumed properly but the animation for the block doesn't play and so the function doesn't activate either. I understand why that happens (it's because I get rid of the world.setBlock()), although what I wonder is why having that line there seems to make the fuel not get consumed properly.
  10. That didn't make any difference. Here is the class now: package com.leo.mobsuppressors.tileentity; import java.util.Random; import com.leo.mobsuppressors.blocks.BlockEnderSuppressor; import jline.internal.Nullable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemEnderPearl; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.ITickable; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemStackHandler; public class TileEntityEnderSuppressor extends TileEntity implements ITickable, IMobSuppressorTE { public static BlockEnderSuppressor block; public boolean isPublic; public static final int maxTicks = 300; public int powerTicksLeft = 0; public Random RNG = new Random(); public ItemStackHandler itemStackHandler = new ItemStackHandler(1) { @Override protected void onContentsChanged(int slot) { TileEntityEnderSuppressor.this.markDirty(); } }; public TileEntityEnderSuppressor() {} public TileEntityEnderSuppressor(BlockEnderSuppressor block) { this.block = block; this.isPublic = true; } @Override public void update() { if (!(world.getBlockState(getPos()).getBlock() instanceof BlockEnderSuppressor)) { return; } world.spawnParticle(EnumParticleTypes.PORTAL, RNG.nextFloat() + pos.getX(), RNG.nextFloat() + pos.getY(), RNG.nextFloat() + pos.getZ(), 0.1, 0.1, 0.1, 0); if (!world.isRemote) { world.setBlockState(this.getPos(), world.getBlockState(getPos()).withProperty(block.is_powered, true)); if (powerTicksLeft > 0) { powerTicksLeft--; world.markBlockRangeForRenderUpdate(pos, pos); world.notifyBlockUpdate(pos, world.getBlockState(getPos()), world.getBlockState(getPos()).withProperty(block.is_powered, true), 3); world.scheduleBlockUpdate(pos,this.getBlockType(),0,0); markDirty(); world.setBlockState(this.getPos(), world.getBlockState(getPos()).withProperty(block.is_powered, true)); } else { if (itemStackHandler.getStackInSlot(0).isEmpty()) { world.setBlockState(this.getPos(), world.getBlockState(getPos()).withProperty(block.is_powered, false)); } else { if (itemStackHandler.getStackInSlot(0).getItem() instanceof ItemEnderPearl) { itemStackHandler.getStackInSlot(0).shrink(1); setFullPowerTicks(); world.markBlockRangeForRenderUpdate(pos, pos); world.notifyBlockUpdate(pos, world.getBlockState(getPos()), world.getBlockState(getPos()).withProperty(block.is_powered, true), 3); world.scheduleBlockUpdate(pos,this.getBlockType(),0,0); markDirty(); } } } } System.out.println(powerTicksLeft); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setTag("items", itemStackHandler.serializeNBT()); compound.setBoolean("isPublic", isPublic); compound.setInteger("powerTicksLeft", powerTicksLeft); return compound; } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); if (compound.hasKey("items")) { itemStackHandler.deserializeNBT((NBTTagCompound)compound.getTag("items")); } isPublic = compound.getBoolean("isPublic"); powerTicksLeft = compound.getInteger("powerTicksLeft"); } @Override @Nullable public SPacketUpdateTileEntity getUpdatePacket() { return new SPacketUpdateTileEntity(this.pos, 3, this.getUpdateTag()); } @Override public NBTTagCompound getUpdateTag() { return this.writeToNBT(new NBTTagCompound()); } @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { super.onDataPacket(net, pkt); handleUpdateTag(pkt.getNbtCompound()); } @Override public boolean isPublic() { return isPublic; } @Override public void setFullPowerTicks() { this.powerTicksLeft = maxTicks; } @Override public int getPowerTicksLeft() { return powerTicksLeft; } @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return true; } return super.hasCapability(capability, facing); } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return (T) itemStackHandler; } return super.getCapability(capability, facing); } public boolean canInteractWith(EntityPlayer playerIn) { return !isInvalid() && playerIn.getDistanceSq(pos.add(0.5D, 0.5D, 0.5D)) <= 64D; } }
  11. I added those methods. What do I need to do to make it work?
  12. Thanks! It works now. Although, as with all programming, by doing this I have discovered the problem that all fuel seems to get consumed when you leave the GUI. Also the full power ticks doesn't seem to be getting set now.
  13. Derp. I thought it wouldn't matter to post it after the imports... package com.leo.mobsuppressors.tileentity; import java.util.Random; import com.leo.mobsuppressors.blocks.BlockEnderSuppressor; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemEnderPearl; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.ITickable; import net.minecraft.world.World; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemStackHandler; public class TileEntityEnderSuppressor extends TileEntity implements ITickable, IMobSuppressorTE { private World world = Minecraft.getMinecraft().world; public BlockEnderSuppressor block; public boolean isPublic; public static final int maxTicks = 300; public int powerTicksLeft = 0; public ItemStackHandler itemStackHandler = new ItemStackHandler(1) { @Override protected void onContentsChanged(int slot) { TileEntityEnderSuppressor.this.markDirty(); } }; public TileEntityEnderSuppressor() {} public TileEntityEnderSuppressor(BlockEnderSuppressor block) { this.block = block; this.isPublic = true; } @Override public void update() { if (world.getBlockState(getPos()).getBlock() instanceof BlockEnderSuppressor != true) { return; } if (world != null) { Random RNG = new Random(); world.spawnParticle(EnumParticleTypes.PORTAL, RNG.nextFloat() + pos.getX(), RNG.nextFloat() + pos.getY(), RNG.nextFloat() + pos.getZ(), 0.1, 0.1, 0.1, 0); } if (powerTicksLeft > 0) { powerTicksLeft--; world.setBlockState(this.getPos(), world.getBlockState(getPos()).withProperty(block.is_powered, false)); } else { if (itemStackHandler.getStackInSlot(0).isEmpty()) { world.setBlockState(this.getPos(), world.getBlockState(getPos()).withProperty(block.is_powered, true)); } else { if (itemStackHandler.getStackInSlot(0).getItem() instanceof ItemEnderPearl) { itemStackHandler.getStackInSlot(0).shrink(1); setFullPowerTicks(); } } } } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setTag("items", itemStackHandler.serializeNBT()); compound.setBoolean("isPublic", isPublic); compound.setInteger("powerTicksLeft", powerTicksLeft); return compound; } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); if (compound.hasKey("items")) { itemStackHandler.deserializeNBT((NBTTagCompound)compound.getTag("items")); } isPublic = compound.getBoolean("isPublic"); powerTicksLeft = compound.getInteger("powerTicksLeft"); } @Override public boolean isPublic() { return isPublic; } @Override public void setFullPowerTicks() { this.powerTicksLeft = maxTicks; } @Override public int getPowerTicksLeft() { return powerTicksLeft; } @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return true; } return super.hasCapability(capability, facing); } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return (T) itemStackHandler; } return super.getCapability(capability, facing); } public boolean canInteractWith(EntityPlayer playerIn) { return !isInvalid() && playerIn.getDistanceSq(pos.add(0.5D, 0.5D, 0.5D)) <= 64D; } }
  14. In my mod I have a TE that does a function while it has power. When it runs out of power it will consume one piece of fuel from its inventory (if there is any there). Every tick the power level decreases by one and when it gets to the end it triggers the fuel consumption. So the block has two different states: powered and unpowered. You can tell which state it is in because they have different textures. The problem is while the power ticks left are counting down the block state flickers between the powered and unpowered state. I also put in a System.out.printline() to check what is going on and it would end up like this: Instead of: Like it should do. I don't know anything about packets and data syncing with FML although I know that things to do with that can cause problems so I think it might be something to do with data not being synced between client and server. Code: public class TileEntityEnderSuppressor extends TileEntity implements ITickable, IMobSuppressorTE { private World world = Minecraft.getMinecraft().world; public BlockEnderSuppressor block; public boolean isPublic; public static final int maxTicks = 300; public int powerTicksLeft = 0; public ItemStackHandler itemStackHandler = new ItemStackHandler(1) { @Override protected void onContentsChanged(int slot) { TileEntityEnderSuppressor.this.markDirty(); } }; public TileEntityEnderSuppressor() {} public TileEntityEnderSuppressor(BlockEnderSuppressor block) { this.block = block; this.isPublic = true; } @Override public void update() { if (world.getBlockState(getPos()).getBlock() instanceof BlockEnderSuppressor != true) { return; } if (world != null) { Random RNG = new Random(); world.spawnParticle(EnumParticleTypes.PORTAL, RNG.nextFloat() + pos.getX(), RNG.nextFloat() + pos.getY(), RNG.nextFloat() + pos.getZ(), 0.1, 0.1, 0.1, 0); } if (powerTicksLeft > 0) { powerTicksLeft--; world.setBlockState(this.getPos(), world.getBlockState(getPos()).withProperty(block.is_powered, false)); } else { if (itemStackHandler.getStackInSlot(0).isEmpty()) { world.setBlockState(this.getPos(), world.getBlockState(getPos()).withProperty(block.is_powered, true)); } else { if (itemStackHandler.getStackInSlot(0).getItem() instanceof ItemEnderPearl) { itemStackHandler.getStackInSlot(0).shrink(1); setFullPowerTicks(); } } } } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setTag("items", itemStackHandler.serializeNBT()); compound.setBoolean("isPublic", isPublic); compound.setInteger("powerTicksLeft", powerTicksLeft); return compound; } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); if (compound.hasKey("items")) { itemStackHandler.deserializeNBT((NBTTagCompound)compound.getTag("items")); } isPublic = compound.getBoolean("isPublic"); powerTicksLeft = compound.getInteger("powerTicksLeft"); } @Override public boolean isPublic() { return isPublic; } @Override public void setFullPowerTicks() { this.powerTicksLeft = maxTicks; } @Override public int getPowerTicksLeft() { return powerTicksLeft; } @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return true; } return super.hasCapability(capability, facing); } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return (T) itemStackHandler; } return super.getCapability(capability, facing); } public boolean canInteractWith(EntityPlayer playerIn) { return !isInvalid() && playerIn.getDistanceSq(pos.add(0.5D, 0.5D, 0.5D)) <= 64D; } public class BlockEnderSuppressor extends Block implements ITileEntityProvider { public static final PropertyBool is_powered = PropertyBool.create("is_powered"); public IMobSuppressorTE TE; protected BlockEnderSuppressor(String unlocalizedName, String registryName) { super(Material.IRON); this.setUnlocalizedName(unlocalizedName); this.setRegistryName(registryName); this.setHardness(2); this.setResistance(6000f); this.setHarvestLevel("pickaxe", 3); this.isBlockContainer = true; this.setDefaultState(this.blockState.getBaseState().withProperty(is_powered, false)); this.setCreativeTab(CreativeTab.mobSuppressorCreativeTab); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, is_powered); } @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(is_powered, meta == 0); } @Override public int getMetaFromState(IBlockState state) { return state.getValue(is_powered) ? 1: 0; } @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { return state.withProperty(is_powered, state.getValue(is_powered)); } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { TE = new TileEntityEnderSuppressor(this); return (TileEntity)TE; } @Override public void breakBlock(World world, BlockPos pos, IBlockState state) { super.breakBlock(world, pos, state); world.removeTileEntity(pos); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (!worldIn.isRemote) { playerIn.openGui(MobSuppressors.instance, ModGUIHandler.enderSuppressorGUIID, worldIn, pos.getX(), pos.getY(), pos.getZ()); } return true; } } If you need any other classes to find the problem just ask.
  15. In my mod I have a TE and on world reload the update method causes a Null Pointer Exception. Here is the error message: [12:21:24] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded. [12:21:25] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:600]: ---- Minecraft Crash Report ---- // Quite honestly, I wouldn't worry myself about that. Time: 6/11/17 12:21 PM Description: Ticking block entity java.lang.NullPointerException: Ticking block entity at com.leo.mobsuppressors.tileentity.TileEntityEnderSuppressor.update(TileEntityEnderSuppressor.java:43) at net.minecraft.world.World.updateEntities(World.java:1950) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:648) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:795) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:699) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:548) at java.lang.Thread.run(Thread.java:748) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace: at com.leo.mobsuppressors.tileentity.TileEntityEnderSuppressor.update(TileEntityEnderSuppressor.java:43) -- Block entity being ticked -- Details: Name: minecraft:endersuppressor_tileentity // com.leo.mobsuppressors.tileentity.TileEntityEnderSuppressor Block type: ID #235 (tile.endersuppressor // com.leo.mobsuppressors.blocks.BlockEnderSuppressor) Block data value: 1 / 0x1 / 0b0001 Block location: World: (113,63,65), Chunk: (at 1,3,1 in 7,4; contains blocks 112,0,64 to 127,255,79), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511) Actual block type: ID #235 (tile.endersuppressor // com.leo.mobsuppressors.blocks.BlockEnderSuppressor) Actual block data value: 1 / 0x1 / 0b0001 Stacktrace: at net.minecraft.world.World.updateEntities(World.java:1950) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:648) -- Affected level -- Details: Level name: New World All players: 0 total; [] Chunk stats: ServerChunkCache: 625 Drop: 0 Level seed: -2733871743652672072 Level generator: ID 00 - default, ver 1. Features enabled: true Level generator options: Level spawn location: World: (8,64,8), Chunk: (at 8,4,8 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511) Level time: 1625 game time, 1625 day time Level dimension: 0 Level storage version: 0x04ABD - Anvil Level weather: Rain time: 82026 (now: false), thunder time: 128357 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true Stacktrace: at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:795) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:699) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:548) at java.lang.Thread.run(Thread.java:748) -- System Details -- Details: Minecraft Version: 1.11.2 Operating System: Mac OS X (x86_64) version 10.12 Java Version: 1.8.0_131, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 611255608 bytes (582 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94 FML: MCP 9.38 Powered by Forge 13.20.0.2294 7 mods loaded, 7 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA minecraft{1.11.2} [Minecraft] (minecraft.jar) UCHIJAAAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.11.2-13.20.0.2294.jar) UCHIJAAAA forge{13.20.0.2294} [Minecraft Forge] (forgeSrc-1.11.2-13.20.0.2294.jar) UCHIJAAAA mobsuppressors{0.1 - alpha} [Mob Suppressors] (bin) UCHIJAAAA jei{4.3.5.275} [Just Enough Items] (jei_1.11.2-4.3.5.275.jar) UCHIJAAAA jeresources{0.6.2.104} [Just Enough Resources] (JustEnoughResources-1.11.2-0.6.2.104.jar) Loaded coremods (and transformers): Profiler Position: N/A (disabled) Player Count: 0 / 8; [] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' [12:21:25] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:600]: #@!@# Game crashed! Crash report saved to: #@!@# ./crash-reports/crash-2017-06-11_12.21.24-server.txt [12:21:25] [Client Shutdown Thread/INFO]: Stopping server [12:21:25] [Client Shutdown Thread/INFO]: Saving players [12:21:25] [Client Shutdown Thread/INFO]: Saving worlds From the error message I guess that the only relevant class is TileEntityEnderSuppressor so that is the only one I will include (unless you need more). public class TileEntityEnderSuppressor extends TileEntity implements ITickable, IMobSuppressorTE { private World world = Minecraft.getMinecraft().world; public BlockEnderSuppressor block; public boolean isPublic; public static final int maxTicks = 300; public int powerTicksLeft = 0; public ItemStackHandler itemStackHandler = new ItemStackHandler(1) { @Override protected void onContentsChanged(int slot) { TileEntityEnderSuppressor.this.markDirty(); } }; public TileEntityEnderSuppressor() {} public TileEntityEnderSuppressor(BlockEnderSuppressor block) { this.block = block; this.isPublic = true; } @Override public void update() { if (world.getBlockState(getPos()).getBlock() instanceof BlockEnderSuppressor != true) { return; } if (world != null) { Random RNG = new Random(); world.spawnParticle(EnumParticleTypes.PORTAL, RNG.nextFloat() + pos.getX(), RNG.nextFloat() + pos.getY(), RNG.nextFloat() + pos.getZ(), 0.1, 0.1, 0.1, 0); } if (powerTicksLeft > 0) { powerTicksLeft--; world.setBlockState(this.getPos(), world.getBlockState(getPos()).withProperty(block.is_powered, false)); } else { if (itemStackHandler.getStackInSlot(0).isEmpty()) { world.setBlockState(this.getPos(), world.getBlockState(getPos()).withProperty(block.is_powered, true)); } else { if (itemStackHandler.getStackInSlot(0).getItem() instanceof ItemEnderPearl) { itemStackHandler.getStackInSlot(0).shrink(1); setFullPowerTicks(); } } } } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setTag("items", itemStackHandler.serializeNBT()); compound.setBoolean("isPublic", isPublic); compound.setInteger("powerTicksLeft", powerTicksLeft); return compound; } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); if (compound.hasKey("items")) { itemStackHandler.deserializeNBT((NBTTagCompound)compound.getTag("items")); } isPublic = compound.getBoolean("isPublic"); powerTicksLeft = compound.getInteger("powerTicksLeft"); } @Override public boolean isPublic() { return isPublic; } @Override public void setFullPowerTicks() { this.powerTicksLeft = maxTicks; } @Override public int getPowerTicksLeft() { return powerTicksLeft; } @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return true; } return super.hasCapability(capability, facing); } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return (T) itemStackHandler; } return super.getCapability(capability, facing); } public boolean canInteractWith(EntityPlayer playerIn) { return !isInvalid() && playerIn.getDistanceSq(pos.add(0.5D, 0.5D, 0.5D)) <= 64D; } } So what happens is if I place the block or mine it or open the GUI nothing happens and its fine. If I exit a world with this block in it, everything is fine. The problem comes when I reload the world; it crashes.
  16. What I want is something like Eye Of Slime that flies to the nearest Slime Chunk or Swamp. Or an Eye Of Skeleton that flies to the nearest Skeleton Dungeon or Skeleton Spawner.
  17. In a mod I am developing I have a block called the Ender Suppressor that will stop all Ender Teleportation within ten blocks of itself (don't worry, it will need an Enter Pearl every half-hour, so it is balanced!). So anyway, I have tried lots of ways to make this work. Here is what I tried: In the TileEntityEnderSuppressor class have an ArrayList<EnderTeleportEvent>and whenever an Ender Teleport event is detected it will add that to the list. In the update function of the TileEntity it will iterate through the events list and check if each one should be cancelled, but it doesn't work. I think the reason could be that the block is trying to cancel the event after it has already happened. So what I want is to do this (psudeo-code): function enderTelrportEvent(EnderTeleportEvent event) { Block[] enderSuppressors = world.getBlocksWithinAABB(BlockEnderSuppressor.class, event.getEntity().getBoundingBox.expand([some amount])); if (length(enderSuppressors) > 0) { event.cancel(); } } Also, if you can think of any other solutions please tell me. P.S. After I have fixed this problem I will properly announce the mod and the other content in it.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.