
gottsch
Members-
Posts
72 -
Joined
-
Last visited
Everything posted by gottsch
-
[1.7.10] Custom Painting Rendering Half Block Off
gottsch replied to gottsch's topic in Modder Support
Yes, I typically do. I just threw this "basic" set of classes together to get it to work, as the actual version in my mod does the same thing. Good question. I don't see the hitbox (black wireframe) even highlight when I hover over the painting. The block's behind the painting will show their hitbox as if the painting wasn't there. -
[1.7.10] Custom Painting Rendering Half Block Off
gottsch replied to gottsch's topic in Modder Support
Thanks, but that line is referring to the dimensions and offset of the image to display on the painting. The enumart is referring to a property of EntityPainting: public static enum EnumArt { Kebab("Kebab", 16, 16, 0, 0), ... So I just used the values to always use the first image. -
Hi. I am having a rendering issue with a custom painting. I simply extended all the painting classes as vanilla as possible, just changing the texture image to use (and of course to point to my classes). However, the image always renders a half block higher than it should. If I make the wall higher, then it will climb, full blocks higher. Has anyone encountered this before? ( I found one thread for an older version, but it didn't really help me). Thanks, gottsch MyItemHangingEntity: MyEntityPainting: MyRenderPainting: (exact coopy of RenderPainting except changing the texture) In MyMod: In ClientProxy: Image: https://dl.dropboxusercontent.com/u/67605173/2014-11-01_20.30.44.png[/img]
-
Ok. Block: public class MyBlock extends BlockContainer { public MyBlock(Material material) { super(material); setHardness(2.0F); setBlockBounds(0.125F, 0.0F, 0.375F, 0.875F, 0.625F, 0.875F); //setBlockBounds(0.0F, 0.0F, 0.0F, 0.5F, 0.5F, 0.5F); } @Override public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) { setBlockBounds(0.125F, 0.0F, 0.375F, 0.875F, 0.625F, 0.875F); return AxisAlignedBB.getBoundingBox(x + 0.125F, y + 0.0F, z + 0.375F, x + 0.875F, y + 0.625F, z + 0.875F); } // tried this //@Override //public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { // setBlockBounds(0.125F, 0.0F, 0.375F, 0.875F, 0.625F, 0.875F); // return AxisAlignedBB.getBoundingBox(x + 0.125F, y + 0.0F, z + 0.375F, x + 0.875F, y + 0.625F, z + 0.875F); //} // tried this //@Override //public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { // setBlockBounds(0.125F, 0.0F, 0.375F, 0.875F, 0.625F, 0.875F); //} @Override public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { return new MyTileEntity(); } @Override public int getRenderType() { return 0; // tried -1 here as well } @Override public boolean renderAsNormalBlock() { return false; } /** * Return false because it is smaller than a regular cube, so we need all sides rendered, else you'll see through other blocks. */ @Override public boolean isOpaqueCube() { return false; } @SideOnly(Side.CLIENT) @Override public void registerBlockIcons(IIconRegister iconRegister) { this.blockIcon = iconRegister.registerIcon(MyMod.modid + ":" + "myblock"); } } TileEntityRenderer: public class MyTileEntityRenderer extends TileEntitySpecialRenderer { private final MyModel model; public MyTileEntityRenderer() { this.model = new MyModel(); } @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float scale) { //The PushMatrix tells the renderer to "start" doing something. GL11.glPushMatrix(); //This is setting the initial location. GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); //This is the texture of your block. It's pathed to be the same place as your other blocks here. //Use in 1.6.2 this ResourceLocation textures = (new ResourceLocation(MyMod.modid +":textures/blocks/myblock.png")); //the ':' is very important //binding the textures Minecraft.getMinecraft().renderEngine.bindTexture(textures); //This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again! GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); //A reference to your Model file. Again, very important. this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); //Tell it to stop rendering for both the PushMatrix's GL11.glPopMatrix(); GL11.glPopMatrix(); } //Set the lighting stuff, so it changes it's brightness properly. private void adjustLightFixture(World world, int i, int j, int k, Block block) { Tessellator tess = Tessellator.instance; //float brightness = block.getBlockBrightness(world, i, j, k); //As of MC 1.7+ block.getBlockBrightness() has become block.getLightValue(): float brightness = block.getLightValue(world, i, j, k); int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); int modulousModifier = skyLight % 65536; int divModifier = skyLight / 65536; tess.setColorOpaque_F(brightness, brightness, brightness); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) modulousModifier, divModifier); } }
-
Hello, I created a custom small model using Techne. Everything works fine - rendering, texture, etc. However, it's bounding box (black wire-frame) takes up the space of a full cube. I was wondering how I can change this to be the size of the actual model. I was assuming it was the blockBounds but this isn't working. Any ideas what else I should be doing? public class MySmallBlock extends BlockContainer { public MySmallBlock(Material material) { super(material); setBlockBounds(0.125F, 0.0F, 0.875F, 0.375F, 0.625F, 0.875F); } ... }
-
[SOLVED] Set Direction of Block (chest) during generate()
gottsch replied to gottsch's topic in Modder Support
Ok, good to know. Thanks to everyone for your replies. -
[SOLVED] Set Direction of Block (chest) during generate()
gottsch replied to gottsch's topic in Modder Support
Thanks, that did the trick. Thanks for catching that. The method comes from WorldGenerator: protected void setBlockAndNotifyAdequately(World p_150516_1_, int p_150516_2_, int p_150516_3_, int p_150516_4_, Block p_150516_5_, int p_150516_6_) { if (this.doBlockNotify) { p_150516_1_.setBlock(p_150516_2_, p_150516_3_, p_150516_4_, p_150516_5_, p_150516_6_, 3); } else { p_150516_1_.setBlock(p_150516_2_, p_150516_3_, p_150516_4_, p_150516_5_, p_150516_6_, 2); } } It seems to place the block and either use flag 3 or 2 depending on the doBlockNotify, which is false by default. So in essence it *should* have done exactly as Eternaldoom suggested, but it didn't seem to be working for me. -
Hi. I have a WorldGenerator that generates a chest, however, I can't seem to set the direction it is pointing. I've tried this to set a random direction: this.setBlockAndNotifyAdequately(world, x, y, z, Blocks.chest, random.nextInt(5) + 2); But the chest is always pointing South. Any ideas? I'm sure it's a pretty simple fix, I'm just missing it.
-
[SOLVED] Custom Chest Loses Items on Minecraft Exit
gottsch replied to gottsch's topic in Modder Support
[sOLVED] I removed all my mods and started from scratch. I got it working but not sure exactly what fixed it - there were several issues I think that caused this, though it was in the my class that extended TileEntityChest. -
[SOLVED] Custom Chest Loses Items on Minecraft Exit
gottsch replied to gottsch's topic in Modder Support
Glad to hear it. Would you mind posting your code? I've updated mine and it still won't work. I even duplicated the entire classes (updating the references) but no go. -
[SOLVED] Custom Chest Loses Items on Minecraft Exit
gottsch replied to gottsch's topic in Modder Support
I had followed a tutorial originally and studied more, testing many different scenarios. It seems to boil down to the createNewTileEntity(..) method in AChest.java. If it creates anything other than TileEntityChest, it doesn't persist the items on exit. Which leads me to think that my ATileEntityChest isn't correct, but I can't figure what. -
Hello, I have created a basic custom BlockChest and corresponding TileEntityChest. I can place the chest in game and add items to it. I can save and exit the current game, reload and the items are still present in the chest. However, if I exit Minecraft entirely, and reload the game, all the items are missing. Note: This only happens when I use the custom ATileEntityChest. If I use the standard TileEntityChest everything works fine. Has anyone encountered this before? I'm using Forge10.12.2.1121 for 1.7.2 AChest.java public class AChest extends BlockChest { private final Random field_149955_b = new Random(); public AChest(int p_i45397_1_) { super(p_i45397_1_); } /** * Called when the block is placed in the world. */ public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) { Block block = p_149689_1_.getBlock(p_149689_2_, p_149689_3_, p_149689_4_ - 1); Block block1 = p_149689_1_.getBlock(p_149689_2_, p_149689_3_, p_149689_4_ + 1); Block block2 = p_149689_1_.getBlock(p_149689_2_ - 1, p_149689_3_, p_149689_4_); Block block3 = p_149689_1_.getBlock(p_149689_2_ + 1, p_149689_3_, p_149689_4_); byte b0 = 0; int l = MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; if (l == 0) { b0 = 2; } if (l == 1) { b0 = 5; } if (l == 2) { b0 = 3; } if (l == 3) { b0 = 4; } if (block != this && block1 != this && block2 != this && block3 != this) { p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, b0, 3); } else { if ((block == this || block1 == this) && (b0 == 4 || b0 == 5)) { if (block == this) { p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_ - 1, b0, 3); } else { p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_ + 1, b0, 3); } p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, b0, 3); } if ((block2 == this || block3 == this) && (b0 == 2 || b0 == 3)) { if (block2 == this) { p_149689_1_.setBlockMetadataWithNotify(p_149689_2_ - 1, p_149689_3_, p_149689_4_, b0, 3); } else { p_149689_1_.setBlockMetadataWithNotify(p_149689_2_ + 1, p_149689_3_, p_149689_4_, b0, 3); } p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, b0, 3); } } if (p_149689_6_.hasDisplayName()) { ((ATileEntityChest)p_149689_1_.getTileEntity(p_149689_2_, p_149689_3_, p_149689_4_)).func_145976_a(p_149689_6_.getDisplayName()); } } /** * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are * their own) Args: x, y, z, neighbor Block */ public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) { super.onNeighborBlockChange(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_5_); ATileEntityChest tileentitychest = (ATileEntityChest)p_149695_1_.getTileEntity(p_149695_2_, p_149695_3_, p_149695_4_); if (tileentitychest != null) { tileentitychest.updateContainingBlockInfo(); } } public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) { ATileEntityChest tileentitychest = (ATileEntityChest)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); if (tileentitychest != null) { for (int i1 = 0; i1 < tileentitychest.getSizeInventory(); ++i1) { ItemStack itemstack = tileentitychest.getStackInSlot(i1); if (itemstack != null) { float f = this.field_149955_b.nextFloat() * 0.8F + 0.1F; float f1 = this.field_149955_b.nextFloat() * 0.8F + 0.1F; EntityItem entityitem; for (float f2 = this.field_149955_b.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; p_149749_1_.spawnEntityInWorld(entityitem)) { int j1 = this.field_149955_b.nextInt(21) + 10; if (j1 > itemstack.stackSize) { j1 = itemstack.stackSize; } itemstack.stackSize -= j1; entityitem = new EntityItem(p_149749_1_, (double)((float)p_149749_2_ + f), (double)((float)p_149749_3_ + f1), (double)((float)p_149749_4_ + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); float f3 = 0.05F; entityitem.motionX = (double)((float)this.field_149955_b.nextGaussian() * f3); entityitem.motionY = (double)((float)this.field_149955_b.nextGaussian() * f3 + 0.2F); entityitem.motionZ = (double)((float)this.field_149955_b.nextGaussian() * f3); if (itemstack.hasTagCompound()) { entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); } } } } p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_); } super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); } public IInventory func_149951_m(World p_149951_1_, int p_149951_2_, int p_149951_3_, int p_149951_4_) { Object object = (ATileEntityChest)p_149951_1_.getTileEntity(p_149951_2_, p_149951_3_, p_149951_4_); if (object == null) { return null; } else if (p_149951_1_.isSideSolid(p_149951_2_, p_149951_3_ + 1, p_149951_4_, DOWN)) { return null; } else if (func_149953_o(p_149951_1_, p_149951_2_, p_149951_3_, p_149951_4_)) { return null; } else if (p_149951_1_.getBlock(p_149951_2_ - 1, p_149951_3_, p_149951_4_) == this && (p_149951_1_.isSideSolid(p_149951_2_ - 1, p_149951_3_ + 1, p_149951_4_, DOWN) || func_149953_o(p_149951_1_, p_149951_2_ - 1, p_149951_3_, p_149951_4_))) { return null; } else if (p_149951_1_.getBlock(p_149951_2_ + 1, p_149951_3_, p_149951_4_) == this && (p_149951_1_.isSideSolid(p_149951_2_ + 1, p_149951_3_ + 1, p_149951_4_, DOWN) || func_149953_o(p_149951_1_, p_149951_2_ + 1, p_149951_3_, p_149951_4_))) { return null; } else if (p_149951_1_.getBlock(p_149951_2_, p_149951_3_, p_149951_4_ - 1) == this && (p_149951_1_.isSideSolid(p_149951_2_, p_149951_3_ + 1, p_149951_4_ - 1, DOWN) || func_149953_o(p_149951_1_, p_149951_2_, p_149951_3_, p_149951_4_ - 1))) { return null; } else if (p_149951_1_.getBlock(p_149951_2_, p_149951_3_, p_149951_4_ + 1) == this && (p_149951_1_.isSideSolid(p_149951_2_, p_149951_3_ + 1, p_149951_4_ + 1, DOWN) || func_149953_o(p_149951_1_, p_149951_2_, p_149951_3_, p_149951_4_ + 1))) { return null; } else { if (p_149951_1_.getBlock(p_149951_2_ - 1, p_149951_3_, p_149951_4_) == this) { object = new InventoryLargeChest("container.chestDouble", (ATileEntityChest)p_149951_1_.getTileEntity(p_149951_2_ - 1, p_149951_3_, p_149951_4_), (IInventory)object); } if (p_149951_1_.getBlock(p_149951_2_ + 1, p_149951_3_, p_149951_4_) == this) { object = new InventoryLargeChest("container.chestDouble", (IInventory)object, (ATileEntityChest)p_149951_1_.getTileEntity(p_149951_2_ + 1, p_149951_3_, p_149951_4_)); } if (p_149951_1_.getBlock(p_149951_2_, p_149951_3_, p_149951_4_ - 1) == this) { object = new InventoryLargeChest("container.chestDouble", (ATileEntityChest)p_149951_1_.getTileEntity(p_149951_2_, p_149951_3_, p_149951_4_ - 1), (IInventory)object); } if (p_149951_1_.getBlock(p_149951_2_, p_149951_3_, p_149951_4_ + 1) == this) { object = new InventoryLargeChest("container.chestDouble", (IInventory)object, (ATileEntityChest)p_149951_1_.getTileEntity(p_149951_2_, p_149951_3_, p_149951_4_ + 1)); } return (IInventory)object; } } private static boolean func_149953_o(World p_149953_0_, int p_149953_1_, int p_149953_2_, int p_149953_3_) { Iterator iterator = p_149953_0_.getEntitiesWithinAABB(EntityOcelot.class, AxisAlignedBB.getAABBPool().getAABB((double)p_149953_1_, (double)(p_149953_2_ + 1), (double)p_149953_3_, (double)(p_149953_1_ + 1), (double)(p_149953_2_ + 2), (double)(p_149953_3_ + 1))).iterator(); EntityOcelot entityocelot1; do { if (!iterator.hasNext()) { return false; } EntityOcelot entityocelot = (EntityOcelot)iterator.next(); entityocelot1 = (EntityOcelot)entityocelot; } while (!entityocelot1.isSitting()); return true; } /** * Returns a new instance of a block's tile entity class. Called on placing the block. */ public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { ATileEntityChest tileentitychest = new ATileEntityChest(); return tileentitychest; } public int isProvidingWeakPower(IBlockAccess p_149709_1_, int p_149709_2_, int p_149709_3_, int p_149709_4_, int p_149709_5_) { if (!this.canProvidePower()) { return 0; } else { int i1 = ((ATileEntityChest)p_149709_1_.getTileEntity(p_149709_2_, p_149709_3_, p_149709_4_)).numPlayersUsing; return MathHelper.clamp_int(i1, 0, 15); } } } ATileEntityChest.java public class ATileEntityChest extends TileEntityChest { private int cachedChestType; private boolean func_145977_a(int p_145977_1_, int p_145977_2_, int p_145977_3_) { Block block = this.worldObj.getBlock(p_145977_1_, p_145977_2_, p_145977_3_); return block instanceof BlockChest && ((BlockChest)block).field_149956_a == this.func_145980_j(); } public void closeInventory() { if (this.getBlockType() instanceof BlockChest) { --this.numPlayersUsing; this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing); this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); } } public int func_145980_j() { if (this.cachedChestType == -1) { if (this.worldObj == null || !(this.getBlockType() instanceof BlockChest)) { return 0; } this.cachedChestType = ((BlockChest)this.getBlockType()).field_149956_a; } return this.cachedChestType; } }