Search in sources :

Example 11 with ItemMaterial

use of pl.asie.charset.lib.material.ItemMaterial in project Charset by CharsetMC.

the class EntityBoatCharset method updateFallState.

@Override
protected void updateFallState(double y, boolean onGroundIn, IBlockState state, BlockPos pos) {
    captureDrops = true;
    super.updateFallState(y, onGroundIn, state, pos);
    captureDrops = false;
    if (!world.isRemote) {
        ItemMaterial stickMaterial = material.getRelated("stick");
        if (stickMaterial == null) {
            stickMaterial = ItemMaterialRegistry.INSTANCE.getOrCreateMaterial(new ItemStack(Items.STICK));
        }
        for (EntityItem entityItem : capturedDrops) {
            if (entityItem.getItem().getItem() == Item.getItemFromBlock(Blocks.PLANKS)) {
                ItemStack newStack = material.getStack().copy();
                newStack.setCount(entityItem.getItem().getCount());
                entityItem.setItem(newStack);
            } else if (entityItem.getItem().getItem() == Items.STICK) {
                ItemStack newStack = stickMaterial.getStack().copy();
                newStack.setCount(entityItem.getItem().getCount());
                entityItem.setItem(newStack);
            }
            world.spawnEntity(entityItem);
        }
    }
    capturedDrops.clear();
}
Also used : ItemMaterial(pl.asie.charset.lib.material.ItemMaterial) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Aggregations

ItemMaterial (pl.asie.charset.lib.material.ItemMaterial)11 ItemStack (net.minecraft.item.ItemStack)7 ArrayList (java.util.ArrayList)3 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 EnumFacing (net.minecraft.util.EnumFacing)2 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)2 IAction (crafttweaker.IAction)1 IItemStack (crafttweaker.api.item.IItemStack)1 TObjectIntHashMap (gnu.trove.map.hash.TObjectIntHashMap)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)1 VertexFormatElement (net.minecraft.client.renderer.vertex.VertexFormatElement)1 Entity (net.minecraft.entity.Entity)1 EntityBoat (net.minecraft.entity.item.EntityBoat)1 EntityItem (net.minecraft.entity.item.EntityItem)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 NBTTagList (net.minecraft.nbt.NBTTagList)1 TileEntity (net.minecraft.tileentity.TileEntity)1