Jump to content

JimiIT92

Members
  • Posts

    867
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by JimiIT92

  1. OH MY GOD! I've just solved this! Or well... the painting finally spawns! Ive just let the EntityClass implements the IEntityAdditionalSpawnData interface, and then add it's related method and IT WORKED! So this is now my class for the entity 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.chunkCoordX); // x buffer.writeInt(this.chunkCoordY); // y buffer.writeInt(this.chunkCoordZ); // z buffer.writeByte(this.getHorizontalFacing().getIndex()); } @Override public void readSpawnData(ByteBuf buffer) { EntityPaintingEB.EnumArt[] aenumart = EntityPaintingEB.EnumArt.values(); this.art = aenumart[buffer.readInt()]; this.chunkCoordX = buffer.readInt(); this.chunkCoordY = buffer.readInt(); this.chunkCoordZ = buffer.readInt(); this.func_174859_a(EnumFacing.getFront((buffer.readByte()))); } } I've also changed the Item class to this 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); } } Now, the only issue remained is that if a painting of 32x32 pixels is spawned (for example the wither painting), it will actually spawns 1 block higher than where i clicked. So here is a picture of a 32x32 painting As you can see rendering is fine but i have clicked with the painting on the block above (so the first log block starting from bottom). It only happens with big painting, if a small painting or a "banner" painting is placed everything works fine Hope to find soon what is the problem and post here the solution. Thanks to all who show me support doing this, probably i will never figured out without you And for who is asking himself, i looked into the AtelierCanvas mod source code on Github
  2. Thanks man, can't wait to know if it works If you paste here all your painting related class i'll test by myself (so you can continue updating other stuff)
  3. I'm starting to guess that there is no answer to my problem If someone know why my entity is not rendering please tell me, i tried EVERYTHING but nothing worked
  4. Understand, thank you
  5. i followed your instructions SanAndreasP but it's still not rendering. I really don't know why this happening
  6. Ok, so i've tried with this tool It's a really powerful tool but however it can't help me becuase the spear act like a bow and when charging it will assume a different model. I think that i'll let act like a normal bow in third person (as i said before in first person it looks fine)
  7. So basically i don't understand exactly how rotation values works. I have a spear item that when charging it use this json file { "parent": "builtin/generated", "textures": { "layer0": "blaze:items/malachite_spear" }, "display": { "thirdperson": { "rotation": [ 0, 90, -35 ], "translation": [ 0, 1.25, -3.5 ], "scale": [ 0.85, 0.85, 0.85 ] }, "firstperson": { "rotation": [ 0, -135, 135 ], "translation": [ 0, 4, 2 ], "scale": [ 1.7, 1.7, 1.7 ] } } } Now, in first person it works as i want (picture below) but in third person i have this but i want that in third person will look similar to first person (so the spear should be horizontal, not vertical). Wich of this value am i supposed to change?
  8. Try doing a block that extends BlockSand but looks like a Diamond block and has same resistance and hardness
  9. adding the potion effect is the fast way, but i DON'T want to add it. I want to do something like the last snapshots
  10. I think that blockId's has been replaced with BlockStates. For the blocklist i don't know (but i don't exclude that here too there are blockstates instead of id's)
  11. How can i simulate the mining fatigue effect? I figured out how to simulate the Haste effect to make an item move faster but it seems that i can't make it slower. The variable interested in this is the swingProgressInt variable, if setting to an higher value will attack instantly (so higher value = higher speed). So i've tried using a negative value, but it results in a really weird animation. If set to 0 acts like a normal tool. This is the code that i use for my item package blaze.items; import blaze.core.BLItems; import blaze.core.BLTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; public class ItemHammer extends ItemPickaxe { public ItemHammer(ToolMaterial par1) { super(par1); this.setCreativeTab(BLTabs.tabTools); } @Override public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { player.swingProgressInt = -255; return false; } }
  12. Ok, i now have only this EntityRegistry.registerModEntity(EntityPaintingEB.class, "paintingEB", 0, BL.instance, 160, Integer.MAX_VALUE, false); //EntityPaintingEB is the entity class //"paintingEB" is the entity name, is this related to something or can be whatever i want? //0 is the id (it's totally a random number) //BL.instance is my mod instance //160 is the tracking range of vanilla painting //Integer.MAX_VALUE is the update frequency of vanilla painting so i removed this painting_eb = new EntityPaintingEB(null); But it's still not rendering at all
  13. Ok i'll change it to that Also, why i should never use the findGlobalUniqueEntityId? I always used that to register mobs and never had problems I forgot to mention that is use it only once, to know "from wich value to start" and then i increment that, is this correct or i should always start with a specific value?
  14. up It's almost solved
  15. Negative numbers makes my katana to not swing at all. I think that the exact value to set could be find in ths function private int getArmSwingAnimationEnd() { return this.isPotionActive(Potion.digSpeed) ? 6 - (1 + this.getActivePotionEffect(Potion.digSpeed).getAmplifier()) * 1 : (this.isPotionActive(Potion.digSlowdown) ? 6 + (1 + this.getActivePotionEffect(Potion.digSlowdown).getAmplifier()) * 2 : 6); } but since is a private function i can't access that to see what value it returns. I tried using the exact value that is supposed to return if the haste or slowdown effect is applied (level 1) (5 for digSpeed and 8 for digSlowdown) but nothing happens (instead with a value of 5 the katana do a weird animation).
  16. Ok, so i've looked into the super method wich is only a return false statement. So i changed my function to this and it worked @Override public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { player.swingProgressInt = 3; return false; } Also fun fact: it seems that i can make my item only faster but not slower.
  17. Ok, so i've looked into the super method wich is only a return false statement. So i changed my function to this and it worked @Override public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { player.swingProgressInt = 3; return false; } Also fun fact: it seems that i can make my item only faster but not slower.
  18. Ok, so i've overrited this method @Override public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { player.swingProgressInt = 1; return this.hitEntity(stack, (EntityLivingBase) entity, player); } and my katana is faster (wich is what i want), BUT if i hit an entity it doesn't deal damage
  19. Ok, so i've overrited this method @Override public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { player.swingProgressInt = 1; return this.hitEntity(stack, (EntityLivingBase) entity, player); } and my katana is faster (wich is what i want), BUT if i hit an entity it doesn't deal damage
  20. Someone in another post told me to do that Anyway i tried changing that value in the function by doing attacker.swingProgressInt = 2; but it doesn't affect the animation (is neither slower or faster)
  21. As by title, i don't know how to use reflection to change a vanilla value. In my particular case i need to change this values swingProgressInt from the EntityLivingBase class to make a faster animation when using a specific item (in my case a Katana). I tried this code Field field; try { field = Class.forName("net.minecraft.entity.EntityLivingBase").getDeclaredField("swingProgressInt"); field.setAccessible(true); field.setInt(arg0, 4); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } but i don't understand what to type in as arg0. The function takes an Object and an int. the in value is the new value of the variable i guess but the object i don't understand what it is
  22. Another test. As i was suspecting the render methods are never called! I don't know why. Is somehow related to how i register the entities? I do this ->from the preInit public static EntityPaintingEB painting_eb; painting_eb = new EntityPaintingEB(null); ->from the Init EntityRegistry.registerModEntity(painting_eb, "painting_eb", EntityRegistry.findGlobalUniqueEntityId(), BL.instance, 128, 1, true); The constructor takes a World argument, wich here i set it to null. I've tried setting it to this Minecraft.getMinecraft().theWorld but it doesn't change. Please i really need help with this
  23. I've done a quick test. In the constructor add this this.setTickRandomly(true); And then override the randomDisplayTick method like this @Override public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { EntityPlayer player = worldIn.getClosestPlayer(pos.getX(), pos.getY(), pos.getZ(), 100); if(player == null) System.out.println("PLAYER FAR"); else System.out.println("PLAYER NEAR"); } Unfortunately this will not work on multiplayer (it takes only the closest player, not ALL the players in that radius, but i will do more tests
  24. Ok, so i've tried doing that, but i don't know how to refer that variable using reflection What is the instruction to do that?
×
×
  • Create New...

Important Information

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