Search in sources :

Example 6 with Method

use of net.minecraftforge.fml.common.Optional.Method in project EnderIO by SleepyTrousers.

the class ItemMagnet method onWornTick.

@Override
@Method(modid = "Baubles|API")
public void onWornTick(ItemStack itemstack, EntityLivingBase player) {
    if (itemstack == null || player == null) {
        return;
    }
    if (player instanceof EntityPlayer && isActive(itemstack) && hasPower(itemstack) && ((EntityPlayer) player).getHealth() > 0f) {
        MagnetController.doHoover((EntityPlayer) player);
        if (!player.world.isRemote && player.world.getTotalWorldTime() % 20 == 0) {
            // mustn't change the item that is in the slot or Baubles will ignore the change
            ItemStack changedStack = itemstack.copy();
            drainPerSecondPower(changedStack);
            IInventory baubles = BaublesUtil.instance().getBaubles((EntityPlayer) player);
            if (baubles != null) {
                for (int i = 0; i < baubles.getSizeInventory(); i++) {
                    if (baubles.getStackInSlot(i) == itemstack) {
                        baubles.setInventorySlotContents(i, changedStack);
                    }
                }
            }
        }
    }
}
Also used : IInventory(net.minecraft.inventory.IInventory) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) Method(net.minecraftforge.fml.common.Optional.Method)

Example 7 with Method

use of net.minecraftforge.fml.common.Optional.Method in project GregTech by GregTechCE.

the class ShapeGenerator method generate.

@ZenMethod
@Method(modid = GTValues.MODID_CT)
public void generate(long randomSeed, IWorld world, IBlockPos centerPos, IBlockState blockState) {
    World mcWorld = CraftTweakerMC.getWorld(world);
    net.minecraft.block.state.IBlockState mcBlockState = CraftTweakerMC.getBlockState(blockState);
    BlockPos blockPos = CraftTweakerMC.getBlockPos(centerPos);
    generate(new Random(randomSeed), (x, y, z) -> mcWorld.setBlockState(blockPos, mcBlockState));
}
Also used : Random(java.util.Random) IBlockPos(crafttweaker.api.world.IBlockPos) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) IWorld(crafttweaker.api.world.IWorld) ZenMethod(stanhebben.zenscript.annotations.ZenMethod) Method(net.minecraftforge.fml.common.Optional.Method) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Aggregations

Method (net.minecraftforge.fml.common.Optional.Method)7 ItemStack (net.minecraft.item.ItemStack)3 ZenMethod (stanhebben.zenscript.annotations.ZenMethod)3 Biome (net.minecraft.world.biome.Biome)2 IEnchantment (crafttweaker.api.enchantments.IEnchantment)1 IItemStack (crafttweaker.api.item.IItemStack)1 CraftTweakerMC (crafttweaker.api.minecraft.CraftTweakerMC)1 IBiome (crafttweaker.api.world.IBiome)1 IBlockPos (crafttweaker.api.world.IBlockPos)1 IWorld (crafttweaker.api.world.IWorld)1 IAlleleButterflySpecies (forestry.api.lepidopterology.IAlleleButterflySpecies)1 IEntityButterfly (forestry.api.lepidopterology.IEntityButterfly)1 EnchantmentData (gregtech.api.enchants.EnchantmentData)1 CTRecipe (gregtech.api.recipes.crafttweaker.CTRecipe)1 Random (java.util.Random)1 Nullable (javax.annotation.Nullable)1 Enchantment (net.minecraft.enchantment.Enchantment)1 EntityItem (net.minecraft.entity.item.EntityItem)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 IInventory (net.minecraft.inventory.IInventory)1