Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I've been playing around with events recently and I'm having some trouble.

 

When I right click the double paper on water nothing happens. I want it to turn into salted paper.

The system print, prints out the coords of the block I clicked on rather than the water(I'm not sure if that right or not).

 

This is the code I'm using, its cannibalized bucket code:

 

 

package robo51.newt.items;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.init.Blocks;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.util.MovingObjectPosition;

import net.minecraft.util.MovingObjectPosition.MovingObjectType;

import net.minecraft.world.World;

import net.minecraftforge.common.MinecraftForge;

import net.minecraftforge.event.entity.player.FillBucketEvent;

import robo51.newt.Newt;

import robo51.newt.lib.Constants;

import cpw.mods.fml.common.eventhandler.Event;

import cpw.mods.fml.common.registry.GameRegistry;

 

public class PaperStackItem extends Item {

 

private String name = "paperstackItem";

    private Block isWet;

 

public PaperStackItem(Block PaperStackItem) {

setUnlocalizedName(Constants.MODID + "_" + name);

setCreativeTab(Newt.tabNewt);

GameRegistry.registerItem(this, name);

setTextureName(Constants.MODID + ":" + name);

        this.maxStackSize = 64;

        this.isWet = PaperStackItem;

}

 

public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {

 

boolean flag = this.isWet == Blocks.air;

MovingObjectPosition movingObjectPosition = this.getMovingObjectPositionFromPlayer(world, player, flag);

 

if (movingObjectPosition == null) {

return itemStack;

} else {

FillBucketEvent event = new FillBucketEvent(player, itemStack, world, movingObjectPosition);

if (MinecraftForge.EVENT_BUS.post(event)) {

return itemStack;

}

 

if (event.getResult() == Event.Result.ALLOW) {

if (--itemStack.stackSize <= 0) {

return event.result;

}

 

if (!player.inventory.addItemStackToInventory(event.result)) {

player.dropPlayerItemWithRandomChoice(event.result,  false);

}

return itemStack;

}

 

if (movingObjectPosition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {

int i = movingObjectPosition.blockX;

int j = movingObjectPosition.blockY;

int k = movingObjectPosition.blockZ;

 

if (!world.canMineBlock(null, i, j, k)) {

return itemStack;

}

 

if (flag) {

if (!player.canPlayerEdit(i, j, k, movingObjectPosition.sideHit, itemStack)) {

return itemStack;

}

 

Material material = world.getBlock(i, j, k).getMaterial();

int l = world.getBlockMetadata(i, j, k);

 

if (material == Material.water && l == 0) {

return this.func_150910_a(itemStack, player, ModItems.saltpaperItem);

}

} else {

if (this.isWet == Blocks.air) {

return new ItemStack(ModItems.paperstackItem);

}

 

if (movingObjectPosition.sideHit == 0) {

--j;

}

 

if (movingObjectPosition.sideHit == 1) {

++j;

}

 

if (movingObjectPosition.sideHit == 2) {

--k;

}

 

if (movingObjectPosition.sideHit == 3) {

++k;

}

 

if (movingObjectPosition.sideHit == 4) {

--i;

}

 

if (movingObjectPosition.sideHit == 5) {

++i;

}

 

                    if (!player.canPlayerEdit(i, j, k, movingObjectPosition.sideHit, itemStack)) {

                        return itemStack;

                    }

}

}

System.out.print("Var I" + " " + movingObjectPosition.blockX);

System.out.print(" ");

System.out.print("Var J" + " " + movingObjectPosition.blockY);

System.out.print(" ");

System.out.print("Var K" + " " + movingObjectPosition.blockZ);

return itemStack;

}

}

 

private ItemStack func_150910_a(ItemStack itemStack, EntityPlayer player, Item item) {

if (--itemStack.stackSize <= 0) {

    return new ItemStack(item);

    } else {

    if (!player.inventory.addItemStackToInventory(new ItemStack(item))) {

    player.dropPlayerItemWithRandomChoice(new ItemStack(item, 1, 0), false);

    }

    return itemStack;

        }

    }

}

 

 

 

Am I missing something?

I'm not trying to be rude it just comes out that way sometimes.

I'm here to try and learn as much as I can, won't you join me?

  • Author

Never-mind I managed to figure it out. :)

I'm not trying to be rude it just comes out that way sometimes.

I'm here to try and learn as much as I can, won't you join me?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.