use of minetweaker.mc1710.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;
}
use of minetweaker.mc1710.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());
}
use of minetweaker.mc1710.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);
}
}
}
use of minetweaker.mc1710.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);
}
}
Aggregations