Search in sources :

Example 1 with ItemPotion

use of net.minecraft.item.ItemPotion in project minecolonies by Minecolonies.

the class ColonyPermissionEventHandler method on.

/**
 * PlayerInteractEvent handler.
 * <p>
 * Check, if a player right clicked a block.
 * Deny if:
 * - If the block is in colony
 * - block is AbstractBlockHut
 * - player has not permission
 *
 * @param event PlayerInteractEvent
 */
@SubscribeEvent
public void on(final PlayerInteractEvent event) {
    if (colony.isCoordInColony(event.getWorld(), event.getPos()) && !(event instanceof PlayerInteractEvent.EntityInteract || event instanceof PlayerInteractEvent.EntityInteractSpecific)) {
        final Block block = event.getWorld().getBlockState(event.getPos()).getBlock();
        // Huts
        if (block instanceof AbstractBlockHut && !colony.getPermissions().hasPermission(event.getEntityPlayer(), Action.ACCESS_HUTS)) {
            cancelEvent(event, event.getEntityPlayer(), colony, Action.ACCESS_HUTS, event.getPos());
            return;
        }
        final Permissions perms = colony.getPermissions();
        if (isFreeToInteractWith(block, event.getPos()) && perms.hasPermission(event.getEntityPlayer(), Action.ACCESS_FREE_BLOCKS)) {
            return;
        }
        if (Configurations.gameplay.enableColonyProtection) {
            if (!perms.hasPermission(event.getEntityPlayer(), Action.RIGHTCLICK_BLOCK) && block != null && block != Blocks.AIR) {
                cancelEvent(event, event.getEntityPlayer(), colony, Action.RIGHTCLICK_BLOCK, event.getPos());
                return;
            }
            if (block instanceof BlockContainer && !perms.hasPermission(event.getEntityPlayer(), Action.OPEN_CONTAINER)) {
                cancelEvent(event, event.getEntityPlayer(), colony, Action.OPEN_CONTAINER, event.getPos());
                return;
            }
            if (event.getWorld().getTileEntity(event.getPos()) != null && !perms.hasPermission(event.getEntityPlayer(), Action.RIGHTCLICK_ENTITY)) {
                cancelEvent(event, event.getEntityPlayer(), colony, Action.RIGHTCLICK_ENTITY, event.getPos());
                return;
            }
            final ItemStack stack = event.getItemStack();
            if (ItemStackUtils.isEmpty(stack) || stack.getItem() instanceof ItemFood) {
                return;
            }
            if (stack.getItem() instanceof ItemPotion && !perms.hasPermission(event.getEntityPlayer(), Action.THROW_POTION)) {
                cancelEvent(event, event.getEntityPlayer(), colony, Action.THROW_POTION, event.getPos());
                return;
            }
            if (stack.getItem() instanceof ItemScanTool && !perms.hasPermission(event.getEntityPlayer(), Action.USE_SCAN_TOOL)) {
                cancelEvent(event, event.getEntityPlayer(), colony, Action.USE_SCAN_TOOL, event.getPos());
                return;
            }
        }
    }
}
Also used : ItemPotion(net.minecraft.item.ItemPotion) ItemFood(net.minecraft.item.ItemFood) ItemScanTool(com.minecolonies.coremod.items.ItemScanTool) BlockContainer(net.minecraft.block.BlockContainer) Permissions(com.minecolonies.coremod.colony.permissions.Permissions) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) AbstractBlockHut(com.minecolonies.coremod.blocks.AbstractBlockHut) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with ItemPotion

use of net.minecraft.item.ItemPotion in project ArsMagica2 by Mithion.

the class AMEventHandler method onPotionBrewed.

@SubscribeEvent
public void onPotionBrewed(PotionBrewedEvent brewEvent) {
    for (ItemStack stack : brewEvent.brewingStacks) {
        if (stack == null)
            continue;
        if (stack.getItem() instanceof ItemPotion) {
            ItemPotion ptn = ((ItemPotion) stack.getItem());
            List<PotionEffect> fx = ptn.getEffects(stack.getItemDamage());
            if (fx == null)
                return;
            for (PotionEffect pe : fx) {
                if (pe.getPotionID() == BuffList.greaterManaPotion.id) {
                    stack = InventoryUtilities.replaceItem(stack, ItemsCommonProxy.greaterManaPotion);
                    break;
                } else if (pe.getPotionID() == BuffList.epicManaPotion.id) {
                    stack = InventoryUtilities.replaceItem(stack, ItemsCommonProxy.epicManaPotion);
                    break;
                } else if (pe.getPotionID() == BuffList.legendaryManaPotion.id) {
                    stack = InventoryUtilities.replaceItem(stack, ItemsCommonProxy.legendaryManaPotion);
                    break;
                }
            }
        }
    }
}
Also used : ItemPotion(net.minecraft.item.ItemPotion) PotionEffect(net.minecraft.potion.PotionEffect) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 3 with ItemPotion

use of net.minecraft.item.ItemPotion in project ImmersiveEngineering by BluSunrize.

the class IEContent method init.

public static void init() {
    /*ARC FURNACE RECYCLING*/
    if (IEConfig.Machines.arcfurnace_recycle) {
        arcRecycleThread = new ArcRecyclingThreadHandler();
        arcRecycleThread.start();
    }
    /*MINING LEVELS*/
    blockOre.setHarvestLevel("pickaxe", 1, blockOre.getStateFromMeta(BlockTypes_Ore.COPPER.getMeta()));
    blockOre.setHarvestLevel("pickaxe", 1, blockOre.getStateFromMeta(BlockTypes_Ore.ALUMINUM.getMeta()));
    blockOre.setHarvestLevel("pickaxe", 2, blockOre.getStateFromMeta(BlockTypes_Ore.LEAD.getMeta()));
    blockOre.setHarvestLevel("pickaxe", 2, blockOre.getStateFromMeta(BlockTypes_Ore.SILVER.getMeta()));
    blockOre.setHarvestLevel("pickaxe", 2, blockOre.getStateFromMeta(BlockTypes_Ore.NICKEL.getMeta()));
    blockOre.setHarvestLevel("pickaxe", 2, blockOre.getStateFromMeta(BlockTypes_Ore.URANIUM.getMeta()));
    blockStorage.setHarvestLevel("pickaxe", 1, blockStorage.getStateFromMeta(BlockTypes_MetalsIE.COPPER.getMeta()));
    blockStorage.setHarvestLevel("pickaxe", 1, blockStorage.getStateFromMeta(BlockTypes_MetalsIE.ALUMINUM.getMeta()));
    blockStorage.setHarvestLevel("pickaxe", 2, blockStorage.getStateFromMeta(BlockTypes_MetalsIE.LEAD.getMeta()));
    blockStorage.setHarvestLevel("pickaxe", 2, blockStorage.getStateFromMeta(BlockTypes_MetalsIE.SILVER.getMeta()));
    blockStorage.setHarvestLevel("pickaxe", 2, blockStorage.getStateFromMeta(BlockTypes_MetalsIE.NICKEL.getMeta()));
    blockStorage.setHarvestLevel("pickaxe", 2, blockStorage.getStateFromMeta(BlockTypes_MetalsIE.URANIUM.getMeta()));
    blockStorage.setHarvestLevel("pickaxe", 2, blockStorage.getStateFromMeta(BlockTypes_MetalsIE.CONSTANTAN.getMeta()));
    blockStorage.setHarvestLevel("pickaxe", 2, blockStorage.getStateFromMeta(BlockTypes_MetalsIE.ELECTRUM.getMeta()));
    blockStorage.setHarvestLevel("pickaxe", 2, blockStorage.getStateFromMeta(BlockTypes_MetalsIE.STEEL.getMeta()));
    /*WORLDGEN*/
    addConfiguredWorldgen(blockOre.getStateFromMeta(0), "copper", IEConfig.Ores.ore_copper);
    addConfiguredWorldgen(blockOre.getStateFromMeta(1), "bauxite", IEConfig.Ores.ore_bauxite);
    addConfiguredWorldgen(blockOre.getStateFromMeta(2), "lead", IEConfig.Ores.ore_lead);
    addConfiguredWorldgen(blockOre.getStateFromMeta(3), "silver", IEConfig.Ores.ore_silver);
    addConfiguredWorldgen(blockOre.getStateFromMeta(4), "nickel", IEConfig.Ores.ore_nickel);
    addConfiguredWorldgen(blockOre.getStateFromMeta(5), "uranium", IEConfig.Ores.ore_uranium);
    /*TILEENTITIES*/
    registerTile(TileEntityIESlab.class);
    registerTile(TileEntityBalloon.class);
    registerTile(TileEntityStripCurtain.class);
    registerTile(TileEntityShaderBanner.class);
    registerTile(TileEntityCokeOven.class);
    registerTile(TileEntityBlastFurnace.class);
    registerTile(TileEntityBlastFurnaceAdvanced.class);
    registerTile(TileEntityCoresample.class);
    registerTile(TileEntityAlloySmelter.class);
    registerTile(TileEntityWoodenCrate.class);
    registerTile(TileEntityWoodenBarrel.class);
    registerTile(TileEntityModWorkbench.class);
    registerTile(TileEntitySorter.class);
    registerTile(TileEntityTurntable.class);
    registerTile(TileEntityFluidSorter.class);
    registerTile(TileEntityWatermill.class);
    registerTile(TileEntityWindmill.class);
    registerTile(TileEntityWoodenPost.class);
    registerTile(TileEntityWallmount.class);
    registerTile(TileEntityLadder.class);
    registerTile(TileEntityLantern.class);
    registerTile(TileEntityRazorWire.class);
    registerTile(TileEntityToolbox.class);
    registerTile(TileEntityStructuralArm.class);
    registerTile(TileEntityConnectorLV.class);
    registerTile(TileEntityRelayLV.class);
    registerTile(TileEntityConnectorMV.class);
    registerTile(TileEntityRelayMV.class);
    registerTile(TileEntityConnectorHV.class);
    registerTile(TileEntityRelayHV.class);
    registerTile(TileEntityConnectorStructural.class);
    registerTile(TileEntityTransformer.class);
    registerTile(TileEntityTransformerHV.class);
    registerTile(TileEntityBreakerSwitch.class);
    registerTile(TileEntityRedstoneBreaker.class);
    registerTile(TileEntityEnergyMeter.class);
    registerTile(TileEntityConnectorRedstone.class);
    registerTile(TileEntityConnectorProbe.class);
    registerTile(TileEntityFeedthrough.class);
    registerTile(TileEntityCapacitorLV.class);
    registerTile(TileEntityCapacitorMV.class);
    registerTile(TileEntityCapacitorHV.class);
    registerTile(TileEntityCapacitorCreative.class);
    registerTile(TileEntityMetalBarrel.class);
    registerTile(TileEntityFluidPump.class);
    registerTile(TileEntityFluidPlacer.class);
    registerTile(TileEntityBlastFurnacePreheater.class);
    registerTile(TileEntityFurnaceHeater.class);
    registerTile(TileEntityDynamo.class);
    registerTile(TileEntityThermoelectricGen.class);
    registerTile(TileEntityElectricLantern.class);
    registerTile(TileEntityChargingStation.class);
    registerTile(TileEntityFluidPipe.class);
    registerTile(TileEntitySampleDrill.class);
    registerTile(TileEntityTeslaCoil.class);
    registerTile(TileEntityFloodlight.class);
    registerTile(TileEntityTurret.class);
    registerTile(TileEntityTurretChem.class);
    registerTile(TileEntityTurretGun.class);
    registerTile(TileEntityBelljar.class);
    registerTile(TileEntityConveyorBelt.class);
    registerTile(TileEntityConveyorVertical.class);
    registerTile(TileEntityMetalPress.class);
    registerTile(TileEntityCrusher.class);
    registerTile(TileEntitySheetmetalTank.class);
    registerTile(TileEntitySilo.class);
    registerTile(TileEntityAssembler.class);
    registerTile(TileEntityAutoWorkbench.class);
    registerTile(TileEntityBottlingMachine.class);
    registerTile(TileEntitySqueezer.class);
    registerTile(TileEntityFermenter.class);
    registerTile(TileEntityRefinery.class);
    registerTile(TileEntityDieselGenerator.class);
    registerTile(TileEntityBucketWheel.class);
    registerTile(TileEntityExcavator.class);
    registerTile(TileEntityArcFurnace.class);
    registerTile(TileEntityLightningrod.class);
    registerTile(TileEntityMixer.class);
    // registerTile(TileEntitySkycrateDispenser.class);
    registerTile(TileEntityFakeLight.class);
    /*ENTITIES*/
    int i = 0;
    EntityRegistry.registerModEntity(new ResourceLocation(ImmersiveEngineering.MODID, "revolverShot"), EntityRevolvershot.class, "revolverShot", i++, ImmersiveEngineering.instance, 64, 1, true);
    EntityRegistry.registerModEntity(new ResourceLocation(ImmersiveEngineering.MODID, "skylineHook"), EntitySkylineHook.class, "skylineHook", i++, ImmersiveEngineering.instance, 64, 1, true);
    // EntityRegistry.registerModEntity(EntitySkycrate.class, "skylineCrate", 2, ImmersiveEngineering.instance, 64, 1, true);
    EntityRegistry.registerModEntity(new ResourceLocation(ImmersiveEngineering.MODID, "revolverShotHoming"), EntityRevolvershotHoming.class, "revolverShotHoming", i++, ImmersiveEngineering.instance, 64, 1, true);
    EntityRegistry.registerModEntity(new ResourceLocation(ImmersiveEngineering.MODID, "revolverShotWolfpack"), EntityWolfpackShot.class, "revolverShotWolfpack", i++, ImmersiveEngineering.instance, 64, 1, true);
    EntityRegistry.registerModEntity(new ResourceLocation(ImmersiveEngineering.MODID, "chemthrowerShot"), EntityChemthrowerShot.class, "chemthrowerShot", i++, ImmersiveEngineering.instance, 64, 1, true);
    EntityRegistry.registerModEntity(new ResourceLocation(ImmersiveEngineering.MODID, "railgunShot"), EntityRailgunShot.class, "railgunShot", i++, ImmersiveEngineering.instance, 64, 5, true);
    EntityRegistry.registerModEntity(new ResourceLocation(ImmersiveEngineering.MODID, "revolverShotFlare"), EntityRevolvershotFlare.class, "revolverShotFlare", i++, ImmersiveEngineering.instance, 64, 1, true);
    EntityRegistry.registerModEntity(new ResourceLocation(ImmersiveEngineering.MODID, "explosive"), EntityIEExplosive.class, "explosive", i++, ImmersiveEngineering.instance, 64, 1, true);
    EntityRegistry.registerModEntity(new ResourceLocation(ImmersiveEngineering.MODID, "fluorescentTube"), EntityFluorescentTube.class, "fluorescentTube", i++, ImmersiveEngineering.instance, 64, 1, true);
    CapabilityShader.register();
    CapabilitySkyhookData.register();
    ShaderRegistry.itemShader = IEContent.itemShader;
    ShaderRegistry.itemShaderBag = IEContent.itemShaderBag;
    ShaderRegistry.itemExamples.add(new ItemStack(IEContent.itemRevolver));
    ShaderRegistry.itemExamples.add(new ItemStack(IEContent.itemDrill));
    ShaderRegistry.itemExamples.add(new ItemStack(IEContent.itemChemthrower));
    ShaderRegistry.itemExamples.add(new ItemStack(IEContent.itemRailgun));
    /*SMELTING*/
    itemMaterial.setBurnTime(6, 3200);
    Item itemBlockStoneDecoration = Item.getItemFromBlock(blockStoneDecoration);
    if (itemBlockStoneDecoration instanceof ItemBlockIEBase)
        ((ItemBlockIEBase) itemBlockStoneDecoration).setBurnTime(3, 3200 * 10);
    /*BANNERS*/
    addBanner("hammer", "hmr", new ItemStack(itemTool, 1, 0));
    addBanner("bevels", "bvl", "plateIron");
    addBanner("ornate", "orn", "dustSilver");
    addBanner("treated_wood", "twd", "plankTreatedWood");
    addBanner("windmill", "wnd", new ItemStack[] { new ItemStack(blockWoodenDevice1, 1, BlockTypes_WoodenDevice1.WINDMILL.getMeta()) });
    if (!BulletHandler.homingCartridges.isEmpty()) {
        ItemStack wolfpackCartridge = BulletHandler.getBulletStack("wolfpack");
        addBanner("wolf_r", "wlfr", wolfpackCartridge, 1);
        addBanner("wolf_l", "wlfl", wolfpackCartridge, -1);
        addBanner("wolf", "wlf", wolfpackCartridge, 0, 0);
    }
    /*ASSEMBLER RECIPE ADAPTERS*/
    // Fluid Ingredients
    AssemblerHandler.registerSpecialQueryConverters((o) -> {
        if (o instanceof IngredientFluidStack)
            return new RecipeQuery(((IngredientFluidStack) o).getFluid(), ((IngredientFluidStack) o).getFluid().amount);
        else
            return null;
    });
    // Potion bullets
    AssemblerHandler.registerRecipeAdapter(RecipePotionBullets.class, new IRecipeAdapter<RecipePotionBullets>() {

        @Nullable
        @Override
        public RecipeQuery[] getQueriedInputs(RecipePotionBullets recipe, NonNullList<ItemStack> input) {
            RecipeQuery bullet = null;
            RecipeQuery potion = null;
            for (int i = 0; i < input.size() - 1; ++i) {
                ItemStack s = input.get(i);
                if (!s.isEmpty()) {
                    if (bullet == null && RecipePotionBullets.isPotionBullet(s))
                        bullet = AssemblerHandler.createQueryFromItemStack(s);
                    else if (potion == null && s.getItem() instanceof ItemPotion)
                        potion = AssemblerHandler.createQuery(MixerPotionHelper.getFluidStackForType(PotionUtils.getPotionFromItem(s), 250));
                    else
                        return null;
                }
            }
            if (bullet == null || potion == null)
                return null;
            return new RecipeQuery[] { bullet, potion };
        }
    });
    DieselHandler.registerFuel(fluidBiodiesel, 125);
    DieselHandler.registerFuel(FluidRegistry.getFluid("fuel"), 375);
    DieselHandler.registerFuel(FluidRegistry.getFluid("diesel"), 175);
    DieselHandler.registerDrillFuel(fluidBiodiesel);
    DieselHandler.registerDrillFuel(FluidRegistry.getFluid("fuel"));
    DieselHandler.registerDrillFuel(FluidRegistry.getFluid("diesel"));
    blockFluidCreosote.setPotionEffects(new PotionEffect(IEPotions.flammable, 100, 0));
    blockFluidEthanol.setPotionEffects(new PotionEffect(MobEffects.NAUSEA, 40, 0));
    blockFluidBiodiesel.setPotionEffects(new PotionEffect(IEPotions.flammable, 100, 1));
    blockFluidConcrete.setPotionEffects(new PotionEffect(MobEffects.SLOWNESS, 20, 3, false, false));
    ChemthrowerHandler.registerEffect(FluidRegistry.WATER, new ChemthrowerEffect_Extinguish());
    ChemthrowerHandler.registerEffect(fluidPotion, new ChemthrowerEffect() {

        @Override
        public void applyToEntity(EntityLivingBase target, @Nullable EntityPlayer shooter, ItemStack thrower, FluidStack fluid) {
            if (fluid.tag != null) {
                List<PotionEffect> effects = PotionUtils.getEffectsFromTag(fluid.tag);
                for (PotionEffect e : effects) {
                    PotionEffect newEffect = new PotionEffect(e.getPotion(), (int) Math.ceil(e.getDuration() * .05), e.getAmplifier());
                    newEffect.setCurativeItems(new ArrayList(e.getCurativeItems()));
                    target.addPotionEffect(newEffect);
                }
            }
        }

        @Override
        public void applyToEntity(EntityLivingBase target, @Nullable EntityPlayer shooter, ItemStack thrower, Fluid fluid) {
        }

        @Override
        public void applyToBlock(World world, RayTraceResult mop, @Nullable EntityPlayer shooter, ItemStack thrower, FluidStack fluid) {
        }

        @Override
        public void applyToBlock(World world, RayTraceResult mop, @Nullable EntityPlayer shooter, ItemStack thrower, Fluid fluid) {
        }
    });
    ChemthrowerHandler.registerEffect(fluidConcrete, new ChemthrowerEffect() {

        @Override
        public void applyToEntity(EntityLivingBase target, @Nullable EntityPlayer shooter, ItemStack thrower, FluidStack fluid) {
            hit(target.world, target.getPosition(), EnumFacing.UP);
        }

        @Override
        public void applyToEntity(EntityLivingBase target, @Nullable EntityPlayer shooter, ItemStack thrower, Fluid fluid) {
        }

        @Override
        public void applyToBlock(World world, RayTraceResult mop, @Nullable EntityPlayer shooter, ItemStack thrower, FluidStack fluid) {
            IBlockState hit = world.getBlockState(mop.getBlockPos());
            if (hit.getBlock() != blockStoneDecoration || hit.getBlock().getMetaFromState(hit) != BlockTypes_StoneDecoration.CONCRETE_SPRAYED.getMeta()) {
                BlockPos pos = mop.getBlockPos().offset(mop.sideHit);
                if (!world.isAirBlock(pos))
                    return;
                AxisAlignedBB aabb = new AxisAlignedBB(pos);
                List<EntityChemthrowerShot> otherProjectiles = world.getEntitiesWithinAABB(EntityChemthrowerShot.class, aabb);
                if (otherProjectiles.size() >= 8)
                    hit(world, pos, mop.sideHit);
            }
        }

        @Override
        public void applyToBlock(World world, RayTraceResult mop, @Nullable EntityPlayer shooter, ItemStack thrower, Fluid fluid) {
        }

        private void hit(World world, BlockPos pos, EnumFacing side) {
            AxisAlignedBB aabb = new AxisAlignedBB(pos);
            List<EntityChemthrowerShot> otherProjectiles = world.getEntitiesWithinAABB(EntityChemthrowerShot.class, aabb);
            for (EntityChemthrowerShot shot : otherProjectiles) shot.setDead();
            world.setBlockState(pos, blockStoneDecoration.getStateFromMeta(BlockTypes_StoneDecoration.CONCRETE_SPRAYED.getMeta()));
            for (EntityLivingBase living : world.getEntitiesWithinAABB(EntityLivingBase.class, aabb)) living.addPotionEffect(new PotionEffect(IEPotions.concreteFeet, Integer.MAX_VALUE));
        }
    });
    ChemthrowerHandler.registerEffect(fluidCreosote, new ChemthrowerEffect_Potion(null, 0, IEPotions.flammable, 140, 0));
    ChemthrowerHandler.registerFlammable(fluidCreosote);
    ChemthrowerHandler.registerEffect(fluidBiodiesel, new ChemthrowerEffect_Potion(null, 0, IEPotions.flammable, 140, 1));
    ChemthrowerHandler.registerFlammable(fluidBiodiesel);
    ChemthrowerHandler.registerFlammable(fluidEthanol);
    ChemthrowerHandler.registerEffect("oil", new ChemthrowerEffect_Potion(null, 0, new PotionEffect(IEPotions.flammable, 140, 0), new PotionEffect(MobEffects.BLINDNESS, 80, 1)));
    ChemthrowerHandler.registerFlammable("oil");
    ChemthrowerHandler.registerEffect("fuel", new ChemthrowerEffect_Potion(null, 0, IEPotions.flammable, 100, 1));
    ChemthrowerHandler.registerFlammable("fuel");
    ChemthrowerHandler.registerEffect("diesel", new ChemthrowerEffect_Potion(null, 0, IEPotions.flammable, 140, 1));
    ChemthrowerHandler.registerFlammable("diesel");
    ChemthrowerHandler.registerEffect("kerosene", new ChemthrowerEffect_Potion(null, 0, IEPotions.flammable, 100, 1));
    ChemthrowerHandler.registerFlammable("kerosene");
    ChemthrowerHandler.registerEffect("biofuel", new ChemthrowerEffect_Potion(null, 0, IEPotions.flammable, 140, 1));
    ChemthrowerHandler.registerFlammable("biofuel");
    ChemthrowerHandler.registerEffect("rocket_fuel", new ChemthrowerEffect_Potion(null, 0, IEPotions.flammable, 60, 2));
    ChemthrowerHandler.registerFlammable("rocket_fuel");
    RailgunHandler.registerProjectileProperties(new IngredientStack("stickIron"), 15, 1.25).setColourMap(new int[][] { { 0xd8d8d8, 0xd8d8d8, 0xd8d8d8, 0xa8a8a8, 0x686868, 0x686868 } });
    RailgunHandler.registerProjectileProperties(new IngredientStack("stickAluminum"), 13, 1.05).setColourMap(new int[][] { { 0xd8d8d8, 0xd8d8d8, 0xd8d8d8, 0xa8a8a8, 0x686868, 0x686868 } });
    RailgunHandler.registerProjectileProperties(new IngredientStack("stickSteel"), 18, 1.25).setColourMap(new int[][] { { 0xb4b4b4, 0xb4b4b4, 0xb4b4b4, 0x7a7a7a, 0x555555, 0x555555 } });
    RailgunHandler.registerProjectileProperties(new ItemStack(itemGraphiteElectrode), 24, .9).setColourMap(new int[][] { { 0x242424, 0x242424, 0x242424, 0x171717, 0x171717, 0x0a0a0a } });
    ExternalHeaterHandler.defaultFurnaceEnergyCost = IEConfig.Machines.heater_consumption;
    ExternalHeaterHandler.defaultFurnaceSpeedupCost = IEConfig.Machines.heater_speedupConsumption;
    ExternalHeaterHandler.registerHeatableAdapter(TileEntityFurnace.class, new DefaultFurnaceAdapter());
    BelljarHandler.DefaultPlantHandler hempBelljarHandler = new BelljarHandler.DefaultPlantHandler() {

        private HashSet<ComparableItemStack> validSeeds = new HashSet<>();

        @Override
        protected HashSet<ComparableItemStack> getSeedSet() {
            return validSeeds;
        }

        @Override
        @SideOnly(Side.CLIENT)
        public IBlockState[] getRenderedPlant(ItemStack seed, ItemStack soil, float growth, TileEntity tile) {
            int age = Math.min(4, Math.round(growth * 4));
            if (age == 4)
                return new IBlockState[] { blockCrop.getStateFromMeta(age), blockCrop.getStateFromMeta(age + 1) };
            return new IBlockState[] { blockCrop.getStateFromMeta(age) };
        }

        @Override
        @SideOnly(Side.CLIENT)
        public float getRenderSize(ItemStack seed, ItemStack soil, float growth, TileEntity tile) {
            return .6875f;
        }
    };
    BelljarHandler.registerHandler(hempBelljarHandler);
    hempBelljarHandler.register(new ItemStack(itemSeeds), new ItemStack[] { new ItemStack(itemMaterial, 4, 4), new ItemStack(itemSeeds, 2) }, new ItemStack(Blocks.DIRT), blockCrop.getDefaultState());
    ThermoelectricHandler.registerSource(new IngredientStack(new ItemStack(Blocks.MAGMA)), 1300);
    ThermoelectricHandler.registerSourceInKelvin("blockIce", 273);
    ThermoelectricHandler.registerSourceInKelvin("blockPackedIce", 200);
    ThermoelectricHandler.registerSourceInKelvin("blockUranium", 2000);
    ThermoelectricHandler.registerSourceInKelvin("blockYellorium", 2000);
    ThermoelectricHandler.registerSourceInKelvin("blockPlutonium", 4000);
    ThermoelectricHandler.registerSourceInKelvin("blockBlutonium", 4000);
    /*MULTIBLOCKS*/
    MultiblockHandler.registerMultiblock(MultiblockCokeOven.instance);
    MultiblockHandler.registerMultiblock(MultiblockAlloySmelter.instance);
    MultiblockHandler.registerMultiblock(MultiblockBlastFurnace.instance);
    MultiblockHandler.registerMultiblock(MultiblockBlastFurnaceAdvanced.instance);
    MultiblockHandler.registerMultiblock(MultiblockMetalPress.instance);
    MultiblockHandler.registerMultiblock(MultiblockCrusher.instance);
    MultiblockHandler.registerMultiblock(MultiblockSheetmetalTank.instance);
    MultiblockHandler.registerMultiblock(MultiblockSilo.instance);
    MultiblockHandler.registerMultiblock(MultiblockAssembler.instance);
    MultiblockHandler.registerMultiblock(MultiblockAutoWorkbench.instance);
    MultiblockHandler.registerMultiblock(MultiblockBottlingMachine.instance);
    MultiblockHandler.registerMultiblock(MultiblockSqueezer.instance);
    MultiblockHandler.registerMultiblock(MultiblockFermenter.instance);
    MultiblockHandler.registerMultiblock(MultiblockRefinery.instance);
    MultiblockHandler.registerMultiblock(MultiblockDieselGenerator.instance);
    MultiblockHandler.registerMultiblock(MultiblockExcavator.instance);
    MultiblockHandler.registerMultiblock(MultiblockBucketWheel.instance);
    MultiblockHandler.registerMultiblock(MultiblockArcFurnace.instance);
    MultiblockHandler.registerMultiblock(MultiblockLightningrod.instance);
    MultiblockHandler.registerMultiblock(MultiblockMixer.instance);
    MultiblockHandler.registerMultiblock(MultiblockFeedthrough.instance);
    /*VILLAGE*/
    IEVillagerHandler.initIEVillagerHouse();
    IEVillagerHandler.initIEVillagerTrades();
    /*LOOT*/
    if (IEConfig.villagerHouse)
        LootTableList.register(VillageEngineersHouse.woodenCrateLoot);
    for (ResourceLocation rl : EventHandler.lootInjections) LootTableList.register(rl);
    // //Railcraft Compat
    // if(Loader.isModLoaded("Railcraft"))
    // {
    // Block rcCube = GameRegistry.findBlock("Railcraft", "cube");
    // if(rcCube!=null)
    // OreDictionary.registerOre("blockFuelCoke", new ItemStack(rcCube,1,0));
    // }
    /*BLOCK ITEMS FROM CRATES*/
    IEApi.forbiddenInCrates.add((stack) -> {
        if (stack.getItem() == IEContent.itemToolbox)
            return true;
        if (stack.getItem() == IEContent.itemToolbox)
            return true;
        if (OreDictionary.itemMatches(new ItemStack(IEContent.blockWoodenDevice0, 1, 0), stack, true))
            return true;
        if (OreDictionary.itemMatches(new ItemStack(IEContent.blockWoodenDevice0, 1, 5), stack, true))
            return true;
        return stack.getItem() instanceof ItemShulkerBox;
    });
    TileEntityFluidPipe.initCovers();
    IEDataFixers.register();
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ItemPotion(net.minecraft.item.ItemPotion) FluidStack(net.minecraftforge.fluids.FluidStack) EnumFacing(net.minecraft.util.EnumFacing) ItemShulkerBox(net.minecraft.item.ItemShulkerBox) World(net.minecraft.world.World) ChemthrowerEffect_Potion(blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect_Potion) TileEntity(net.minecraft.tileentity.TileEntity) Item(net.minecraft.item.Item) ChemthrowerEffect_Extinguish(blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect_Extinguish) ResourceLocation(net.minecraft.util.ResourceLocation) NonNullList(net.minecraft.util.NonNullList) LootTableList(net.minecraft.world.storage.loot.LootTableList) BlockPos(net.minecraft.util.math.BlockPos) ChemthrowerEffect(blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect) IBlockState(net.minecraft.block.state.IBlockState) Fluid(net.minecraftforge.fluids.Fluid) IEFluid(blusunrize.immersiveengineering.common.util.IEFluid) RayTraceResult(net.minecraft.util.math.RayTraceResult) DefaultFurnaceAdapter(blusunrize.immersiveengineering.api.tool.ExternalHeaterHandler.DefaultFurnaceAdapter) RecipeQuery(blusunrize.immersiveengineering.api.tool.AssemblerHandler.RecipeQuery) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) Nullable(javax.annotation.Nullable)

Example 4 with ItemPotion

use of net.minecraft.item.ItemPotion in project MineFactoryReloaded by powercrystals.

the class TileEntityAutoBrewer method activateMachine.

@Override
protected boolean activateMachine() {
    if (_inventory[30] != null) {
        return false;
    }
    boolean hasWorkToDo = false;
    for (int row = 0; row < 6; row++) {
        if (_inventory[getProcessSlot(row)] != null && _inventory[getProcessSlot(row + 1)] == null && canBrew(row)) {
            hasWorkToDo = true;
        }
    }
    if (!hasWorkToDo) {
        setWorkDone(0);
        return false;
    }
    if (getWorkDone() < getWorkMax()) {
        setWorkDone(getWorkDone() + 1);
        return true;
    }
    setWorkDone(0);
    for (int row = 5; row >= 0; row--) {
        ItemStack current = _inventory[getProcessSlot(row)];
        ItemStack next = _inventory[getProcessSlot(row + 1)];
        if (next != null && current != null) {
            return row < 5;
        }
        ItemStack ingredient = _inventory[getTemplateSlot(row)];
        if (_inventory[getProcessSlot(row)] != null && _inventory[getProcessSlot(row)].getItem() instanceof ItemPotion) {
            int existingPotion = _inventory[getProcessSlot(row)].getItemDamage();
            int newPotion = this.getPotionResult(existingPotion, ingredient);
            @SuppressWarnings("unchecked") List<Integer> existingEffects = Item.potion.getEffects(existingPotion);
            @SuppressWarnings("unchecked") List<Integer> newEffects = Item.potion.getEffects(newPotion);
            if ((existingPotion <= 0 || existingEffects != newEffects) && (existingEffects == null || !existingEffects.equals(newEffects) && newEffects != null)) {
                if (existingPotion != newPotion) {
                    _inventory[getProcessSlot(row)].setItemDamage(newPotion);
                }
            } else if (!ItemPotion.isSplash(existingPotion) && ItemPotion.isSplash(newPotion)) {
                _inventory[getProcessSlot(row)].setItemDamage(newPotion);
            }
            _inventory[getProcessSlot(row + 1)] = _inventory[getProcessSlot(row)];
            _inventory[getProcessSlot(row)] = null;
            for (int i = 0; i < 3; i++) {
                if (!UtilInventory.stacksEqual(_inventory[getResourceSlot(row, i)], ingredient)) {
                    continue;
                }
                if (Item.itemsList[ingredient.itemID].hasContainerItem()) {
                    _inventory[getResourceSlot(row, i)] = Item.itemsList[ingredient.itemID].getContainerItemStack(_inventory[getResourceSlot(row, i)]);
                } else {
                    _inventory[getResourceSlot(row, i)].stackSize--;
                    if (_inventory[getResourceSlot(row, i)].stackSize <= 0) {
                        _inventory[getResourceSlot(row, i)] = null;
                    }
                }
                break;
            }
        }
    }
    return true;
}
Also used : ItemPotion(net.minecraft.item.ItemPotion) ItemStack(net.minecraft.item.ItemStack)

Example 5 with ItemPotion

use of net.minecraft.item.ItemPotion in project Wurst-MC-1.12 by Wurst-Imperium.

the class TrajectoriesMod method onRender.

@Override
public void onRender(float partialTicks) {
    EntityPlayerSP player = WMinecraft.getPlayer();
    // check if player is holding item
    ItemStack stack = player.inventory.getCurrentItem();
    if (stack == null)
        return;
    // check if item is throwable
    if (!WItem.isThrowable(stack))
        return;
    boolean usingBow = stack.getItem() instanceof ItemBow;
    // calculate starting position
    double arrowPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * mc.timer.renderPartialTicks - WMath.cos((float) Math.toRadians(player.rotationYaw)) * 0.16F;
    double arrowPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * Minecraft.getMinecraft().timer.renderPartialTicks + player.getEyeHeight() - 0.1;
    double arrowPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * Minecraft.getMinecraft().timer.renderPartialTicks - WMath.sin((float) Math.toRadians(player.rotationYaw)) * 0.16F;
    // calculate starting motion
    float arrowMotionFactor = usingBow ? 1F : 0.4F;
    float yaw = (float) Math.toRadians(player.rotationYaw);
    float pitch = (float) Math.toRadians(player.rotationPitch);
    float arrowMotionX = -WMath.sin(yaw) * WMath.cos(pitch) * arrowMotionFactor;
    float arrowMotionY = -WMath.sin(pitch) * arrowMotionFactor;
    float arrowMotionZ = WMath.cos(yaw) * WMath.cos(pitch) * arrowMotionFactor;
    double arrowMotion = Math.sqrt(arrowMotionX * arrowMotionX + arrowMotionY * arrowMotionY + arrowMotionZ * arrowMotionZ);
    arrowMotionX /= arrowMotion;
    arrowMotionY /= arrowMotion;
    arrowMotionZ /= arrowMotion;
    if (usingBow) {
        float bowPower = (72000 - player.getItemInUseCount()) / 20F;
        bowPower = (bowPower * bowPower + bowPower * 2F) / 3F;
        if (bowPower > 1F || bowPower <= 0.1F)
            bowPower = 1F;
        bowPower *= 3F;
        arrowMotionX *= bowPower;
        arrowMotionY *= bowPower;
        arrowMotionZ *= bowPower;
    } else {
        arrowMotionX *= 1.5D;
        arrowMotionY *= 1.5D;
        arrowMotionZ *= 1.5D;
    }
    // GL settings
    GL11.glPushMatrix();
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDepthMask(false);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glLineWidth(2);
    RenderManager renderManager = mc.getRenderManager();
    // draw trajectory line
    double gravity = usingBow ? 0.05D : stack.getItem() instanceof ItemPotion ? 0.4D : stack.getItem() instanceof ItemFishingRod ? 0.15D : 0.03D;
    Vec3d playerVector = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
    GL11.glColor4f(0, 1, 0, 0.75F);
    GL11.glBegin(GL11.GL_LINE_STRIP);
    for (int i = 0; i < 1000; i++) {
        GL11.glVertex3d(arrowPosX - renderManager.renderPosX, arrowPosY - renderManager.renderPosY, arrowPosZ - renderManager.renderPosZ);
        arrowPosX += arrowMotionX * 0.1;
        arrowPosY += arrowMotionY * 0.1;
        arrowPosZ += arrowMotionZ * 0.1;
        arrowMotionX *= 0.999D;
        arrowMotionY *= 0.999D;
        arrowMotionZ *= 0.999D;
        arrowMotionY -= gravity * 0.1;
        if (WMinecraft.getWorld().rayTraceBlocks(playerVector, new Vec3d(arrowPosX, arrowPosY, arrowPosZ)) != null)
            break;
    }
    GL11.glEnd();
    // draw end of trajectory line
    double renderX = arrowPosX - renderManager.renderPosX;
    double renderY = arrowPosY - renderManager.renderPosY;
    double renderZ = arrowPosZ - renderManager.renderPosZ;
    GL11.glPushMatrix();
    GL11.glTranslated(renderX - 0.5, renderY - 0.5, renderZ - 0.5);
    GL11.glColor4f(0F, 1F, 0F, 0.25F);
    RenderUtils.drawSolidBox();
    GL11.glColor4f(0, 1, 0, 0.75F);
    RenderUtils.drawOutlinedBox();
    GL11.glPopMatrix();
    // GL resets
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthMask(true);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GL11.glPopMatrix();
}
Also used : ItemPotion(net.minecraft.item.ItemPotion) ItemFishingRod(net.minecraft.item.ItemFishingRod) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) ItemStack(net.minecraft.item.ItemStack) ItemBow(net.minecraft.item.ItemBow) RenderManager(net.minecraft.client.renderer.entity.RenderManager) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

ItemPotion (net.minecraft.item.ItemPotion)11 ItemStack (net.minecraft.item.ItemStack)11 ResourceLocation (net.minecraft.util.ResourceLocation)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 Nullable (javax.annotation.Nullable)2 PotionEffect (net.minecraft.potion.PotionEffect)2 EnumFacing (net.minecraft.util.EnumFacing)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 RecipeQuery (blusunrize.immersiveengineering.api.tool.AssemblerHandler.RecipeQuery)1 ChemthrowerEffect (blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect)1 ChemthrowerEffect_Extinguish (blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect_Extinguish)1 ChemthrowerEffect_Potion (blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect_Potion)1 DefaultFurnaceAdapter (blusunrize.immersiveengineering.api.tool.ExternalHeaterHandler.DefaultFurnaceAdapter)1 IEFluid (blusunrize.immersiveengineering.common.util.IEFluid)1 AbstractBlockHut (com.minecolonies.coremod.blocks.AbstractBlockHut)1 Permissions (com.minecolonies.coremod.colony.permissions.Permissions)1 ItemScanTool (com.minecolonies.coremod.items.ItemScanTool)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1