Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Notunknown

Members
  • Posts

    156
  • Joined

  • Last visited

Posts posted by Notunknown

  1. Yeah, so basically dont use getDrops(IBlockAccess, BlockPos, IBlockState, int) as it will probably be removed entirely by 1.13 and doesnt do anything important, either.

     

    As for dropBlockAsItem and dropBlockAsItemWithChance, for most blocks you will not need to override either of those.

  2. I doubt the list would be in the Block, but in whatever function calls getDrops. Your drops should be added to the NonNullList provided. For example:

     

    public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune)

    {

    super.getDrops(drops, world, pos, state, fortune);

    drops.add(new ItemStack(Items.IRON_INGOT));

    drops.add(new ItemStack(Items.GOLD_INGOT));

    drops.add(new ItemStack(Items.DIAMOND));

    }

  3. For these types of functions the list would simply be passed in already created (you dont have to make it yourself with 'new') and you simply add the drops to the list provided.

     

    Because its passed by reference then the list will be the same once your function has completed, ready for forge to drop the items onto the ground (or more likely go through the event system first so other mods can make changes to the drops)

     

    So just add a, b and c to drops

  4. So I am creating a Capability for an ItemStack and have two major issues and a couple of questions:


    The first issue is that the capabilities appear to sync fine, but the data flickers back to the default values on the client what appears to be randomly. On the server the values are always correct, however. I am thinking this is a serialization issue, but the serialization issue that I had in the past manifested itself differently to this (not being random).

    I have checked the incoming packets used to sync the data, and they are correct.

     

    The second issue is that I cannot figure out how to sync the item data for other players than the player who is holding the item. What is the best method for syncing this data to all players, regardless of whether the ItemStack is on the ground, in a container or being held by something?

     

    Finally, I have a few questions regarding Capabilities and some other information:

     

    First, the onUpdate for my Item is fairly simple and could be run on the client (at least partially). It only needs to be synced when the player picks up the ItemStack, drops it or opens a UI (all of which seem to also cause deserialization, so that would be the perfect time to sync). However, I cannot seem to figure out how to do this.

    Secondly (not a Capabilities question, but doesn't seem worthy of a separate thread), are proxies still needed? I have references to client-only classes (such as a reference to Minecraft in the sync message) without the server exploding.

  5. Also, is that the exact way we should be structuring our mods?

     

    I have taken a different approach: giving the

    Mod.EventBusSubscriber

    annotation to

    CommonProxy

    , and

    Mod.EventBusSubscriber(Side.CLIENT)

    and

    SideOnly(Side.CLIENT)

    annotations to

    ClientProxy

    , the providing each with the necessary events.

     

    It works (at least it does not crash when I launch clients or servers).

     

    Or maybe I am being an idiot and should just do what was suggested.

  6. You could provide with another value - the number of health bars remaining.

     

    When it dies, subtract 1 from the remaining bar count and restore it to full health, unless the bar count is reduced to 0.

     

    For example, if an enemy has 2000 health, give it 1000 health and 2 health bars.

  7. I have been looking for a way to prevent an item from being placed in all contains which I do not approve (as they need to be constantly ticking).

     

    However, I could not see any method which I could override, or any event to cancel, which would allow me to do this. Does Forge allow it, or is it something I will have to deal with in some other way.

     

    Alternatively, could I simply do something to the ItemStack when it is placed in any invalid inventory?

     

    Also, I have noticed that an item held by the cursor does not tick, is there something I need to do to have the item held update? Note that it may result in the ItemStack being replaced by another ItemStack or completely destroyed.

  8. I randomly found out about this: It uses

    itemstack.getItem() == Items.elytra

    . Oh well, no need to extend ItemElytra.

     

    Here is the code which is run when flying with an elytra:

     

    if (this.motionY > -0.5D)
    {
    this.fallDistance = 1.0F;
    }
    
    Vec3d vec3d = this.getLookVec();
    float f = this.rotationPitch * 0.017453292F;
    double d6 = Math.sqrt(vec3d.xCoord * vec3d.xCoord + vec3d.zCoord * vec3d.zCoord);
    double d8 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
    double d1 = vec3d.lengthVector();
    float f4 = MathHelper.cos(f);
    f4 = (float)((double)f4 * (double)f4 * Math.min(1.0D, d1 / 0.4D));
    this.motionY += -0.08D + (double)f4 * 0.06D;
    
    if (this.motionY < 0.0D && d6 > 0.0D)
    {
    double d2 = this.motionY * -0.1D * (double)f4;
    this.motionY += d2;
    this.motionX += vec3d.xCoord * d2 / d6;
    this.motionZ += vec3d.zCoord * d2 / d6;
    }
    
    if (f < 0.0F)
    {
    double d9 = d8 * (double)(-MathHelper.sin(f)) * 0.04D;
    this.motionY += d9 * 3.2D;
    this.motionX -= vec3d.xCoord * d9 / d6;
    this.motionZ -= vec3d.zCoord * d9 / d6;
    }
    
    if (d6 > 0.0D)
    {
    this.motionX += (vec3d.xCoord / d6 * d8 - this.motionX) * 0.1D;
    this.motionZ += (vec3d.zCoord / d6 * d8 - this.motionZ) * 0.1D;
    }
    
    this.motionX *= 0.9900000095367432D;
    this.motionY *= 0.9800000190734863D;
    this.motionZ *= 0.9900000095367432D;
    this.moveEntity(this.motionX, this.motionY, this.motionZ);
    
    if (this.isCollidedHorizontally && !this.worldObj.isRemote)
    {
    double d10 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
    double d3 = d8 - d10;
    float f5 = (float)(d3 * 10.0D - 3.0D);
    
    if (f5 > 0.0F)
    {
    	this.playSound(this.getFallSound((int)f5), 1.0F, 1.0F);
    	this.attackEntityFrom(DamageSource.flyIntoWall, f5);
    }
    }
    
    if (this.onGround && !this.worldObj.isRemote)
    {
    this.setFlag(7, false); //Disables elytra flight
    }
    

  9. Why do you need these JSON files? Why can you not use the normal language system?

     

    Its for a sort of book, and the information that it contains is quite complex, with text where some lines can have their own font, it can display images, crafting and furnace recipes in the middle of pages and some lines, paragraphs, images, etc can be disabled/enabled by some arbitrary conditions.

     

    This is what a typical file could contain:

     

     

     

    {

    "title": "This is the title of the page",

    "tooltip": "This is viewed when hovering over the title in the selection menu",

    "content": [

    {

    "type": "text",

    "text": "This is a text fragment."

    },

    {

    "type": "text",

    "text": "This renders in the Standard Galactic Alphabet font.",

    "font": "sga"

    },

    {

    "type": "itemname",

    "item": "minecraft:pickaxe",

    "meta": 0

    },

    {

    "type": "item",

    "item": "minecraft:pickaxe",

    "meta": 0,

    "nbt": {

    "display": {

    "name": "name"

    }

    }

    },

    {

    "type": "crafting_table",

    "item": "minecraft:pickaxe"

    },

    {

    "type": "furnace",

    "name": "minecraft:iron_ingot"

    },

    {

    "type": "image",

    "location": "minecraft:textures/environment/end_sky"

    }

    ]

    }

     

     

  10. My mod requires localization based on JSON files. I am going to go about this by having a subfolder under assets/myMod which contains more subfolders named after the languages (IE: en_US), which the contains a load of different json files. The JSON files are loaded whenever the language is changed and stored somewhere, allowing for localization whilst giving me more power to customize the content of what I am loading.

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.