Jump to content

sequituri

Forge Modder
  • Posts

    669
  • Joined

  • Last visited

Posts posted by sequituri

  1. A more effective solution would be:

    A. add an event PlayerEvent.armorChangeEvent with properties Item oldArmor, newArmor

    B. Post the even in these methods:

    • InventoryPlayer#clearInventory - armor removed
    • InventoryPlayer#copyInventory - armor changed
    • InventoryPlayer#damageArmor - armor removed (if damaged beyond repair)
    • InventoryPlayer#decrStackSize - when stack is armorInventory slot
    • InventoryPlayer#dropAllItems - obviously, armor removed
    • InventoryPlayer#getStackInSlotOnClosing - why this removes armor is a mystery
    • InventoryPlayer#setInventorySlotContents - change, add, or remove
    • InventoryPlayer#readFromNBT - donning armor

     

    Then armor can listen for the change and add/remove effects.

  2. The function getEntitySpawningPacket(Entity entity) calls the following function with false as second argument. However, the way it is coded that flag will be ignored. [it will search up the class tree for no reason,  which is unintended behavior]

     

    Current method in cpw.mods.fml.common.registry.EntityRegistry:

    public EntityRegistration lookupModSpawn(Class<? extends Entity> clazz, boolean keepLooking)
        {
            Class<?> localClazz = clazz;
    
            do
            {
                EntityRegistration er = entityClassRegistrations.get(localClazz);
                if (er != null)
                {
                    return er;
                }
                localClazz = localClazz.getSuperclass();
                keepLooking = (!Object.class.equals(localClazz));
            }
            while (keepLooking);
    
            return null;
        }
    

    Proposed code to make the keepLooking parameter actually useful:

    public EntityRegistration lookupModSpawn(Class<? extends Entity> clazz, boolean keepLooking)
        {
            Class<?> localClazz = clazz;
    
            do
            {
                EntityRegistration er = entityClassRegistrations.get(localClazz);
                if (er != null)
                {
                    return er;
                }
                localClazz = localClazz.getSuperclass();
            }
            while (keepLooking && (!Object.class.equals(localClazz)));
    
            return null;
        }

    This might already be changed, but I checked 1208 and it isn't.

     

  3. You might want to think about terrain here too, since your teleport could put the mob under ground or inside other terrain (nearby cliffs or lava pools).

    However, this is all you need.

    event.entity.setPosition(event.entity.posX -10.0D + World.rand.nextDouble() * 20.0D, event.entity.posY - 3.0D + world.rand.nextDouble() * 6.0D, event.entity.posZ - 10.0D + World.rand.nextDouble() * 20.0D);
    

    Noter that the entity will not change facing. The will still be pointed in the same direction they were pointed, unless you use setPositionAndRotation instead.

     

  4. What diesieben07 said. This is due to the fact that the texture cannot be stored with the block, it has to be computed at render time in this case. Now the only problem is figuring out when returning the IIcon where the block actually is. That is tricky, since getIcon does not pass in the coordinates of the block as far as I can tell.

  5. It's just a guess, but why not try and resave your texture again as a PNG file. It seems to have the correct extension, but imageIO cannot read it. It's probably a .jpeg or .bmp with an incorrect extension.

    If that doesn't work, I'm stumped.

  6. implement IFuelHandler in your block class and create the method "int getBurnTime(ItemStack stack)". The register the block as a Fuel Handler with: GameRegistry.registerFuelHandler( MyBlocks.myFuelBlock );

    Of course, replace the argument with your own block instance.

     

  7. Use an plain old interface that defines the methods you want to call on the external mods class. Thusly:

    public interface IFirePlaceCore {
      public void addRecipe(ItemStack stack, Object[] input, boolean shapeless);
      ...
    }
    

    Then define two classes.

    One (DummyFirePlaceCore) where each method has an empty body or returns null, false, 0 depending.

    Another where the actual code is found. Thusly:

    public class RealFirePlaceCore implements IFirePlaceCore {
    // everything same as interface but overridden liek so:
      @Override
      public void addRecipe(ItemStack stack, Object input ...) { return naruto1310.extendedWorkbench.crafting.ExtendedCraftingManager.addRecipe(stack, input); }
    ...
    }
    

    Now, in the initialization event, if mod is loaded assign the second object to the interface property:

      public static IFireplaceCore fpc;
      onInit( .... ) {
        (if loader.isModLoaded("your dependency mod here") fpc = new RealFirePlaceCore(); else fpc = new DummyIFirePlaceCore();
    

    Now just call fpc.addRecipe(yadda yadda);

     

    NOTE: Some detail left out for brevity.

     

  8. You have no constructor for your Ore class that sets the  dimensionList property of the object. So, it is always null. The only similar property set is dimensionListDefault (in both constructors).

     

    You are obviously having problems because you named your parameters the names of some of your class properties. The only way to set the class property when you do that is with this syntax: this.dimensionList = dimensionList;

     

    To avoid such confusion, a) always use "this." or b) don't make your parameter names the same as your property (member) names.

  9. FakePlayer is defined in net.minecraftforge.common.util.FakePlayer.class

     

    It is an EntityClientPlayerMP and overrides several method to do nothing or return false.

    [*]Cannot send commands

    [*]Always has coordinates 0,0,0

    [*]Doesn't have a chatbox or handle chat

    [*]Has no stats

    [*]Will not open a GUI (he has no eyes that could see it anyways)

    [*]Is invulnerable to damage

    [*]He cannot be killed and drop items etc. i.e. onDeath() { return; }

    [*]He will not travel to other dimensions.

    [*]Not much more to say....

     

    Answer your questions?

     

    Oh yeah. The main question in the topic title. FakePlayerFactory is your answer.

  10. First problem, you never update the slot you have the container in. Try putting the return of drainFluidContainer(container) /* the now empty container */ into the slot selected after the call.

     

    This method ...

    FluidContainerRegistry.fillFluidContainer(fluid, container);
    

    ... returns the ItemStack when successful, or null on failure. You ignore the results, hence it does not do what you expect.

  11. You found the next problem.

    java.lang.ClassCastException: net.net46.thesuperhb.IronMan.Armor.Mk1Render cannot be cast to net.minecraftforge.client.IItemRenderer

    In your code you use this instruction:

    MinecraftForgeClient.registerItemRenderer(ironmanMk1Helmet, (IItemRenderer)new Mk1Render());
    

    Since you did not show your Mk1Render class, there was no way of knowing if it was a proper cast. Eclipse should have indicated the error to you.

    You have to make your class implement the interface IItemRenderer or you cannot cast it like that.

  12. If I remember correctly, the float f parameter to renderTileEntityAt(...) gives the partial ticks that occurred since last call. This number is used to determined animation motion interpolation in most renderers. You should not have to use nanotime. You can if you want to, that a matter of taste.

    Mostly I have seen mojang use two variable for last position, and net tick position (computed on the server side) and the client uses partial tick to determine the interpolated animation reference. Last + (Next - Last)/ partialTicks = Current...

  13. What a lot of the noobs to modding do not know is that the parameter names are local only to your method and can be renamed very easily to more understandable/readable names. Just select the parameter name and press CTRL-ALT-R (in eclipse) to give it a new name and all the uses of that name will change automagicly. Eclipse scores! You win.

  14. I'm going with a wild-assed guess here... So don't kill me if I'm wrong, but It may be that you are loading the model before the resource manager has been set up.  The trace-back log shows all of this occurs during the constructing phase before preinitialization event even gets sent. So, I'd suggest not loading armor textures until the preinitialization event is being handled.

  15. This is your problem. You have created a stalemate situation here.

    netherrack_brick_slab = new BlockROCSlab(false, netherrack_bricks, 0.4f, 1.0f, "slabHellrockBrick").register("netherrack_brick_slab");
    netherrack_brick_slab_double = new BlockROCSlab(true, netherrack_bricks, 0.4f, 1.0f, "slabHellrockBrick").register("netherrack_brick_slab_double");
    

    The first block cannot be registered because if uses the second block which is not yet created. The order cannot be reversed, because the second block want the first block to be created. Both of these problems are due to adding .register(name) at the end. The register functions need both blocks already created you they use the value 'null'.

  16. I don't do much with sounds, but I suspect you have made the common mistake of using non-lowercase symbols in resource locations. Minecraft converts all resource location strings to lower-case when it searches for the resource. Try making "activate-TA" something like "activate.ta" and make that change in the sounds.json file, too. See if it works then.

  17. I cannot say what is the best way to slow entities (like within a ring of frost), but I can tell you that you do not want to use dot-product on a velocity vector.  You only want to save the magnitude by a specific amount. The magnitude of a velocity is sqrt(vx^2 + vy^2 + vz^2), scale that magnitude by .7 or whatever, then multiply it by the velocity unit vector to get the proper adjusted speed.

  18. Walking speed is defined in net.minecraft.entity.player.PlayerCapabilities and it's pretty useful and is normally saved with the player data.

        public void writeCapabilitiesToNBT(NBTTagCompound p_75091_1_)
        {
            NBTTagCompound nbttagcompound1 = new NBTTagCompound();
            nbttagcompound1.setBoolean("invulnerable", this.disableDamage);
            nbttagcompound1.setBoolean("flying", this.isFlying);
            nbttagcompound1.setBoolean("mayfly", this.allowFlying);
            nbttagcompound1.setBoolean("instabuild", this.isCreativeMode);
            nbttagcompound1.setBoolean("mayBuild", this.allowEdit);
            nbttagcompound1.setFloat("flySpeed", this.flySpeed);
            nbttagcompound1.setFloat("walkSpeed", this.walkSpeed);
            p_75091_1_.setTag("abilities", nbttagcompound1);
        }
    
        public void readCapabilitiesFromNBT(NBTTagCompound p_75095_1_)
        {
            if (p_75095_1_.hasKey("abilities", 10))
            {
                NBTTagCompound nbttagcompound1 = p_75095_1_.getCompoundTag("abilities");
                this.disableDamage = nbttagcompound1.getBoolean("invulnerable");
                this.isFlying = nbttagcompound1.getBoolean("flying");
                this.allowFlying = nbttagcompound1.getBoolean("mayfly");
                this.isCreativeMode = nbttagcompound1.getBoolean("instabuild");
    
                if (nbttagcompound1.hasKey("flySpeed", 99))
                {
                    this.flySpeed = nbttagcompound1.getFloat("flySpeed");
                    this.walkSpeed = nbttagcompound1.getFloat("walkSpeed");
                }
    
                if (nbttagcompound1.hasKey("mayBuild", 1))
                {
                    this.allowEdit = nbttagcompound1.getBoolean("mayBuild");
                }
            }
        }
    

    You can use PlayerCapabilities#setPlayerWalkSpeed(float speed), but you have to make sure to do it on both sides (for agreement). OnLivingUpdate will set attributes accordingly. These are saved automagicly.

     

×
×
  • Create New...

Important Information

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