Jump to content

salvestrom

Members
  • Posts

    116
  • Joined

  • Last visited

Posts posted by salvestrom

  1. Not sure which of the titles options is actually my problem, but here the problem is:

     

    I have a general blockslab class with two variants:

     

    The slabs place and appear correctly in the game world as blocks/slabs.

     

    However, as inventory and entity items they are untextured (but correctly named).

     

    There's an additional error where the game says it cant find the approprite blockstates for an item baring the name the itemBlock is registered with. (i'm assuming this is where the issue is occuring). This currently removed by using the string "mossy_slab" to register the itemblock. note this has no impact on the ingame issue.

     

    My blockstate and model files are copy pastes and so contain no information about inventory or ground states. These seems a potentional solution.

     

    The blockSlab class (i'm fairly confident this is in order):

     

     

     

    public class mossySlab extends BlockSlab

    {

        public static final PropertyEnum<mossySlab.EnumType> VARIANT = PropertyEnum.<mossySlab.EnumType>create("variant", mossySlab.EnumType.class);

     

     

    public mossySlab() {

     

    super(Material.ROCK);

    this.setHardness(2.0F);

    this.setResistance(10F);

    //this.fullblock = fullblock;

    this.setSoundType(SoundType.STONE);

            IBlockState iblockstate = this.blockState.getBaseState();

     

            if (!this.isDouble())

          {

            this.setCreativeTab(w2theJungle.JungleModTab);

    this.setLightOpacity(0);

                iblockstate = iblockstate.withProperty(HALF, BlockSlab.EnumBlockHalf.BOTTOM);

            }

     

    this.setDefaultState(iblockstate.withProperty(VARIANT, mossySlab.EnumType.MOSSY_SLAB));

    }

     

    @SideOnly(Side.CLIENT)

    @Override

    public ItemStack getPickBlock(IBlockState state, RayTraceResult trace, World wrld, BlockPos pos, EntityPlayer player)

    {

            return new ItemStack(JungleBlocks.mossyslabSingle, 1, ((mossySlab.EnumType)state.getValue(VARIANT)).getMetadata());

     

    }

     

        public int quantityDropped(Random p_149745_1_)

        {

            return this.isDouble() ? 2 : 1;

        }

       

        public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state)

        {

            return new ItemStack(Blocks.STONE_SLAB, 1, ((mossySlab.EnumType)state.getValue(VARIANT)).getMetadata());

        }

       

    @Override

    public Item getItemDropped(IBlockState state, Random random, int b) {

     

            return Item.getItemFromBlock(JungleBlocks.mossyslabSingle);

    }

       

        public IBlockState getStateFromMeta(int meta)

        {

            IBlockState iblockstate = this.getDefaultState().withProperty(VARIANT, mossySlab.EnumType.byMetadata(meta & 7));

     

            if (!this.isDouble())

            {

                iblockstate = iblockstate.withProperty(HALF, (meta & 8) == 0 ? BlockSlab.EnumBlockHalf.BOTTOM : BlockSlab.EnumBlockHalf.TOP);

            }

     

            return iblockstate;

        }

       

        public int getMetaFromState(IBlockState state)

        {

            int i = 0;

            i = i | ((mossySlab.EnumType)state.getValue(VARIANT)).getMetadata();

     

            if (!this.isDouble() && state.getValue(HALF) == BlockSlab.EnumBlockHalf.TOP)

            {

                i |= 8;

            }

     

            return i;

        }

     

    @Override

    public String getUnlocalizedName(int meta) {

            return super.getUnlocalizedName() + "." + mossySlab.EnumType.byMetadata(meta).getUnlocalizedName();

    }

       

    @Override

    public Comparable<?> getTypeForItem(ItemStack stack) {

            return mossySlab.EnumType.byMetadata(stack.getMetadata() & 7);

    }

     

    @Override

    public IProperty<?> getVariantProperty() {

            return VARIANT;

    }

     

        @SideOnly(Side.CLIENT)

        public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)

        {

            if (itemIn != Item.getItemFromBlock(JungleBlocks.mossyslabDouble))

            {

                for (mossySlab.EnumType blockstoneslab$enumtype : mossySlab.EnumType.values())

                {

                list.add(new ItemStack(itemIn, 1, blockstoneslab$enumtype.getMetadata()));

                }

            }

        }

     

        public int damageDropped(IBlockState state)

        {

            return ((mossySlab.EnumType)state.getValue(VARIANT)).getMetadata();

        }

     

        protected final BlockStateContainer createBlockState() {

            if (this.isDouble()) {

                return new BlockStateContainer(this, new IProperty[] {VARIANT});

            } else {

                return new BlockStateContainer(

                    this,

                    new IProperty[] {HALF, VARIANT});

            }

        }

       

        public MapColor getMapColor(IBlockState state)

        {

            return ((mossySlab.EnumType)state.getValue(VARIANT)).getMapColor();

        }

       

    @Override

    public boolean isDouble() {

    return false;

    }

     

        public static class Double extends mossySlab

        {

            public boolean isDouble()

            {

                return true;

            }

        }

     

        public static class Half extends mossySlab

        {

            public boolean isDouble()

            {

                return false;

            }

        }

     

     

        public static enum EnumType implements IStringSerializable

        {

            MOSSY_SLAB(0, "mossy", MapColor.STONE),

            MOSSY_SMOOTH_SLAB(1, "mossy_smooth", MapColor.STONE);

     

     

            private static final mossySlab.EnumType[] META_LOOKUP = new mossySlab.EnumType[values().length];

            private final int meta;

            private final String name;

            private final MapColor mapColor;

     

            private EnumType(int p_i46391_3_, String p_i46391_4_, MapColor p_i46391_5_)

            {

                this.meta = p_i46391_3_;

                this.name = p_i46391_4_;

                this.mapColor = p_i46391_5_;

            }

     

            public int getMetadata()

            {

                return this.meta;

            }

     

            public MapColor getMapColor()

            {

                return this.mapColor;

            }

     

            public String toString()

            {

                return this.name;

            }

     

            public static mossySlab.EnumType byMetadata(int meta)

            {

                if (meta < 0 || meta >= META_LOOKUP.length)

                {

                    meta = 0;

                }

     

                return META_LOOKUP[meta];

            }

     

            public String getName()

            {

                return this.name;

            }

     

            public String getUnlocalizedName()

            {

                return this.name;

            }

     

            static

            {

                for (mossySlab.EnumType blockstoneslabnew$enumtype : values())

                {

                    META_LOOKUP[blockstoneslabnew$enumtype.getMetadata()] = blockstoneslabnew$enumtype;

                }

            }

        }

    }

     

     

     

    The definition and registration:

     

     

     

     

                    mossyslabSingle = (BlockSlab) (new mossySlab.Half()).setUnlocalizedName("stoneMossySlab");

    mossyslabDouble = (BlockSlab) (new mossySlab.Double()).setUnlocalizedName("stoneMossySlab");

     

     

                    ItemSlab item = (ItemSlab) (new ItemSlab(JungleBlocks.mossyslabSingle, JungleBlocks.mossyslabSingle, JungleBlocks.mossyslabDouble)).setUnlocalizedName("mossySlab");

    registerBlockSlab(mossyslabSingle, item, "mossy_slab"); 

            registerBlockSlab(mossyslabDouble, null, "mossy_double_slab");

     

    public static void registerBlockSlab(Block block, ItemSlab item, String string)

    {

    block.setRegistryName(string);

    GameRegistry.register(block);

    if(item != null)

    {

    GameRegistry.register(item, block.getRegistryName());

    }

           

    }

     

    ModelLoader.setCustomStateMapper(mossyslabSingle, (new StateMap.Builder()).withName(mossySlab.VARIANT).withSuffix("_slab").build());

                    ModelLoader.setCustomStateMapper(mossyslabDouble, (new StateMap.Builder()).withName(mossySlab.VARIANT).withSuffix("_double_slab").build());

     

     

     

     

    The render:

     

     

     

                    registerSlabRender("mossy_slab", mossySlab.EnumType.MOSSY_SLAB.getMetadata(), JungleBlocks.mossyslabSingle);

    registerSlabRender("mossy_smooth_slab", mossySlab.EnumType.MOSSY_SMOOTH_SLAB.getMetadata(), JungleBlocks.mossyslabSingle);

     

    public static void registerSlabRender(String string, int i, Block block)

    {

    Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), i, new ModelResourceLocation(string, "inventory"));

    }

     

     

     

    edit: to remove commented out experiments/notes/old code

  2. if anyone has any idea how to do the below in 1.9.4 it would be appreciated.

     

    Just to clarify, the below code is part of an entity file. The entity, when aggro'd would display a fully drawn bow. Once fired, the animation would cycle back to fully drawn. When the entity had no target, the bow animation was the default(undrawn). It was largely a reversal of animation order, tied to the entity animation counter.

     

    I can see how the bow files getIcon method was update to the addPropertyOverride method, but have no idea how to tap into that from the entity file. I'm not really sure where to go from there.

     

     

     

    //from EntityLizardmanStalker

     

    @Override

        @SideOnly(Side.CLIENT)

        public IIcon getItemIcon(ItemStack p_70620_1_, int p_70620_2_)

        {

            IIcon iicon = super.getItemIcon(p_70620_1_, p_70620_2_);

     

            if(this.getHasTarget() == 2 && p_70620_1_.getItem() instanceof ItemBow)

              {

                    int j = 0 + this.animationTimer;

     

                    if (j >= 15)

                    {

                        return ((ItemBow)p_70620_1_.getItem()).getIcon(p_70620_1_, 0);

                    }

     

                    if (j > 10)

                    {

                    return ((ItemBow)p_70620_1_.getItem()).getItemIconForUseDuration(0);

                    }

     

                    if (j > 5)

                    {

                    return ((ItemBow)p_70620_1_.getItem()).getItemIconForUseDuration(1);

     

                    }

                    if (j >= 0)

                    {

                    return ((ItemBow)p_70620_1_.getItem()).getItemIconForUseDuration(2);

                    }

              }

            else

                //

            if(this.getHasTarget() != 2) {

            iicon = //p_70620_1_.getItem() == Items.bow ?

                ((ItemBow)p_70620_1_.getItem()).getIcon(p_70620_1_, 0);// :

                //((boneGripBow)w2theJungle.boneGripBow).getIcon2(p_70620_1_, p_70620_2_, (EntityLivingBase)this, this.attackStatus, this.attackTime);

            }

            return iicon;

        }

     

     

  3. UPDATE:

    1.11.2 version now available.

    1.10.2 version now available.

    1.9.4 version available now.

     

    /UPDATE

     

    This is something of an update mod, adding a variety of items, blocks, mobs, structures all with a view to enhancing the jungle experience. Head out to the nearest jungle to get started.

     

    link to curse-gaming download:

    http://mods.curse.com/mc-mods/minecraft/246895-welcome-to-the-jungle#t1:description

     

    compatibility:

     

    the two new biomes can only be seen using the added world type, but the world type is not required to experience the majority of the mod.

     

    dimension id is -42 and clashes with thaumacraft. can be altered in config.

     

    the added armour is soulbound, meaning it stays on the player after respawn from death. it is likely going to cause issues with mods like Soulbound. This feature can be disabled in the config.

     

    -=-

     

    contact me at [email protected]

     

    enjoy.

     

  4. this:

     

     

     

    @Override

    public void attackEntityWithRangedAttack(EntityLivingBase nttlb, float rangeMod) {

     

    if(f3 >= this.minRange) {

     

    this.attacktype = 3;

       

        this.worldObj.setEntityState(this, (byte)35);

       

        float a = 0.75f + (1-rangeMod) + ((float)(this.rand.nextGaussian() * 0.25D)

                + ((float)this.worldObj.difficultySetting.getDifficultyId() * 0.11f)) + (nttlb instanceof EntityBat ? 15 : 0);

     

        nttlb.attackEntityFrom(DamageSource.causeMobDamage(this), a);

        nttlb.attackEntityFrom(DamageSource.magic, a);

     

        this.playSound("random.fizz", 5.0F, .21F);

        System.out.println(a);

    }}

     

     

     

    the game will ignore the second call to attackEntityFrom. Whatever's listed first is it.

     

    My objective is to ensure x amount of damage from any of this mobs attacks bypass armour while the rest is physical damage. The above example is an exception where the damage is low and split 50/50. I added similar lines to all the mobs attacks. The mob, a boss, has one exceptionally powerful attack that current armour will not defend well against, forcing the player to use the mod-added armour to stay alive. causing a portion of the damage as magic/generic is intended to ensure the player still does take damage of some amount.

  5. so, yeah. ID-10T issue.

     

    the wakeTheDamned() method gives the skeletons a custom bow. the combat tasks method in EntitySkeleton only checks against Items.bow, so the aid has no ranged attack task. eliminating the appropriate line fixed everything, even if i have new stuff to deal with. :) I will most likely overwrite the combat task method to allow a check for the custom bow.

     

    i was staring at it only yesterday and am kicking myself for not managing to put 2 and 2 together.

     

    thanks for the troubleshooting.

  6. The problem predates the inclusion of aid.onspawnwithegg. I added that today after seeing it used in similar circumstances for vanilla code. it made no difference. the sac. skel entity has no implimentation of onspawn, anyway. also note that my skeleton, when spawned by other means, behaves correctly. it is only the version summoned by the boss code that is not working correctly.

     

    the class:

     

     

     

    public class EntitySacrificialSkeleton extends EntitySkeleton {

     

    public EntitySacrificialSkeleton(World p_i1741_1_) {

    super(p_i1741_1_);

     

    System.out.println("i been made");

     

    }

     

    protected boolean isValidLightLevel()

        {

            int i = MathHelper.floor_double(this.posX);

            int j = MathHelper.floor_double(this.boundingBox.minY);

            int k = MathHelper.floor_double(this.posZ);

     

            if (this.worldObj.getSavedLightValue(EnumSkyBlock.Sky, i, j, k) > this.rand.nextInt(32))

            {

                return false;

            }

            else

            {

                int l = this.worldObj.getBlockLightValue(i, j, k);

     

                if (this.worldObj.isThundering())

                {

                    int i1 = this.worldObj.skylightSubtracted;

                    this.worldObj.skylightSubtracted = 10;

                    l = this.worldObj.getBlockLightValue(i, j, k);

                    this.worldObj.skylightSubtracted = i1;

                }

     

                return true; //l <= this.rand.nextInt(13);

               

    //            return l >= this.rand.nextInt(12) + 6;

            }

        }

     

        public void onLivingUpdate() {

       

        //this.setDead();

        super.onLivingUpdate();

        }

       

        public void updateRidden()

        {

        //this.renderYawOffset = 1.5f;

        super.updateRidden();

       

        }

       

        @Override   

        public boolean attackEntityFrom(DamageSource ds, float f0)

        {

        if(ds == DamageSource.onFire) {

        return false;

        }

       

        if(this.ridingEntity != null && ds.getEntity() == this.ridingEntity)

        {

        return false;

        }

       

        return super.attackEntityFrom(ds, f0);

        }

       

        public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)

        {

        if(this.ridingEntity != null && p_82196_1_ == this.ridingEntity)

        {

        }

       

        this.height = this.isRiding() ? 1.8f * 1.25f : 1.8f;

       

            EntityArrow entityarrow = new EntityArrow(this.worldObj, this, p_82196_1_, 1.6F, (float)(14 - this.worldObj.difficultySetting.getDifficultyId() * 4));

            int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem());

            int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem());

            entityarrow.setDamage((double)(p_82196_2_ * 2.0F) + this.rand.nextGaussian() * 0.25D + (double)((float)this.worldObj.difficultySetting.getDifficultyId() * 0.11F));

     

            if (i > 0)

            {

                entityarrow.setDamage(entityarrow.getDamage() + (double)i * 0.5D + 0.5D);

            }

     

            if (j > 0)

            {

                entityarrow.setKnockbackStrength(j);

            }

     

            if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, this.getHeldItem()) > 0 || this.getSkeletonType() == 1)

            {

                entityarrow.setFire(100);

            }

     

            this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));

            this.worldObj.spawnEntityInWorld(entityarrow);

        }

     

        protected Item getDropItem()

        {

            return Items.arrow;

        }

       

       

     

        protected void dropFewItems(boolean p_70628_1_, int p_70628_2_)

        {

            int j;

            int k;

     

            j = this.rand.nextInt(3 + p_70628_2_);

     

            for (k = 0; k < j; ++k)

            {

            this.dropItem(Items.arrow, 1);

          }

     

            j = this.rand.nextInt(1 + p_70628_2_);

     

            for (k = 0; k < j; ++k)

            {

                this.dropItem(w2theJungle.carvedBone, 1);

            }

        }

     

        protected void dropRareDrop(int p_70600_1_)

        {

        this.entityDropItem(new ItemStack(w2theJungle.ancientSkull, 1, 1), 0.0F);

        }

    }

     

     

     

     

    as you can see, theres nothing here but tweaks to code for loot and valid light checks. if it wasn't for an issue with mounted shooting and an abandoned interest in upping their dmg, the ranged attack method wouldn't even be here.

     

    is there a chance this is due to an issue with an older forge? my 1.7.10 is a year old, i think.

  7.  

     

     

    public void wakeTheDamned() {

     

    if(!this.worldObj.isRemote)

    {

    for(int i = 0; i < 2; ++i) {

     

    //"Wake the Dead"

    EntitySacrificialSkeleton aid = new EntitySacrificialSkeleton(this.worldObj);

    aid.setLocationAndAngles((double)this.posX-5+this.rand.nextInt(10), (double)this.posY+1, (double)this.posZ-5+this.rand.nextInt(10), 0.0F, 0.0F);

    aid.onSpawnWithEgg((IEntityLivingData)null);

    aid.setCurrentItemOrArmor(0, new ItemStack(w2theJungle.boneGripBow));

    aid.setCurrentItemOrArmor(4, new ItemStack(w2theJungle.obshelmet));

     

    this.worldObj.spawnEntityInWorld(aid);

    this.playSound("mob.skeleton.hurt", 0.5f, 1);

    aid.spawnExplosionParticle();

    }

    }

    }

     

     

     

     

    This code is part of a boss entity. He summons these adds and can pass his attack target to them. But the mobs summoned in this code are largely idle,  don't fight back and won't respond to passed threat. In contrast the same skeletons summoned using an egg will happily attack anything that they're told to by the boss.

     

    According to the system.out i used, the constructor  for the sacrifical skeletons is run, so presumably the super [which calls EntitySkeleton] is too, yet, it's like it isn't.

     

     

  8. "Again"??

     

    Anyway, that code in my first post is comprised of three things:

     

    1) the onDeath() method from EntityPlayerMP, which is where the livingDeathEvent hook is and which I am cancelling and overwriting.

     

    2) the dropAllItems() method from InventoryPlayer, which is called in the onDeath() method. I have added it directly into my event overwrite, rather than call it as seperate method.

     

    3) My code which consists of a check if the inventory slot contains my mod armour.

     

    It's almost entirely vanilla code, as it appears in the code. I'm using the hook to affect one of only three things it can affect: player inventroy dump. This part was already working before I ever posted. The only hurdle was the fact that the respawn due to death does not copy inventory because in the vanilla game there never is an inventory to copy after death (I didn't get this at the time). You drew my attention to the clone event, which I decided to experiment with ahead of starting from scratch. The clone event provides access to the original inventory, now set by my new version of onDeath() which I can copy using pre-existing methods.

     

    That's about all I'm doing.

     

    if(I ever get this out there && myCodeBreaksOtherPeoplesMod)

    {

          buyDiesieben07Beer == true;

    }

  9. The only thing my code is not doing from your first reply is pre-storing the items to be spared. It seems redundant given that the clone event is able to transfer over inventory - something that happens naturally on dimension transfer but isn't used on respawn because there's never anything to copy in vanilla.

     

    the bus in the main mod file:

     

     

     

    @EventHandler

    public void load(FMLInitializationEvent vnt)

    {

    MinecraftForge.EVENT_BUS.register(new JungleLivingEvent());

    }

     

     

     

    the event class:

     

     

     

    public class JungleLivingEvent {

     

    @SubscribeEvent

    public void keepObsidianArmour(LivingDeathEvent lde)

    {

    //the code in the first post is here, plus some straight copy/paste from ondeath() (in EntityPlayerMP)

            }

     

    //the clone code is also located in this file

     

     

     

     

  10. Sooooo... the below code in the spoiler, mostly hijacked from the actual ondeath method and including a modified version of the dropAllItems() method is intended to keep the armours listed on a player when they die. Which it does... at the instant of death, regular items are clearly being ejected while armour in the inventory is kept on the toolbar. Where it all goes wrong is when I hit the Respawn button. At this point everything still on the player is lost.

     

    The GuiGameOver class has a line relating to this triggering a method in EntityClientPlayerMP to send a packet labelled "Perform_Respawn" which is where the code descends into a quagmire of functions and lines i do not understand.

     

    I've found intriguing lines about clonePlayer and similar stuff to do with recreating inventory, but couldn't find where it's actually called from, let alone if it's what I'm after.

     

    Anyway, so close and yet so far.

     

     

     

    if(!this.thisworld.getGameRules().getGameRuleBooleanValue("keepInventory")

    && lde.entity instanceof EntityPlayerMP)

    {

    lde.setCanceled(true);

     

    EntityPlayerMP ntt = (EntityPlayerMP)lde.entity;

     

            ntt.mcServer.getConfigurationManager().sendChatMsg(ntt.func_110142_aN().func_151521_b());

     

    ItemStack[] ais = ntt.inventory.armorInventory;

     

     

    for(int numi = 0; numi < ais.length; ++i)

    {

    if (ais[num] != null && ((ais[numi].getItem() == w2theJungle.obshelmet)

    || (ais[num].getItem() == w2theJungle.obschest)

    || (ais[num].getItem() == w2theJungle.obsboots)

    || (ais[num].getItem() == w2theJungle.obslegs)

    ))

    {

    ais[num] = ais[num];

    }

    else

    {

    ntt.func_146097_a(ais[num], true, false);

    ais[num] = null;

    }

    }

     

    ItemStack mis[] = ntt.inventory.mainInventory;

     

    for(int i = 0; i < mis.length; ++i)

    {

     

    if(mis[num] != null && ((mis[num].getItem() == w2theJungle.obshelmet)

    || (mis[num].getItem() == w2theJungle.obschest)

    || (mis[num].getItem() == w2theJungle.obsboots)

    || (mis[num].getItem() == w2theJungle.obslegs)

    ))

    {

    mis[num] = mis[num];

    }

    else

    {

    ntt.func_146097_a(mis[num], true, false);

    mis[num] = null;

    }

    }

     

    note: lower half of code was removed since its pure copy/paste from onDeath()

     

     

     

  11. creating a custom liquid using material.water is great. except for a few cosmetic issues. one of which is the bubbles and splashes entities make as they run through the custom liquid. this is done by the handleWaterMovement() in the Entity class. I created a LivingUpdateEvent and put in a near duplicate of this method, designed for a custom material. At this point all the watery movement was lost because the moveEntityWithHeading() method is hard coded to check for material.water and lava. I seem to be looking then, at overwriting that method. My attempt to do so failed because the game was adding the movement from my own method to the games moveEntity...() method, while the latter also treated entities as being on the ground. In other words nothing was really solved.

     

    So I feel like I'm rebuilding a ferrarri engine for the sake of a new paint job.

     

    This is my first mod and I am actually willing to suffer the cosmetic blips if the alternative is something more major, at least, for this go around. I'm too close to being finished, otherwise.

     

    Any indication of how to procede would be greatly appreciated.

×
×
  • Create New...

Important Information

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