Everything posted by BourgeoisArab
-
[1.7.10] Getting Block Coordinates
If this is a dumb question, I apologize in advance. I may be missing something obvious, but I can't seem to find a simple way to get the coordinates of the block itself within its class (something like xCoord, yCoord and zCoord with tile entities)? I know most methods supply the coordinates, but that isn't what I'm after. Any ideas, or is this impossible?
-
Getting Fluid Source Block
OK. I thought that was the case. Thank you for clarifying anyway.
-
Getting Fluid Source Block
Does anybody know if there is a way of getting the source block (or position of it) from a flowing block? Here's an example of something I mean (this would be in the fluid block class): if (meta>0) { something.getSourceBlock() } From what I know about how liquid spreading works, I doubt that it's possible in a simple way, but I thought I'd check here.
-
[1.7.10] Bubble particles not spawning
I have added a block and want to make bubble particles spawn on top of it, so I added this: @Override @SideOnly(Side.CLIENT) public void randomDisplayTick(World world, int x, int y, int z, Random rand) { world.spawnParticle("bubble", x + (rand.nextFloat() * 0.625 + 0.1875), y + 0.75, z + (rand.nextFloat() * 0.625 + 0.1875), 0.0, 0.1, 0.0); } For some reason, the particle doesn't spawn. I've tried it with other particles, such as smoke, flame or heart, and these do work. Any ideas on what my problem here is?
-
Reading from NBT issue
OK. I'm not sure what I did differently from last time I tested it, but it works now! Thanks a lot, you guys.
-
Reading from NBT issue
I don't think updating the block is an issue, since I added this: @Override public boolean canUpdate() { return true; }
-
Reading from NBT issue
I have added those. Does this mean the methods are wrong?
-
Reading from NBT issue
I am positively flummoxed now. I've marked the tile entity dirty and added this piece of code: @Override public void updateEntity() { System.out.println(this.getFluidAmount() + "mB"); } When I place the cauldron down, it prints out "0mB" continuously, as expected. When I fill it, again it continuously prints "1000mB". However if leave it full and re-log, the console does this (if I leave the cauldron empty, it's normal after re-logging): 0mB 0mB 0mB 1000mB 0mB 1000mB 0mB 1000mB 0mB 1000mB 0mB 1000mB 0mB 1000mB 0mB 1000mB 0mB 1000mB 1000mB 0mB 1000mB 0mB 1000mB 0mB 1000mB 0mB 1000mB 0mB 1000mB 1000mB Does anybody have any explanation as to what is going on here?
-
Reading from NBT issue
I've only been testing this in single-player so far, so this didn't even occur to me. However it still doesn't solve anything.
-
Reading from NBT issue
I've tried to do it the way it is in TileFluidHandler, but still it doesn't work. Does that mean the problem is elsewhere? Like my cauldron block class: package jakoubeck503.alchemicalinstillation.common.block; import jakoubeck503.alchemicalinstillation.AlchemicalInstillation; import jakoubeck503.alchemicalinstillation.common.tileentity.TEBrewingCauldron; import java.util.List; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.IIcon; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockBrewingCauldron extends BlockContainer { @SideOnly(Side.CLIENT) private IIcon iicon; public BlockBrewingCauldron() { super(Material.iron); setCreativeTab(AlchemicalInstillation.tabAlchemicalInstillation); this.setBlockName("blockBrewingCauldron"); this.setBlockTextureName(AlchemicalInstillation.modid + ":" + "brewingCauldron_side"); this.setHardness(1.0F); this.setResistance(2.0F); } public TileEntity createNewTileEntity(World world, int i1) { return new TEBrewingCauldron(); } public TileEntity getTileEntity(World world, int x, int y, int z) { return world.getTileEntity(x, y, z); } public void setBlockBoundsForItemRender() { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } public boolean isOpaqueCube() { return false; } public int getRenderType() { return -1; } public boolean renderAsNormalBlock() { return false; } public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB axis, List list, Entity entity) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.3125F, 1.0F); super.addCollisionBoxesToList(world, x, y, z, axis, list, entity); float f = 0.125F; this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); super.addCollisionBoxesToList(world, x, y, z, axis, list, entity); this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); super.addCollisionBoxesToList(world, x, y, z, axis, list, entity); this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); super.addCollisionBoxesToList(world, x, y, z, axis, list, entity); this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); super.addCollisionBoxesToList(world, x, y, z, axis, list, entity); this.setBlockBoundsForItemRender(); } @Override @SubscribeEvent public boolean onBlockEventReceived(World world, int x, int y, int z, int something, int different) { System.out.println("BLOCK CHANGE!!!"); if (world.getBlock(x, y - 1, z)==Blocks.fire || world.getBlock(x, y - 1, z)==Blocks.lava) { System.out.println("LAVA AND FIRE!!!"); TEBrewingCauldron entity = (TEBrewingCauldron) world.getTileEntity(x, y, z); entity.setBoiling(true); return true; } else return false; } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { TEBrewingCauldron tileEntity = (TEBrewingCauldron) world.getTileEntity(x, y, z); if (tileEntity==null || player.isSneaking()) { return false; } ItemStack heldItem = player.getCurrentEquippedItem(); if (heldItem!=null) { if (heldItem.getItem()==Items.water_bucket) { if (tileEntity.isFillable()) { tileEntity.fill(ForgeDirection.UP, new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME), true); if (!player.capabilities.isCreativeMode) player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.bucket)); } return true; } if (heldItem.getItem()==Items.glass_bottle && tileEntity.getFluidAmount()>=333){ tileEntity.drain(ForgeDirection.UP, 333, true); if (!player.capabilities.isCreativeMode) player.inventory.setInventorySlotContents(player.inventory.currentItem, FluidContainerRegistry.fillFluidContainer( FluidRegistry.getFluidStack(FluidRegistry.WATER.getName(), 333), FluidContainerRegistry.EMPTY_BOTTLE)); return true; } if (heldItem.getItem()==Items.bucket && tileEntity.getFluidAmount()>=FluidContainerRegistry.BUCKET_VOLUME){ tileEntity.drain(ForgeDirection.UP, FluidContainerRegistry.BUCKET_VOLUME, true); if (!player.capabilities.isCreativeMode) player.inventory.setInventorySlotContents(player.inventory.currentItem, FluidContainerRegistry.fillFluidContainer( FluidRegistry.getFluidStack(FluidRegistry.WATER.getName(), FluidContainerRegistry.BUCKET_VOLUME), FluidContainerRegistry.EMPTY_BUCKET)); return true; } } return false; } }
-
Reading from NBT issue
I am trying to make a custom cauldron and working out how to make it store water properly. I have it filling and emptying, but if it's filled, and I log out and then log in, it isn't filled anymore. I think it has something to do with my readFromNBT method, but I'm not sure. Can anyone point out where I went wrong? Here is my Tile Entity class for it: package jakoubeck503.alchemicalinstillation.common.tileentity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidEvent; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidTank; public class TEBrewingCauldron extends TileEntity implements IFluidTank, IFluidHandler { private FluidTank tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME); private boolean boiling = false; public TEBrewingCauldron() { System.out.println("Creating a new tile entity..."); } public void setBoiling(boolean par1) { this.boiling = par1; System.out.println("Cauldron " + (this.boiling==true ? "is" : "isn't") + " boiling!"); } public boolean getBoiling() { return this.boiling; } public boolean isFillable() { if (tank.getFluid()!=null) { if (tank.getFluid().getFluid()==FluidRegistry.WATER && tank.getFluidAmount()<FluidContainerRegistry.BUCKET_VOLUME){ return true; } else return false; } else return true; } @Override public void readFromNBT(NBTTagCompound nbt) { System.out.println("Reading from NBT..."); super.readFromNBT(nbt); if (!nbt.hasKey("Empty")) { FluidStack fluid = this.tank.getFluid().loadFluidStackFromNBT(nbt); System.out.println(fluid.amount + "mB of " + fluid.getFluid()); if (fluid!=null) { this.tank.setFluid(fluid); } } if (tank.getFluid().getFluid()!=FluidRegistry.WATER){ System.out.println("ERROR! Not equal to water..."); } } @Override public void writeToNBT(NBTTagCompound nbt) { System.out.println("Writing to NBT..."); super.writeToNBT(nbt); if (tank.getFluid()!=null) { tank.getFluid().writeToNBT(nbt); } else { nbt.setString("Empty", ""); } } @Override public FluidStack getFluid() { return tank.getFluid(); } @Override public int getFluidAmount() { if (tank.getFluid()==null) { return 0; } else return tank.getFluidAmount(); } @Override public int getCapacity() { return tank.getCapacity(); } @Override public FluidTankInfo getInfo() { return tank.getInfo(); } @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { // TODO Auto-generated method stub return tank.fill(resource, doFill); } @Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { // TODO Auto-generated method stub return null; } @Override public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { // TODO Auto-generated method stub return null; } @Override public boolean canFill(ForgeDirection from, Fluid fluid) { // TODO Auto-generated method stub return false; } @Override public boolean canDrain(ForgeDirection from, Fluid fluid) { // TODO Auto-generated method stub return false; } @Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { // TODO Auto-generated method stub return null; } private void setFluid(FluidStack f) { this.tank.setFluid(f); } @Override public int fill(FluidStack resource, boolean doFill) { return tank.fill(resource, doFill); } @Override public FluidStack drain(int maxDrain, boolean doDrain) { return tank.drain(maxDrain, doDrain); } }
-
Animated Texture with a 3D model
Alright, I've somehow managed to slap it together in a way that works from the RenderBlocks class. I'm happy with it for now; thank you so much, guys!
-
Animated Texture with a 3D model
Sorry for being unclear. I meant how do I use those coordinates to tell the render engine what part of the atlas to use? Sorry if these are stupid questions; I only started modding 2 weeks ago.
-
Animated Texture with a 3D model
How do I use the water IIcon to get the UV coordinates?
-
Animated Texture with a 3D model
I am trying to create my own cauldron block, of sorts, which you can fill and empty with water buckets. I'd like the water level to render with its texture animated, like normal water blocks in the game. I was hoping to do it with the mcmeta files, like with normal blocks but that doesn't work. In-game it just looks like this (it makes me feel nauseous, just looking at it): https://www.dropbox.com/s/57tmveohzfw2jvr/2014-09-21_20.13.25.png?dl=0 I am quite new to modding, so if there is a whole better way of doing this, please tell me. I'd be grateful for any advice. Cauldron model class: Cauldron renderer class:
IPS spam blocked by CleanTalk.