mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
Items done, <1000 errors whoot!
This commit is contained in:
1 parent
ad788880e5
commit
8863aab9e5
40 files changed
+1136
-1348
No files matched your search
@@ -52,9 +52,15 @@ import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityNote;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.WeightedRandom;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
@@ -540,14 +546,14 @@ public class ForgeHooks
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static ChatComponentTranslation onServerChatEvent(NetHandlerPlayServer net, String raw, ChatComponentTranslation comp)
|
||||
public static ITextComponent onServerChatEvent(NetHandlerPlayServer net, String raw, ITextComponent comp)
|
||||
{
|
||||
ServerChatEvent event = new ServerChatEvent(net.playerEntity, raw, comp);
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return event.component;
|
||||
return event.getComponent();
|
||||
}
|
||||
|
||||
|
||||
@@ -614,7 +620,7 @@ public class ForgeHooks
|
||||
ClickEvent click = new ClickEvent(ClickEvent.Action.OPEN_URL, url);
|
||||
link.getChatStyle().setChatClickEvent(click);
|
||||
link.getChatStyle().setUnderlined(true);
|
||||
link.getChatStyle().setColor(EnumChatFormatting.BLUE);
|
||||
link.getChatStyle().setColor(TextFormatting.BLUE);
|
||||
if (ichat == null)
|
||||
ichat = link;
|
||||
else
|
||||
@@ -691,7 +697,7 @@ public class ForgeHooks
|
||||
return event.isCanceled() ? -1 : event.getExpToDrop();
|
||||
}
|
||||
|
||||
public static boolean onPlaceItemIntoWorld(ItemStack itemstack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
public static EnumActionResult onPlaceItemIntoWorld(ItemStack itemstack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand)
|
||||
{
|
||||
// handle all placement events here
|
||||
int meta = itemstack.getItemDamage();
|
||||
@@ -707,10 +713,10 @@ public class ForgeHooks
|
||||
world.captureBlockSnapshots = true;
|
||||
}
|
||||
|
||||
boolean flag = itemstack.getItem().onItemUse(itemstack, player, world, pos, side, hitX, hitY, hitZ);
|
||||
EnumActionResult ret = itemstack.getItem().onItemUse(itemstack, player, world, pos, hand, side, hitX, hitY, hitZ);
|
||||
world.captureBlockSnapshots = false;
|
||||
|
||||
if (flag)
|
||||
if (ret == EnumActionResult.SUCCESS)
|
||||
{
|
||||
// save new item data
|
||||
int newMeta = itemstack.getItemDamage();
|
||||
@@ -743,7 +749,7 @@ public class ForgeHooks
|
||||
|
||||
if (placeEvent != null && (placeEvent.isCanceled()))
|
||||
{
|
||||
flag = false; // cancel placement
|
||||
ret = EnumActionResult.FAIL; // cancel placement
|
||||
// revert back all captured blocks
|
||||
for (net.minecraftforge.common.util.BlockSnapshot blocksnapshot : blockSnapshots)
|
||||
{
|
||||
@@ -774,12 +780,12 @@ public class ForgeHooks
|
||||
|
||||
world.markAndNotifyBlock(snap.pos, null, oldBlock, newBlock, updateFlag);
|
||||
}
|
||||
player.addStat(StatList.objectUseStats[Item.getIdFromItem(itemstack.getItem())], 1);
|
||||
player.triggerAchievement(StatList.func_188060_a(itemstack.getItem()));
|
||||
}
|
||||
}
|
||||
world.capturedBlockSnapshots.clear();
|
||||
|
||||
return flag;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static boolean onAnvilChange(ContainerRepair container, ItemStack left, ItemStack right, IInventory outputSlot, String name, int baseCost)
|
||||
|
||||
@@ -16,10 +16,13 @@ import net.minecraft.entity.monster.EntityZombie;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayer.EnumStatus;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -52,6 +55,8 @@ import net.minecraftforge.event.entity.living.LivingPackSizeEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingSpawnEvent.AllowDespawn;
|
||||
import net.minecraftforge.event.entity.living.ZombieEvent.SummonAidEvent;
|
||||
import net.minecraftforge.event.entity.player.ArrowLooseEvent;
|
||||
import net.minecraftforge.event.entity.player.ArrowNockEvent;
|
||||
import net.minecraftforge.event.entity.player.BonemealEvent;
|
||||
import net.minecraftforge.event.entity.player.EntityInteractEvent;
|
||||
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
||||
@@ -297,23 +302,23 @@ public class ForgeEventFactory
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static ItemStack onBucketUse(EntityPlayer player, World world, ItemStack stack, RayTraceResult target)
|
||||
public static ActionResult<ItemStack> onBucketUse(EntityPlayer player, World world, ItemStack stack, RayTraceResult target)
|
||||
{
|
||||
FillBucketEvent event = new FillBucketEvent(player, stack, world, target);
|
||||
if (MinecraftForge.EVENT_BUS.post(event)) return stack;
|
||||
if (MinecraftForge.EVENT_BUS.post(event)) return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
|
||||
|
||||
if (event.getResult() == Result.ALLOW)
|
||||
{
|
||||
if (player.capabilities.isCreativeMode)
|
||||
return stack;
|
||||
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
|
||||
|
||||
if (--stack.stackSize <= 0)
|
||||
return event.getFilledBucket();
|
||||
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, event.getFilledBucket());
|
||||
|
||||
if (!player.inventory.addItemStackToInventory(event.getFilledBucket()))
|
||||
player.dropPlayerItemWithRandomChoice(event.getFilledBucket(), false);
|
||||
|
||||
return stack;
|
||||
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -521,4 +526,20 @@ public class ForgeEventFactory
|
||||
return canContinueSleep == Result.ALLOW;
|
||||
}
|
||||
|
||||
public static ActionResult<ItemStack> onArrowNock(ItemStack item, World world, EntityPlayer player, EnumHand hand, boolean hasAmmo)
|
||||
{
|
||||
ArrowNockEvent event = new ArrowNockEvent(player, item, hand, world, hasAmmo);
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
return new ActionResult<ItemStack>(EnumActionResult.FAIL, item);
|
||||
return event.getAction();
|
||||
}
|
||||
|
||||
public static int onArrowLoose(ItemStack stack, World world, EntityPlayer player, int charge, boolean hasAmmo)
|
||||
{
|
||||
ArrowLooseEvent event = new ArrowLooseEvent(player, stack, world, charge, hasAmmo);
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
return -1;
|
||||
return event.getCharge();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package net.minecraftforge.event.entity.player;
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* ArrowLooseEvent is fired when a player stops using a bow.<br>
|
||||
@@ -22,13 +23,22 @@ import net.minecraft.item.ItemStack;
|
||||
@Cancelable
|
||||
public class ArrowLooseEvent extends PlayerEvent
|
||||
{
|
||||
public final ItemStack bow;
|
||||
public int charge;
|
||||
|
||||
public ArrowLooseEvent(EntityPlayer player, ItemStack bow, int charge)
|
||||
private final ItemStack bow;
|
||||
private final World world;
|
||||
private final boolean hasAmmo;
|
||||
private int charge;
|
||||
|
||||
public ArrowLooseEvent(EntityPlayer player, ItemStack bow, World world, int charge, boolean hasAmmo)
|
||||
{
|
||||
super(player);
|
||||
this.bow = bow;
|
||||
this.world = world;
|
||||
this.charge = charge;
|
||||
this.hasAmmo = hasAmmo;
|
||||
}
|
||||
|
||||
public ItemStack getBow() { return this.bow; }
|
||||
public boolean hasAmmo() { return this.hasAmmo; }
|
||||
public int getCharge() { return this.charge; }
|
||||
public void setCharge(int charge) { this.charge = charge; }
|
||||
}
|
||||
@@ -1,31 +1,45 @@
|
||||
package net.minecraftforge.event.entity.player;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* ArrowNockEvent is fired when a player begins using a bow.<br>
|
||||
* This event is fired whenever a player begins using a bow in
|
||||
* ItemBow#onItemRightClick(ItemStack, World, EntityPlayer).<br>
|
||||
* <br>
|
||||
* {@link #result} contains the resulting ItemStack due to the use of the bow. <br>
|
||||
* <br>
|
||||
* This event is {@link Cancelable}.<br>
|
||||
* If this event is canceled, the player does not begin using the bow.<br>
|
||||
* <br>
|
||||
* This event does not have a result. {@link HasResult}<br>
|
||||
* <br>
|
||||
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
|
||||
**/
|
||||
@Cancelable
|
||||
public class ArrowNockEvent extends PlayerEvent
|
||||
{
|
||||
public ItemStack result;
|
||||
|
||||
public ArrowNockEvent(EntityPlayer player, ItemStack result)
|
||||
private final ItemStack bow;
|
||||
private final EnumHand hand;
|
||||
private final World world;
|
||||
private final boolean hasAmmo;
|
||||
private ActionResult<ItemStack> action;
|
||||
|
||||
public ArrowNockEvent(EntityPlayer player, ItemStack item, EnumHand hand, World world, boolean hasAmmo)
|
||||
{
|
||||
super(player);
|
||||
this.result = result;
|
||||
this.bow = item;
|
||||
this.hand = hand;
|
||||
this.world = world;
|
||||
this.hasAmmo = hasAmmo;
|
||||
}
|
||||
|
||||
public ItemStack getBow() { return this.bow; }
|
||||
public EnumHand getHand() { return this.hand; }
|
||||
public boolean hasAmmo() { return this.hasAmmo; }
|
||||
public ActionResult<ItemStack> getAction()
|
||||
{
|
||||
return this.action;
|
||||
}
|
||||
|
||||
public void setAction(ActionResult<ItemStack> action)
|
||||
{
|
||||
this.action = action;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user