Jump to content

Ceiling Gecko

Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by Ceiling Gecko

  1. Solved it by manipulating the block metadata when condition is met and then checking for block metadata changes in the randomDisplayTick, seems similar to how vanilla redstone wire handles their particles. Full code of block and tile entity for reference in case others want to do something like this: public class SoftGlassBlock extends Block implements ITileEntityProvider { public SoftGlassBlock(Material material){ super(material); setTickRandomly(true); setBlockName("softGlassBlock"); setBlockTextureName(QuenchProperties.MODID + ":" + getUnlocalizedName().substring(5)); setCreativeTab(CreativeTabs.tabBlock); setLightLevel(0.3F); setLightOpacity(3); } @SideOnly(Side.CLIENT) public int getRenderBlockPass(){ return 1; } @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { Block block = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_); return block == this ? false : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); } public boolean isOpaqueCube(){ return false; } public void updateTick(World world, int x, int y, int z, Random rand) { if (world.provider.isHellWorld) { return; } else { if (world.getSavedLightValue(EnumSkyBlock.Block, x, y, z) > 10 - this.getLightOpacity()) { return; } else { SoftGlassEntity entity = (SoftGlassEntity) world.getTileEntity(x, y, z); int currentTemperature = entity.getGlassTemperature(); if(currentTemperature > 0){ currentTemperature--; entity.setGlassTemperature(currentTemperature); world.markBlockForUpdate(x, y, z); world.playSoundEffect((double)x + 0.5D, (double)y + 0.5D, (double)z + 0.5D, "random.fizz", 1.0F, world.rand.nextFloat() * 0.1F + 0.9F); } else { world.setBlock(x, y, z, Blocks.glass); world.removeTileEntity(x, y, z); } } } } @SideOnly(Side.CLIENT) public void randomDisplayTick(World world, int x, int y, int z, Random rand) { int meta = world.getBlockMetadata(x, y, z); if(meta > 0){ world.spawnParticle("largesmoke", (double)x + 0.5D, (double)y + 1.2D, (double)z + 0.5D, 0.0D, 0.1D, 0.0D); world.setBlockMetadataWithNotify(x, y, z, 0, 2); } } @Override public TileEntity createNewTileEntity(World world, int p_149915_2_) { return new SoftGlassEntity(); } } public class SoftGlassEntity extends TileEntity { private int glassTemperature; public SoftGlassEntity(){ this.glassTemperature = 3; } public void setGlassTemperature(int temperature){ worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 2); this.glassTemperature = temperature; } public int getGlassTemperature(){ return this.glassTemperature; } public void writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); tag.setInteger("GlassTemperature", this.glassTemperature); } public void readFromNBT(NBTTagCompound tag) { super.readFromNBT(tag); this.glassTemperature = tag.getInteger("GlassTemperature"); } }
  2. So I have a block with setTickRandomly enabled, in the updateTick override I perform various actions on the associated tile entity and am attempting to trigger a particle effect on some occasions, however when calling the spawnParticle method from within the updateTick method, the particle does not appear to render in-game. I can trigger the particle via randomDisplayTick method but that just renders the particle continuously. Is there some way to trigger the particle from updateTick, or do I have to check for changes to the tile entity data within randomDisplayTick (seems expensive)? Here's how my updateTick method looks: public void updateTick(World world, int x, int y, int z, Random rand) { if (world.provider.isHellWorld) { return; } else { if (world.getSavedLightValue(EnumSkyBlock.Block, x, y, z) > 10 - this.getLightOpacity()) { return; } else { SoftGlassEntity entity = (SoftGlassEntity) world.getTileEntity(x, y, z); int currentTemperature = entity.getGlassTemperature(); if(currentTemperature > 0){ currentTemperature--; entity.setGlassTemperature(currentTemperature); world.markBlockForUpdate(x, y, z); world.playSoundEffect((double)x + 0.5D, (double)y + 0.5D, (double)z + 0.5D, "random.fizz", 1.0F, world.rand.nextFloat() * 0.1F + 0.9F); world.spawnParticle("largesmoke", (double)x + 0.5D, (double)y + 1.2D, (double)z + 0.5D, 0.0D, 0.1D, 0.0D); } else { world.setBlock(x, y, z, Blocks.glass); world.removeTileEntity(x, y, z); } } } } The fizz sound effect is playing just fine but the smoke particle doesn't seem to be rendering.
  3. Assuming I want my mod talking to other mod APIs for additional recipes/power/options etc., is there a sure way to make sure my mod loads after those mods? From the wiki I saw that you can specify dependencies via: "required-after:ParentMod;required-after:ParentMod2;required-before:ChildMod" But since they are specified as dependencies I assume if they are not present, my mod will simply not load up. From what I've read I think I can just append a couple of leading "z"s to the mod id and hope that none of the mods which APIs my mod talks to has appended more "z"s but that seems unreliable and a somewhat hackish way to do it, which I would like to avoid if possible.
  4. So basically as the title says, is there a way to retrieve the responsible player who caused the call to onBlockDestroyedByPlayer? I was thinking of using the world object among the parameters to find the closest player to that block but that might not always be the case. (e.g. another player standing closer to the block than the one destroying it)
  5. Is there a way to tell NEI or similar mods to ignore and not list certain blocks? I would not want to clutter up the list with individually-useless things like ghost/gag blocks and the like. I assume for regular creative I can just not specify which creative tab the block resides in but I assume mods like NEI use other means? Or am I completely wrong and NEI also only references creative tab blocks/items?
  6. Thanks, I figured I'd have to do something like that, one small thing to clarify: Block bounds going downwards: I'm assuming that means setting the origin Y coordinate block bound as a negative number, meaning it'll go downwards in respect to the block placed, is that correct?
  7. Hi guys, started modding just a couple of days ago and was wondering if I can somehow target the blocks with models that are outside the 1 block scale but are bound to 1 block. Sounds confusing but allow me to elaborate with a couple of images. As long as I'm targeting the bottom of the model where the block actually is placed I can interact with it as normal and the outline box (I assume representing the block bounds) is shown: However if I move my cursor upwards and it leaves the bottom block boundaries while still technically targeting the model within it's bounds it no longer acknowledges that it's targeted: I'm assuming this limitation is because in it's core it is just a single block, but I was wondering if I can somehow circumvent it in a reasonably elegant way? Or do I have to perform some ghost block sorcery?
×
×
  • Create New...

Important Information

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