net.minecraft.item.ItemBucket Java Examples

The following examples show how to use net.minecraft.item.ItemBucket. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Fluids.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
private static void initializeFluidBlocksAndBuckets(){
    for(final Fluid fluid : fluids) {
        //FluidRegistry.registerFluid(fluid); (The constructor of FluidPneumaticCrafts registers the fluid.
        Block fluidBlock = fluid.getBlock();
        Blockss.registerBlock(fluidBlock);
        fluidToBlockMap.put(fluid.getName(), fluidBlock);

        Item fluidBucket = new ItemBucket(fluidBlock){
            @Override
            public void addInformation(ItemStack p_77624_1_, net.minecraft.entity.player.EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_){
                super.addInformation(p_77624_1_, p_77624_2_, p_77624_3_, p_77624_4_);
                ItemPneumatic.addTooltip(p_77624_1_, p_77624_2_, p_77624_3_);
            };

            @Override
            @SideOnly(Side.CLIENT)
            public void getSubItems(Item item, CreativeTabs creativeTab, List items){
                if(FluidRegistry.isFluidDefault(fluid)) super.getSubItems(item, creativeTab, items);
            }
        }.setContainerItem(Items.bucket).setCreativeTab(PneumaticCraft.tabPneumaticCraft).setTextureName(Textures.ICON_LOCATION + fluid.getName() + "Bucket").setUnlocalizedName(fluid.getName() + "Bucket");

        Itemss.registerItem(fluidBucket);

        fluidBlockToBucketMap.put(fluidBlock, fluidBucket);

        FluidContainerRegistry.registerFluidContainer(new FluidStack(fluid, 1000), new ItemStack(fluidBucket), new ItemStack(Items.bucket));
    }
}
 
Example #2
Source File: NoFall.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@EventTarget
private void onMotionUpdate(MotionEvent event) {
    if (!modeValue.get().equalsIgnoreCase("MLG"))
        return;

    if (event.getEventState() == EventState.PRE) {
        currentMlgRotation = null;
        mlgTimer.update();

        if (!mlgTimer.hasTimePassed(10))
            return;

        if (mc.thePlayer.fallDistance > minFallDistance.get()) {
            FallingPlayer fallingPlayer = new FallingPlayer(
                    mc.thePlayer.posX,
                    mc.thePlayer.posY,
                    mc.thePlayer.posZ,
                    mc.thePlayer.motionX,
                    mc.thePlayer.motionY,
                    mc.thePlayer.motionZ,
                    mc.thePlayer.rotationYaw,
                    mc.thePlayer.moveStrafing,
                    mc.thePlayer.moveForward
            );

            double maxDist = mc.playerController.getBlockReachDistance() + 1.5;

            FallingPlayer.CollisionResult collision = fallingPlayer.findCollision((int) Math.ceil((1.0 / mc.thePlayer.motionY) * (-maxDist)));

            if (collision == null)
                return;

            boolean ok = new Vec3(mc.thePlayer.posX, mc.thePlayer.posY + mc.thePlayer.eyeHeight, mc.thePlayer.posZ).distanceTo(new Vec3(collision.getPos()).addVector(0.5, 0.5, 0.5)) < mc.playerController.getBlockReachDistance() + Math.sqrt(0.75);

            if (mc.thePlayer.motionY < (collision.getPos().getY() + 1) - mc.thePlayer.posY) {
                ok = true;
            }

            if (!ok)
                return;

            int index = -1;

            for (int i = 36; i < 45; i++) {
                ItemStack itemStack = mc.thePlayer.inventoryContainer.getSlot(i).getStack();

                if (itemStack != null && (itemStack.getItem() == Items.water_bucket || itemStack.getItem() instanceof ItemBlock && ((ItemBlock) itemStack.getItem()).getBlock() == Blocks.web)) {
                    index = i - 36;

                    if (mc.thePlayer.inventory.currentItem == index)
                        break;
                }
            }

            if (index == -1)
                return;

            currentMlgItemIndex = index;
            currentMlgBlock = collision.getPos();

            if (mc.thePlayer.inventory.currentItem != index) {
                mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(index));
            }

            currentMlgRotation = RotationUtils.faceBlock(collision.getPos());
            currentMlgRotation.getRotation().toPlayer(mc.thePlayer);
        }
    } else if (currentMlgRotation != null) {
        ItemStack stack = mc.thePlayer.inventoryContainer.getSlot(currentMlgItemIndex + 36).getStack();

        if (stack.getItem() instanceof ItemBucket) {
            mc.playerController.sendUseItem(mc.thePlayer, mc.theWorld, stack);
        } else {
            Vec3i dirVec = EnumFacing.UP.getDirectionVec();

            if (mc.playerController.onPlayerRightClick(mc.thePlayer, mc.theWorld, stack, currentMlgBlock, EnumFacing.UP, new Vec3(dirVec.getX() * 0.5, dirVec.getY() * 0.5, dirVec.getZ() * 0.5).add(new Vec3(currentMlgBlock)))) {
                mlgTimer.reset();
            }
        }

        if (mc.thePlayer.inventory.currentItem != currentMlgItemIndex)
            mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem));
    }
}
 
Example #3
Source File: PLItems.java    From Production-Line with MIT License 4 votes vote down vote up
public static void init() {
        diamondApple = new ItemDiamondApple();


        record_MusicSpring = new ItemPLRecord("record_musicspring", PLSounds.recordMusicSpring);
        salt = new ItemPLFood("salt", 0, 10F, true);
        gravityRay = new ItemGravityRay();

        //MultiMetaItem registry
        itemOre = new ItemOre();
        itemCrafting = new ItemCrafting();


        // special registry TODO: Better registry system

        packagedSalt = new ItemPL("packaged_salt") {
            /**
             * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
             */
            @Override
            public ActionResult<ItemStack> onItemRightClick(ItemStack itemStack, World world, EntityPlayer player, EnumHand hand) {
                if (PLConfig.instance.throwablePackagedSalt) {
                    if (!player.capabilities.isCreativeMode) {
                        --itemStack.stackSize;
                    }
                    world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
                    if (!world.isRemote) {
                        world.spawnEntity(new EntityThrownItem(world, player, itemStack));
                    }
                }

                return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
            }

        };

        saltWaterBucket = new ItemBucket(Blocks.WATER);
        saltWaterBucket.setCreativeTab(ProductionLine.creativeTabPL)
                .setUnlocalizedName(MOD_ID + ".saltwater_bucket");

//        iridiumPickaxe = ToolPL.registerPickaxe(PLToolMaterial.iridium, "iridium_pickaxe");
//        iridiumAxe = ToolPL.registerAxe(PLToolMaterial.iridium, "iridium_axe");
//        iridiumSpade = ToolPL.registerSpade(PLToolMaterial.iridium, "iridium_spade");
//        iridiumSword = ToolPL.registerSword(PLToolMaterial.iridium, "iridium_sword");

        // TODO: Better registry system
        GameRegistry.<Item>register(saltWaterBucket, new ResourceLocation(MOD_ID, "saltwater_bucket"));
        GameRegistry.registerFuelHandler(new PLItems());
    }