-
Posts
867 -
Joined
-
Last visited
-
Days Won
3
Everything posted by JimiIT92
-
No, but i thought you meant that. I've tried doing this BiomeManager.addVillageBiome(BiomeGenBase.hell, true); wich works with all other biomes in the overworld but it doesn't in the nether So how can i make it work?
-
So i need to rewrite the entire village generation?
-
Is there any chanche to get a village spawn in the nether? Because it seems that the Netherrack or all other nether-related blocks are not listed as terrain, so adding the Nether as a village biome is useless (the village will never spawn). So, there is any chanche to change this? To tell the game "also check if the terrain is netherrack or else" so the village can spawn there? I don't want to rewrite all the village generation system if is not necessary, so i'm asking for your help
-
[SOLVED] [1.8] Custom Painting sometime is placing wrong
JimiIT92 replied to JimiIT92's topic in Modder Support
Oh, i always supposed that the starting block was the bottom corner of the painting (not the center). Thanks for your explanation -
[SOLVED] [1.8] Custom Painting sometime is placing wrong
JimiIT92 replied to JimiIT92's topic in Modder Support
I tried printing out what it reads and what it writes and they are the same value, so it should not be any problem (while instead there is ) -
As by title, i have a cutom painting but sometimes when i place it on a wall it has an incorrect position. This only occurs with big paintings, for 1x1 or 2x2 painitngs everything works fine. Here is my entity painting class package blaze.entities; import java.util.ArrayList; import com.google.common.collect.Lists; import blaze.core.BLItems; import io.netty.buffer.ByteBuf; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityHanging; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class EntityPaintingEB extends EntityHanging implements IEntityAdditionalSpawnData { public EntityPaintingEB.EnumArt art; public EntityPaintingEB(World worldIn) { super(worldIn); } public EntityPaintingEB(World worldIn, BlockPos pos, EnumFacing side) { super(worldIn, pos); ArrayList arraylist = Lists.newArrayList(); EntityPaintingEB.EnumArt[] aenumart = EntityPaintingEB.EnumArt.values(); int i = aenumart.length; for (int j = 0; j < i; ++j) { EntityPaintingEB.EnumArt enumart = aenumart[j]; this.art = enumart; this.func_174859_a(side); if (this.onValidSurface()) { arraylist.add(enumart); } } if (!arraylist.isEmpty()) { this.art = (EntityPaintingEB.EnumArt)arraylist.get(this.rand.nextInt(arraylist.size())); } this.func_174859_a(side); } @SideOnly(Side.CLIENT) public EntityPaintingEB(World worldIn, BlockPos pos, EnumFacing side, String name) { this(worldIn, pos, side); EntityPaintingEB.EnumArt[] aenumart = EntityPaintingEB.EnumArt.values(); int i = aenumart.length; for (int j = 0; j < i; ++j) { EntityPaintingEB.EnumArt enumart = aenumart[j]; if (enumart.title.equals(name)) { this.art = enumart; break; } } this.func_174859_a(side); } /** * (abstract) Protected helper method to write subclass entity data to NBT. */ public void writeEntityToNBT(NBTTagCompound tagCompound) { tagCompound.setString("Motive", this.art.title); super.writeEntityToNBT(tagCompound); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound tagCompund) { String s = tagCompund.getString("Motive"); EntityPaintingEB.EnumArt[] aenumart = EntityPaintingEB.EnumArt.values(); int i = aenumart.length; for (int j = 0; j < i; ++j) { EntityPaintingEB.EnumArt enumart = aenumart[j]; if (enumart.title.equals(s)) { this.art = enumart; } } if (this.art == null) { this.art = EntityPaintingEB.EnumArt.KEBAB; } super.readEntityFromNBT(tagCompund); } public int getWidthPixels() { return this.art.sizeX; } public int getHeightPixels() { return this.art.sizeY; } /** * Called when this entity is broken. Entity parameter may be null. */ public void onBroken(Entity entity) { if (this.worldObj.getGameRules().getGameRuleBooleanValue("doTileDrops")) { if (entity instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer)entity; if (entityplayer.capabilities.isCreativeMode) { return; } } this.entityDropItem(new ItemStack(BLItems.painting_eb), 0.0F); } } /** * Sets the location and Yaw/Pitch of an entity in the world */ public void setLocationAndAngles(double x, double y, double z, float yaw, float pitch) { BlockPos blockpos = new BlockPos(x - this.posX, y - this.posY, z - this.posZ); BlockPos blockpos1 = this.hangingPosition.add(blockpos); this.setPosition((double)blockpos1.getX(), (double)blockpos1.getY(), (double)blockpos1.getZ()); } @SideOnly(Side.CLIENT) public void func_180426_a(double par1, double par2, double par3, float par4, float par5, int par6, boolean par7) { BlockPos blockpos = new BlockPos(par1 - this.posX, par2 - this.posY, par3 - this.posZ); BlockPos blockpos1 = this.hangingPosition.add(blockpos); this.setPosition((double)blockpos1.getX(), (double)blockpos1.getY(), (double)blockpos1.getZ()); } public static enum EnumArt { KEBAB("Kebab", 16, 16, 0, 0), AZTEC("Aztec", 16, 16, 16, 0), ALBAN("Alban", 16, 16, 32, 0), AZTEC_2("Aztec2", 16, 16, 48, 0), BOMB("Bomb", 16, 16, 64, 0), PLANT("Plant", 16, 16, 80, 0), WASTELAND("Wasteland", 16, 16, 96, 0), POOL("Pool", 32, 16, 0, 32), COURBET("Courbet", 32, 16, 32, 32), SEA("Sea", 32, 16, 64, 32), SUNSET("Sunset", 32, 16, 96, 32), CREEBET("Creebet", 32, 16, 128, 32), WANDERER("Wanderer", 16, 32, 0, 64), GRAHAM("Graham", 16, 32, 16, 64), MATCH("Match", 32, 32, 0, 128), BUST("Bust", 32, 32, 32, 128), STAGE("Stage", 32, 32, 64, 128), VOID("Void", 32, 32, 96, 128), SKULL_AND_ROSES("SkullAndRoses", 32, 32, 128, 128), WITHER("Wither", 32, 32, 160, 128), FIGHTERS("Fighters", 64, 32, 0, 96), POINTER("Pointer", 64, 64, 0, 192), PIGSCENE("Pigscene", 64, 64, 64, 192), BURNING_SKULL("BurningSkull", 64, 64, 128, 192), SKELETON("Skeleton", 64, 48, 192, 64), DONKEY_KONG("DonkeyKong", 64, 48, 192, 112), EB("EB", 32, 32, 96, 80), SUBSCRIBE("Subscribe", 64, 16, 96, 64); public static final int field_180001_A = "SkullAndRoses".length(); /** Painting Title. */ public final String title; public final int sizeX; public final int sizeY; public final int offsetX; public final int offsetY; private EnumArt(String name, int par1, int par2, int par3, int par4) { this.title = name; this.sizeX = par1; this.sizeY = par2; this.offsetX = par3; this.offsetY = par4; } } @Override public void writeSpawnData(ByteBuf buffer) { buffer.writeInt(this.art.ordinal()); buffer.writeInt(this.hangingPosition.getX()); buffer.writeInt(this.hangingPosition.getY()); buffer.writeInt(this.hangingPosition.getZ()); buffer.writeByte(this.getHorizontalFacing().getIndex()); } @Override public void readSpawnData(ByteBuf buffer) { EntityPaintingEB.EnumArt[] aenumart = EntityPaintingEB.EnumArt.values(); this.art = aenumart[buffer.readInt()]; int x = buffer.readInt(); int y = buffer.readInt(); int z = buffer.readInt(); BlockPos pos = new BlockPos(x, y, z); this.hangingPosition = pos; this.func_174859_a(EnumFacing.getFront((buffer.readByte()))); } } This is my item custom painting (from wich i place the entity in the world) package blaze.items; import blaze.entities.EntityPaintingEB; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityHanging; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; public class ItemCustomPainting extends Item { private final Class hangingEntityClass; public ItemCustomPainting(Class entityClass) { super(); this.hangingEntityClass = entityClass; this.setCreativeTab(CreativeTabs.tabDecorations); } /** * Called when a Block is right-clicked with this Item * * @param pos The block being right-clicked * @param side The side being right-clicked */ public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { if (side == EnumFacing.DOWN) { return false; } else if (side == EnumFacing.UP) { return false; } else { BlockPos blockpos1 = pos.offset(side); if (!playerIn.canPlayerEdit(blockpos1, side, stack)) { return false; } else { EntityHanging entityhanging = this.createHangingEntity(worldIn, blockpos1, side); if (entityhanging != null && entityhanging.onValidSurface()) { if (!worldIn.isRemote) { worldIn.spawnEntityInWorld(entityhanging); } --stack.stackSize; } return true; } } } private EntityHanging createHangingEntity(World worldIn, BlockPos pos, EnumFacing clickedSide) { return new EntityPaintingEB(worldIn, pos, clickedSide); } } And this is the rendering class package blaze.entities.renderer; import blaze.core.BL; import blaze.entities.EntityPaintingEB; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.Entity; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderPaintingEB extends Render { private static final ResourceLocation paintings = new ResourceLocation(BL.MODID + ":" + "textures/painting/paintings.png"); public RenderPaintingEB(RenderManager mgr) { super(mgr); } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render<T extends Entity>) and this method has signature public void func_76986_a(T entity, double d, double d1, * double d2, float f, float f1). But JAD is pre 1.5 so doe */ public void doRender(EntityPaintingEB entity, double x, double y, double z, float par5, float partialTicks) { GlStateManager.pushMatrix(); GlStateManager.translate(x, y, z); GlStateManager.rotate(180.0F - par5, 0.0F, 1.0F, 0.0F); GlStateManager.enableRescaleNormal(); this.bindEntityTexture(entity); EntityPaintingEB.EnumArt enumart = entity.art; float f2 = 0.0625F; GlStateManager.scale(f2, f2, f2); this.func_77010_a(entity, enumart.sizeX, enumart.sizeY, enumart.offsetX, enumart.offsetY); GlStateManager.disableRescaleNormal(); GlStateManager.popMatrix(); super.doRender(entity, x, y, z, par5, partialTicks); } protected ResourceLocation func_180562_a(EntityPaintingEB entity) { return paintings; } private void func_77010_a(EntityPaintingEB entity, int par2, int par3, int par4, int par5) { float f = (float)(-par2) / 2.0F; float f1 = (float)(-par3) / 2.0F; float f2 = 0.5F; float f3 = 0.75F; float f4 = 0.8125F; float f5 = 0.0F; float f6 = 0.0625F; float f7 = 0.75F; float f8 = 0.8125F; float f9 = 0.001953125F; float f10 = 0.001953125F; float f11 = 0.7519531F; float f12 = 0.7519531F; float f13 = 0.0F; float f14 = 0.0625F; for (int i1 = 0; i1 < par2 / 16; ++i1) { for (int j1 = 0; j1 < par3 / 16; ++j1) { float f15 = f + (float)((i1 + 1) * 16); float f16 = f + (float)(i1 * 16); float f17 = f1 + (float)((j1 + 1) * 16); float f18 = f1 + (float)(j1 * 16); this.func_77008_a(entity, (f15 + f16) / 2.0F, (f17 + f18) / 2.0F); float f19 = (float)(par4 + par2 - i1 * 16) / 256.0F; float f20 = (float)(par4 + par2 - (i1 + 1) * 16) / 256.0F; float f21 = (float)(par5 + par3 - j1 * 16) / 256.0F; float f22 = (float)(par5 + par3 - (j1 + 1) * 16) / 256.0F; Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); worldrenderer.startDrawingQuads(); worldrenderer.setNormal(0.0F, 0.0F, -1.0F); worldrenderer.addVertexWithUV((double)f15, (double)f18, (double)(-f2), (double)f20, (double)f21); worldrenderer.addVertexWithUV((double)f16, (double)f18, (double)(-f2), (double)f19, (double)f21); worldrenderer.addVertexWithUV((double)f16, (double)f17, (double)(-f2), (double)f19, (double)f22); worldrenderer.addVertexWithUV((double)f15, (double)f17, (double)(-f2), (double)f20, (double)f22); if(!entity.art.title.equals("EB")) { worldrenderer.setNormal(0.0F, 0.0F, 1.0F); worldrenderer.addVertexWithUV((double)f15, (double)f17, (double)f2, (double)f3, (double)f5); worldrenderer.addVertexWithUV((double)f16, (double)f17, (double)f2, (double)f4, (double)f5); worldrenderer.addVertexWithUV((double)f16, (double)f18, (double)f2, (double)f4, (double)f6); worldrenderer.addVertexWithUV((double)f15, (double)f18, (double)f2, (double)f3, (double)f6); worldrenderer.setNormal(0.0F, 1.0F, 0.0F); worldrenderer.addVertexWithUV((double)f15, (double)f17, (double)(-f2), (double)f7, (double)f9); worldrenderer.addVertexWithUV((double)f16, (double)f17, (double)(-f2), (double)f8, (double)f9); worldrenderer.addVertexWithUV((double)f16, (double)f17, (double)f2, (double)f8, (double)f10); worldrenderer.addVertexWithUV((double)f15, (double)f17, (double)f2, (double)f7, (double)f10); worldrenderer.setNormal(0.0F, -1.0F, 0.0F); worldrenderer.addVertexWithUV((double)f15, (double)f18, (double)f2, (double)f7, (double)f9); worldrenderer.addVertexWithUV((double)f16, (double)f18, (double)f2, (double)f8, (double)f9); worldrenderer.addVertexWithUV((double)f16, (double)f18, (double)(-f2), (double)f8, (double)f10); worldrenderer.addVertexWithUV((double)f15, (double)f18, (double)(-f2), (double)f7, (double)f10); worldrenderer.setNormal(-1.0F, 0.0F, 0.0F); worldrenderer.addVertexWithUV((double)f15, (double)f17, (double)f2, (double)f12, (double)f13); worldrenderer.addVertexWithUV((double)f15, (double)f18, (double)f2, (double)f12, (double)f14); worldrenderer.addVertexWithUV((double)f15, (double)f18, (double)(-f2), (double)f11, (double)f14); worldrenderer.addVertexWithUV((double)f15, (double)f17, (double)(-f2), (double)f11, (double)f13); worldrenderer.setNormal(1.0F, 0.0F, 0.0F); worldrenderer.addVertexWithUV((double)f16, (double)f17, (double)(-f2), (double)f12, (double)f13); worldrenderer.addVertexWithUV((double)f16, (double)f18, (double)(-f2), (double)f12, (double)f14); worldrenderer.addVertexWithUV((double)f16, (double)f18, (double)f2, (double)f11, (double)f14); worldrenderer.addVertexWithUV((double)f16, (double)f17, (double)f2, (double)f11, (double)f13); } tessellator.draw(); } } } private void func_77008_a(EntityPaintingEB entity, float par2, float par3) { int i = MathHelper.floor_double(entity.posX); int j = MathHelper.floor_double(entity.posY + (double)(par3 / 16.0F)); int k = MathHelper.floor_double(entity.posZ); EnumFacing enumfacing = entity.field_174860_b; if (enumfacing == EnumFacing.NORTH) { i = MathHelper.floor_double(entity.posX + (double)(par2 / 16.0F)); } if (enumfacing == EnumFacing.WEST) { k = MathHelper.floor_double(entity.posZ - (double)(par2 / 16.0F)); } if (enumfacing == EnumFacing.SOUTH) { i = MathHelper.floor_double(entity.posX - (double)(par2 / 16.0F)); } if (enumfacing == EnumFacing.EAST) { k = MathHelper.floor_double(entity.posZ + (double)(par2 / 16.0F)); } int l = this.renderManager.worldObj.getCombinedLight(new BlockPos(i, j, k), 0); int i1 = l % 65536; int j1 = l / 65536; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)i1, (float)j1); GlStateManager.color(1.0F, 1.0F, 1.0F); } /** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(Entity entity) { return this.func_180562_a((EntityPaintingEB)entity); } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render<T extends Entity>) and this method has signature public void func_76986_a(T entity, double d, double d1, * double d2, float f, float f1). But JAD is pre 1.5 so doe */ public void doRender(Entity entity, double x, double y, double z, float par5, float partialTicks) { this.doRender((EntityPaintingEB)entity, x, y, z, par5, partialTicks); } } I've also made a video to better explain what is my problem https://www.youtube.com/watch?v=piQWeUJI_uw&feature=youtu.be
-
Alright, it turns out that it was a registration error. I've now registered my entity with this values EntityRegistry.registerModEntity(EntityAtomicTNTPrimed.class, "atomicTNT", starting_id+3, BL.instance, 160, 10, true); and it worked
-
I'm making a custom tnt but if i set it on fire when there is a block above it it has a strange animation. Here is a video to show you what i mean https://www.youtube.com/watch?v=8fNatm6ebPg And here is my entity class package blaze.entities; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityTNTPrimed; import net.minecraft.util.EnumParticleTypes; import net.minecraft.world.World; public class EntityAtomicTNTPrimed extends EntityTNTPrimed { /** How long the fuse is */ public int fuse; private EntityLivingBase tntPlacedBy; public EntityAtomicTNTPrimed(World par1World) { super(par1World); this.fuse = 80; } public EntityAtomicTNTPrimed(World par1World, double par2, double par4, double par6, EntityLivingBase par8EntityLivingBase) { this(par1World); this.setPosition(par2, par4, par6); float f = (float)(Math.random() * Math.PI * 2.0D); this.motionX = (double)(-((float)Math.sin((double)f)) * 0.02F); this.motionY = 0.20000000298023224D; this.motionZ = (double)(-((float)Math.cos((double)f)) * 0.02F); this.fuse = 80; this.prevPosX = par2; this.prevPosY = par4; this.prevPosZ = par6; this.tntPlacedBy = par8EntityLivingBase; } /** * Called to update the entity's position/logic. */ public void onUpdate() { this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; this.motionY -= 0.03999999910593033D; this.moveEntity(this.motionX, this.motionY, this.motionZ); this.motionX *= 0.9800000190734863D; this.motionY *= 0.9800000190734863D; this.motionZ *= 0.9800000190734863D; if (this.onGround) { this.motionX *= 0.699999988079071D; this.motionZ *= 0.699999988079071D; this.motionY *= -0.5D; } if (this.fuse-- <= 0) { this.setDead(); if (!this.worldObj.isRemote) { this.explode(); } } else { this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); } } private void explode() { float f = 36.0F; this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, f, true); } } Any idea about why this happens?
-
Woops Ok, changed to this /** * Get the actual Block state of this Block at the given position. This applies properties not visible in the * metadata, such as fence connections. */ @Override @SideOnly(Side.CLIENT) public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { RenderGlobal render = Minecraft.getMinecraft().renderGlobal; DestroyBlockProgress progress; if(damage != null) { Map mp; try { mp = (Map)damage.get(render); Iterator it = mp.entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry)it.next(); progress = (DestroyBlockProgress) pair.getValue(); if(progress.getPosition().equals(pos)) { return state.withProperty(DAMAGE, Integer.valueOf(progress.getPartialBlockDamage())); } } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } return state; }
-
Ok, quick discover. If i comment everything in my getActualState method and only do this state.withProperty(DAMAGE, Integer.valueOf(3)); it return the block model for the damage value of 3, wich is correct. So i think that the problem could be in this method @Override @SideOnly(Side.CLIENT) public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { IBlockState newState = null; RenderGlobal render = Minecraft.getMinecraft().renderGlobal; DestroyBlockProgress progress; if(damage != null) { Map mp; try { mp = (Map)damage.get(render); Iterator it = mp.entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry)it.next(); progress = (DestroyBlockProgress) pair.getValue(); if(progress.getPosition().equals(pos)) { newState = state.withProperty(DAMAGE, Integer.valueOf(progress.getPartialBlockDamage())); } } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } return newState; }
-
Don't worry man, at least you tried to solve this problem Thanks for all your support Hope to find out a way to make this work
-
Alright, so now my block is registered as a normal block, and as i said in the previous edit i print the damage value when breaking the block but is always 10, event if i force it to 0
-
Ok, so i've now this block.setUnlocalizedName(name); GameRegistry.registerBlock(block, name); ModelBakery.addVariantName(Item.getItemFromBlock(coal_block), BL.MODID + ":" + "coal_block_0", BL.MODID + ":" + "coal_block_1", BL.MODID + ":" + "coal_block_2", BL.MODID + ":" + "coal_block_3", BL.MODID + ":" + "coal_block_4", BL.MODID + ":" + "coal_block_5", BL.MODID + ":" + "coal_block_6", BL.MODID + ":" + "coal_block_7", BL.MODID + ":" + "coal_block_8", BL.MODID + ":" + "coal_block_9", BL.MODID + ":" + "coal_block_10"); for(int i = 0; i < 11; i++) renderItem.getItemModelMesher().register(Item.getItemFromBlock(block), i, new ModelResourceLocation(BL.MODID + ":" + name + "_" + i, "inventory")); The model file are pretty the same as before (only the block high on each value is changed) So now if i place a block down it place the last block model registered (the corresponding to the damage value of 10) EDIT: printing this in the getActualState always return 10 System.out.println(state.getValue(DAMAGE)); so basically the damage value is never change, even doing this newState = state.withProperty(DAMAGE, Integer.valueOf(progress.getPartialBlockDamage()));
-
I know that the registration could be the problem, but since there is actually no metadata value saved how can i register it properly? Like a normal metadata block (so using a normal ItemBlock class and registering every variant with a different name?)
-
If i return this newState = state.withProperty(DAMAGE, Integer.valueOf(0)); it's still returning me the model that should be corresponding the the damage 5 or higher, so i think could be this the problem. This is how i register the block block.setUnlocalizedName(name); GameRegistry.registerBlock(block, ItemCoalBlock.class, name); ModelBakery.addVariantName(Item.getItemFromBlock(coal_block), BL.MODID + ":" + "coal_block", BL.MODID + ":" + "coal_block", BL.MODID + ":" + "coal_block", BL.MODID + ":" + "coal_block", BL.MODID + ":" + "coal_block", BL.MODID + ":" + "coal_block", BL.MODID + ":" + "coal_block", BL.MODID + ":" + "coal_block", BL.MODID + ":" + "coal_block", BL.MODID + ":" + "coal_block", BL.MODID + ":" + "coal_block"); for(int i = 0; i < 11; i++) renderItem.getItemModelMesher().register(Item.getItemFromBlock(block), i, new ModelResourceLocation(BL.MODID + ":" + name, "inventory")); block is the coal_block instance name is the unlocalized name renderItem is the RenderItem instance and this is the blockstate file { "variants": { "damage=0": { "model": "blaze:coal_block" }, "damage=1": { "model": "blaze:coal_block" }, "damage=2": { "model": "blaze:coal_block" }, "damage=3": { "model": "blaze:coal_block" }, "damage=4": { "model": "blaze:coal_block" }, "damage=5": { "model": "blaze:coal_block_5" }, "damage=6": { "model": "blaze:coal_block_5" }, "damage=7": { "model": "blaze:coal_block_5" }, "damage=8": { "model": "blaze:coal_block_5" }, "damage=9": { "model": "blaze:coal_block_5" }, "damage=10": { "model": "blaze:coal_block_5" } } } And this is the block model file for damage 0-4 { "parent": "block/cube_all", "textures": { "all": "blocks/coal_block" } } and for damage 5-10 { "textures": { "all": "blocks/coal_block", "particle": "blocks/coal_block" }, "elements": [ { "from": [ 0, 0, 0 ], "to": [ 16, 5, 16 ], "faces": { "down": { "texture": "#all", "cullface": "down" }, "up": { "texture": "#all", "cullface": "up" }, "north": { "texture": "#all", "cullface": "north" }, "south": { "texture": "#all", "cullface": "south" }, "west": { "texture": "#all", "cullface": "west" }, "east": { "texture": "#all", "cullface": "east" } } } ] }
-
It goes from 0 to 8 while breaking the block, reaching the 8 when is nearly broken. I've printed this progress.getPartialBlockDamage()
-
Removed, updated previous code
-
[1.8] how would you render an model on a player?
JimiIT92 replied to frenchtoaster10's topic in Modder Support
Vanity items could be intended like armors (but with 0 protection), so why not considering them like that and change their rendering to a custom model? -
forgot to change that, it was static beacause before was used in the static block. So i need to return this right? state.withProperty(DAMAGE, Integer.valueOf(this.d_progress)); EDIT: changed to this @Override @SideOnly(Side.CLIENT) public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { IBlockState newState = state; RenderGlobal render = Minecraft.getMinecraft().renderGlobal; DestroyBlockProgress progress = null; if(damage != null) { Map mp; try { mp = (Map)damage.get(render); Iterator it = mp.entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry)it.next(); progress = (DestroyBlockProgress) pair.getValue(); if(progress.getPosition().equals(pos)) { newState = state.withProperty(DAMAGE, Integer.valueOf(progress.getPartialBlockDamage())); } } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } return newState; } still returning the incorrect block model
-
Alright, code changed to this public static Field damage; public static int d_progress; ... /** * Get the actual Block state of this Block at the given position. This applies properties not visible in the * metadata, such as fence connections. */ @Override @SideOnly(Side.CLIENT) public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { IBlockState newState = state; RenderGlobal render = Minecraft.getMinecraft().renderGlobal; DestroyBlockProgress progress = null; if(damage != null) { Map mp; try { mp = (Map)damage.get(render); Iterator it = mp.entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry)it.next(); progress = (DestroyBlockProgress) pair.getValue(); if(progress.getPosition().equals(pos)) { d_progress = progress.getPartialBlockDamage(); newState = this.blockState.getBaseState().withProperty(DAMAGE, Integer.valueOf(this.d_progress)); } } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } return newState; } static { try { damage = RenderGlobal.class.getDeclaredField("damagedBlocks"); damage.setAccessible(true); } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } } But still get the incorrect blockstate when placing it down
-
/** * Get the actual Block state of this Block at the given position. This applies properties not visible in the * metadata, such as fence connections. */ @Override @SideOnly(Side.CLIENT) public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { IBlockState newState = state; newState = this.blockState.getBaseState().withProperty(DAMAGE, Integer.valueOf(this.damage)); return newState; } static { RenderGlobal render = Minecraft.getMinecraft().renderGlobal; DestroyBlockProgress progress = null; Field damage; try { damage = RenderGlobal.class.getDeclaredField("damagedBlocks"); damage.setAccessible(true); if(damage != null) { Map mp = (Map)damage.get(render); Iterator it = mp.entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry)it.next(); progress = (DestroyBlockProgress) pair.getValue(); BlockCoalBlock.damage = progress.getPartialBlockDamage(); } } } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } } it gives me this java.lang.ExceptionInInitializerError at blaze.core.BLBlocks.addBlocks(BLBlocks.java:108) ~[bin/:?] at blaze.core.BL.preInit(BL.java:33) ~[bin/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_51] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_51] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_51] at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:536) ~[forgeSrc-1.8-11.14.1.1375.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_51] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_51] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_51] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:208) ~[forgeSrc-1.8-11.14.1.1375.jar:?] at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:187) ~[forgeSrc-1.8-11.14.1.1375.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_51] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_51] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_51] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118) [LoadController.class:?] at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:514) [Loader.class:?] at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243) [FMLClientHandler.class:?] at net.minecraft.client.Minecraft.startGame(Minecraft.java:446) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:356) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_51] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_51] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_51] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] at GradleStart.main(Unknown Source) [start/:?] Caused by: java.lang.NullPointerException at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(Unknown Source) ~[?:1.8.0_51] at sun.reflect.UnsafeQualifiedObjectFieldAccessorImpl.get(Unknown Source) ~[?:1.8.0_51] at java.lang.reflect.Field.get(Unknown Source) ~[?:1.8.0_51] at blaze.blocks.BlockCoalBlock.<clinit>(BlockCoalBlock.java:86) ~[blockCoalBlock.class:?] ... 41 more Also how to check the position? Since it's a static block i can't access the getPosition method
-
Ok, so now it looks like this /** * Get the actual Block state of this Block at the given position. This applies properties not visible in the * metadata, such as fence connections. */ @Override @SideOnly(Side.CLIENT) public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { IBlockState newState = state; RenderGlobal render = Minecraft.getMinecraft().renderGlobal; DestroyBlockProgress progress = null; try { Field damage = RenderGlobal.class.getDeclaredField("damagedBlocks"); damage.setAccessible(true); Map mp = (Map)damage.get(render); Iterator it = mp.entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry)it.next(); progress = (DestroyBlockProgress) pair.getValue(); newState = this.blockState.getBaseState().withProperty(DAMAGE, Integer.valueOf(progress.getPartialBlockDamage())); } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } return newState; } And when placing the block down by default it gives me this This is the blockstate file for the block { "variants": { "damage=0": { "model": "blaze:coal_block" }, "damage=1": { "model": "blaze:coal_block" }, "damage=2": { "model": "blaze:coal_block" }, "damage=3": { "model": "blaze:coal_block" }, "damage=4": { "model": "blaze:coal_block" }, "damage=5": { "model": "blaze:coal_block_5" }, "damage=6": { "model": "blaze:coal_block_5" }, "damage=7": { "model": "blaze:coal_block_5" }, "damage=8": { "model": "blaze:coal_block_5" }, "damage=9": { "model": "blaze:coal_block_5" }, "damage=10": { "model": "blaze:coal_block_5" } } } Also how to prevent from looking it every time?
-
Sorry, my bad! Ok, so i've now this /** * Get the actual Block state of this Block at the given position. This applies properties not visible in the * metadata, such as fence connections. */ @Override @SideOnly(Side.CLIENT) public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { IBlockState newState = state; RenderGlobal render = Minecraft.getMinecraft().renderGlobal; DestroyBlockProgress progress = null; try { Field damage = RenderGlobal.class.getDeclaredField("damagedBlocks"); damage.setAccessible(true); HashMap mp = (HashMap)damage.get(render); Iterator it = mp.entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry)it.next(); System.out.println(pair.getKey() + " = " + pair.getValue()); progress = (DestroyBlockProgress) pair.getValue(); it.remove(); // avoids a ConcurrentModificationException System.out.println(progress.getPartialBlockDamage()); } } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } return newState; } and i can keep track of how the block is damaged. Now, i just have to set a new block state with the progress value right? For example this? return this.getStateFromMeta(2);
-
Looping though the values give me this 157=net.minecraft.client.renderer.DestroyBlockProgress@58da1b27 from the damage.get(render) How to turn this into an integer (from 1 to 10)? Or how from damage variable obtain the position?
-
D'oh, i've changed the system out to this RenderGlobal render = Minecraft.getMinecraft().renderGlobal; try { Field damage = RenderGlobal.class.getDeclaredField("damagedBlocks"); damage.setAccessible(true); System.out.println(damage.get(render).toString()); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } wich is now correct, but the system out return this [15:41:17] [Client thread/INFO] [sTDOUT]: [blaze.blocks.BlockCoalBlock:getActualState:65]: {} and when destroying it gives me this [15:41:31] [Client thread/INFO] [sTDOUT]: [blaze.blocks.BlockCoalBlock:getActualState:65]: {157=net.minecraft.client.renderer.DestroyBlockProgress@58da1b27} So how to get the exact value of the damaging progress?