Search in sources :

Example 6 with MCItemStack

use of minetweaker.mc1102.item.MCItemStack in project BetterStorage by copygirl.

the class RecipeInputIngredient method craft.

@Override
public void craft(ItemStack input, ContainerInfo containerInfo) {
    super.craft(input, containerInfo);
    ItemStack transformed = MTHelper.toStack(ingredient.applyTransform(new MCItemStack(input), ((player != null) ? new MCPlayer(player) : null)));
    if (transformed != input) {
        input.stackSize = 0;
        if (transformed.stackSize > 0)
            containerInfo.set(transformed, false);
    }
}
Also used : MCItemStack(minetweaker.mc1710.item.MCItemStack) MCPlayer(minetweaker.mc1710.player.MCPlayer) MCItemStack(minetweaker.mc1710.item.MCItemStack) IItemStack(minetweaker.api.item.IItemStack) ItemStack(net.minecraft.item.ItemStack)

Example 7 with MCItemStack

use of minetweaker.mc1102.item.MCItemStack in project CraftTweaker by CraftTweaker.

the class ForgeEventHandler method mobDrop.

@SubscribeEvent
public void mobDrop(LivingDropsEvent ev) {
    Entity entity = ev.getEntity();
    IEntityDefinition entityDefinition = MineTweakerAPI.game.getEntity(EntityList.getEntityString(ev.getEntity()));
    if (entityDefinition != null) {
        if (!entityDefinition.getDropsToAdd().isEmpty()) {
            entityDefinition.getDropsToAdd().forEach((key, val) -> {
                EntityItem item = null;
                if (val.getMin() == 0 && val.getMax() == 0) {
                    item = new EntityItem(entity.world, entity.posX + 0.5, entity.posY + 0.5, entity.posZ + 0.5, ((ItemStack) key.getInternal()).copy());
                } else {
                    item = new EntityItem(entity.world, entity.posX + 0.5, entity.posY + 0.5, entity.posZ + 0.5, ((ItemStack) key.withAmount(val.getRandom()).getInternal()).copy());
                }
                ev.getDrops().add(item);
            });
        }
        if (ev.getSource().getEntity() instanceof EntityPlayer) {
            if (!entityDefinition.getDropsToAddPlayerOnly().isEmpty()) {
                entityDefinition.getDropsToAddPlayerOnly().forEach((key, val) -> {
                    EntityItem item = null;
                    if (val.getMin() == 0 && val.getMax() == 0) {
                        item = new EntityItem(entity.world, entity.posX + 0.5, entity.posY + 0.5, entity.posZ + 0.5, ((ItemStack) key.getInternal()).copy());
                    } else {
                        item = new EntityItem(entity.world, entity.posX + 0.5, entity.posY + 0.5, entity.posZ + 0.5, ((ItemStack) key.withAmount(val.getRandom()).getInternal()).copy());
                    }
                    ev.getDrops().add(item);
                });
            }
        }
        if (!entityDefinition.getDropsToRemove().isEmpty()) {
            List<EntityItem> removedDrops = new ArrayList<>();
            entityDefinition.getDropsToRemove().forEach(drop -> {
                // if(drop.matches(new MCItemStack()))
                ev.getDrops().forEach(drops -> {
                    if (drop.matches(new MCItemStack(drops.getEntityItem()))) {
                        removedDrops.add(drops);
                    }
                });
            });
            ev.getDrops().removeAll(removedDrops);
        }
    }
}
Also used : MCItemStack(minetweaker.mc1112.item.MCItemStack) IEntityDefinition(minetweaker.api.entity.IEntityDefinition) EntityPlayer(net.minecraft.entity.player.EntityPlayer) IItemStack(minetweaker.api.item.IItemStack) ItemStack(net.minecraft.item.ItemStack) MCItemStack(minetweaker.mc1112.item.MCItemStack) EntityItem(net.minecraft.entity.item.EntityItem) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 8 with MCItemStack

use of minetweaker.mc1102.item.MCItemStack in project CraftTweaker by CraftTweaker.

the class MCBrewingManager method getAll.

@Override
public List<IBrewingRecipe> getAll() {
    List<IBrewingRecipe> ret = new ArrayList<>();
    for (net.minecraftforge.common.brewing.IBrewingRecipe rec : BrewingRecipeRegistry.getRecipes()) {
        if (rec instanceof net.minecraftforge.common.brewing.AbstractBrewingRecipe) {
            AbstractBrewingRecipe abs = (AbstractBrewingRecipe) rec;
            if (abs instanceof BrewingOreRecipe) {
                BrewingOreRecipe brew = (BrewingOreRecipe) abs;
                ret.add(new BrewingRecipe(new MCItemStack(brew.getOutput()), new MCItemStack(brew.getInput()), convert(brew.getIngredient())));
            }
        }
    }
    return ret;
}
Also used : net.minecraftforge.common.brewing(net.minecraftforge.common.brewing) MCItemStack(minetweaker.mc1112.item.MCItemStack) IBrewingRecipe(minetweaker.api.recipes.IBrewingRecipe) BrewingRecipe(minetweaker.api.recipes.BrewingRecipe) IBrewingRecipe(minetweaker.api.recipes.IBrewingRecipe)

Aggregations

ItemStack (net.minecraft.item.ItemStack)4 MCItemStack (crafttweaker.mc1120.item.MCItemStack)3 IItemStack (minetweaker.api.item.IItemStack)3 EntityItem (net.minecraft.entity.item.EntityItem)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 IEntityDefinition (minetweaker.api.entity.IEntityDefinition)2 BrewingRecipe (minetweaker.api.recipes.BrewingRecipe)2 IBrewingRecipe (minetweaker.api.recipes.IBrewingRecipe)2 MCItemStack (minetweaker.mc1102.item.MCItemStack)2 MCItemStack (minetweaker.mc1112.item.MCItemStack)2 net.minecraftforge.common.brewing (net.minecraftforge.common.brewing)2 crafttweaker (crafttweaker)1 IDamageSource (crafttweaker.api.damage.IDamageSource)1 crafttweaker.api.entity (crafttweaker.api.entity)1 IItemStack (crafttweaker.api.item.IItemStack)1 CraftTweakerMC (crafttweaker.api.minecraft.CraftTweakerMC)1 IPlayer (crafttweaker.api.player.IPlayer)1 CraftingInfo (crafttweaker.api.recipes.CraftingInfo)1 crafttweaker.mc1120.brackets (crafttweaker.mc1120.brackets)1