Search in sources :

Example 1 with MCItemStack

use of minetweaker.mc1102.item.MCItemStack in project GregTech by GregTechCE.

the class CTRecipe method getChancedOutputs.

@ZenGetter("changedOutputs")
public List<ChancedEntry> getChancedOutputs() {
    ArrayList<ChancedEntry> result = new ArrayList<>();
    this.backingRecipe.getChancedOutputs().forEach(chanceEntry -> result.add(new ChancedEntry(new MCItemStack(chanceEntry.getItemStack()), chanceEntry.getChance(), chanceEntry.getBoostPerTier())));
    return result;
}
Also used : MCItemStack(crafttweaker.mc1120.item.MCItemStack) ArrayList(java.util.ArrayList) ZenGetter(stanhebben.zenscript.annotations.ZenGetter)

Example 2 with MCItemStack

use of minetweaker.mc1102.item.MCItemStack in project GregTech by GregTechCE.

the class MetaTileEntityBracketHandler method getMetaTileEntityItem.

public static IItemStack getMetaTileEntityItem(String name) {
    String[] resultName = splitObjectName(name);
    MetaTileEntity metaTileEntity = GregTechAPI.META_TILE_ENTITY_REGISTRY.getObject(new ResourceLocation(resultName[0], resultName[1]));
    return metaTileEntity == null ? null : new MCItemStack(metaTileEntity.getStackForm());
}
Also used : MCItemStack(crafttweaker.mc1120.item.MCItemStack) ResourceLocation(net.minecraft.util.ResourceLocation) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) ExpressionString(stanhebben.zenscript.expression.ExpressionString)

Example 3 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.mc1102.item.MCItemStack) IEntityDefinition(minetweaker.api.entity.IEntityDefinition) EntityPlayer(net.minecraft.entity.player.EntityPlayer) MCItemStack(minetweaker.mc1102.item.MCItemStack) IItemStack(minetweaker.api.item.IItemStack) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 4 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.mc1102.item.MCItemStack) IBrewingRecipe(minetweaker.api.recipes.IBrewingRecipe) BrewingRecipe(minetweaker.api.recipes.BrewingRecipe) IBrewingRecipe(minetweaker.api.recipes.IBrewingRecipe)

Example 5 with MCItemStack

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

the class CommonEventHandler method mobDrop.

@SubscribeEvent
public void mobDrop(LivingDropsEvent ev) {
    Entity entity = ev.getEntity();
    IEntityDefinition entityDefinition = CraftTweakerAPI.game.getEntity(EntityList.getEntityString(ev.getEntity()));
    if (entityDefinition != null) {
        if (entityDefinition.shouldClearDrops()) {
            ev.getDrops().clear();
        } else if (!entityDefinition.getDropsToRemove().isEmpty()) {
            List<EntityItem> removedDrops = new ArrayList<>();
            entityDefinition.getDropsToRemove().forEach(drop -> ev.getDrops().forEach(drops -> {
                if (drop.matches(new MCItemStack(drops.getItem()))) {
                    removedDrops.add(drops);
                }
            }));
            ev.getDrops().removeAll(removedDrops);
        }
        if (!entityDefinition.getDrops().isEmpty()) {
            Random rand = entity.world.rand;
            entityDefinition.getDrops().forEach(drop -> {
                if (drop.isPlayerOnly() && !(ev.getSource().getTrueSource() instanceof EntityPlayer))
                    return;
                if (drop.getChance() > 0 && drop.getChance() < 1 && rand.nextFloat() > drop.getChance())
                    return;
                EntityItem item;
                if (drop.getMin() == 0 && drop.getMax() == 0) {
                    item = new EntityItem(entity.world, entity.posX + 0.5, entity.posY + 0.5, entity.posZ + 0.5, ((ItemStack) drop.getItemStack().getInternal()).copy());
                } else {
                    item = new EntityItem(entity.world, entity.posX + 0.5, entity.posY + 0.5, entity.posZ + 0.5, ((ItemStack) drop.getItemStack().withAmount(drop.getRange().getRandom(rand)).getInternal()).copy());
                }
                if (item.getItem().getCount() != 0) {
                    ev.getDrops().add(item);
                }
            });
        }
        if (!entityDefinition.getDropFunctions().isEmpty()) {
            IEntity ent = new MCEntity(ev.getEntity());
            IDamageSource dmgSource = new MCDamageSource(ev.getSource());
            entityDefinition.getDropFunctions().stream().map((fun) -> fun.handle(ent, dmgSource)).filter(Objects::nonNull).filter((item) -> item.getAmount() > 0).map(CraftTweakerMC::getItemStack).map((ItemStack item) -> new EntityItem(entity.world, entity.posX + 0.5, entity.posY + 0.5, entity.posZ + 0.5, item)).forEach(ev.getDrops()::add);
        }
    }
}
Also used : crafttweaker.mc1120.brackets(crafttweaker.mc1120.brackets) java.util(java.util) net.minecraftforge.fml.common.gameevent(net.minecraftforge.fml.common.gameevent) crafttweaker.mc1120.recipes(crafttweaker.mc1120.recipes) FurnaceFuelBurnTimeEvent(net.minecraftforge.event.furnace.FurnaceFuelBurnTimeEvent) net.minecraft.item.crafting(net.minecraft.item.crafting) net.minecraftforge.event.entity.item(net.minecraftforge.event.entity.item) PlayerEvent(net.minecraftforge.fml.common.gameevent.PlayerEvent) ItemStack(net.minecraft.item.ItemStack) OreDictionary(net.minecraftforge.oredict.OreDictionary) CraftingInfo(crafttweaker.api.recipes.CraftingInfo) MCFurnaceManager(crafttweaker.mc1120.furnace.MCFurnaceManager) net.minecraft.entity(net.minecraft.entity) IDamageSource(crafttweaker.api.damage.IDamageSource) crafttweaker.api.entity(crafttweaker.api.entity) RegistryEvent(net.minecraftforge.event.RegistryEvent) MCDamageSource(crafttweaker.mc1120.damage.MCDamageSource) IPlayer(crafttweaker.api.player.IPlayer) net.minecraftforge.event.entity.living(net.minecraftforge.event.entity.living) EntityItem(net.minecraft.entity.item.EntityItem) BlockEvent(net.minecraftforge.event.world.BlockEvent) crafttweaker.mc1120.events.handling(crafttweaker.mc1120.events.handling) net.minecraftforge.event.entity.player(net.minecraftforge.event.entity.player) EntityStruckByLightningEvent(net.minecraftforge.event.entity.EntityStruckByLightningEvent) MCEntity(crafttweaker.mc1120.entity.MCEntity) crafttweaker(crafttweaker) MinecraftForge(net.minecraftforge.common.MinecraftForge) IItemStack(crafttweaker.api.item.IItemStack) CraftTweakerMC(crafttweaker.api.minecraft.CraftTweakerMC) EntityPlayer(net.minecraft.entity.player.EntityPlayer) LOWEST(net.minecraftforge.fml.common.eventhandler.EventPriority.LOWEST) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) MCOreDictEntry(crafttweaker.mc1120.oredict.MCOreDictEntry) MCItemStack(crafttweaker.mc1120.item.MCItemStack) InventoryCrafting(net.minecraft.inventory.InventoryCrafting) PlayerBrewedPotionEvent(net.minecraftforge.event.brewing.PlayerBrewedPotionEvent) MCEntity(crafttweaker.mc1120.entity.MCEntity) CraftTweakerMC(crafttweaker.api.minecraft.CraftTweakerMC) MCEntity(crafttweaker.mc1120.entity.MCEntity) MCDamageSource(crafttweaker.mc1120.damage.MCDamageSource) MCItemStack(crafttweaker.mc1120.item.MCItemStack) IDamageSource(crafttweaker.api.damage.IDamageSource) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) IItemStack(crafttweaker.api.item.IItemStack) MCItemStack(crafttweaker.mc1120.item.MCItemStack) EntityItem(net.minecraft.entity.item.EntityItem) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

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