mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-21 12:42:26 +00:00
Initial 1.11-pre1 update
This commit is contained in:
1 parent
c177219ff3
commit
4e6a774075
294 files changed
+3099
-2846
No files matched your search
@@ -46,6 +46,7 @@ import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
@@ -152,9 +153,9 @@ public class ForgeEventFactory
|
||||
return event;
|
||||
}
|
||||
|
||||
public static NeighborNotifyEvent onNeighborNotify(World world, BlockPos pos, IBlockState state, EnumSet<EnumFacing> notifiedSides)
|
||||
public static NeighborNotifyEvent onNeighborNotify(World world, BlockPos pos, IBlockState state, EnumSet<EnumFacing> notifiedSides, boolean forceRedstoneUpdate)
|
||||
{
|
||||
NeighborNotifyEvent event = new NeighborNotifyEvent(world, pos, state, notifiedSides);
|
||||
NeighborNotifyEvent event = new NeighborNotifyEvent(world, pos, state, notifiedSides, forceRedstoneUpdate);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event;
|
||||
}
|
||||
@@ -354,7 +355,7 @@ public class ForgeEventFactory
|
||||
if (event.getResult() == Result.ALLOW)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
stack.stackSize--;
|
||||
stack.func_190918_g(1);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -370,7 +371,8 @@ public class ForgeEventFactory
|
||||
if (player.capabilities.isCreativeMode)
|
||||
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
|
||||
|
||||
if (--stack.stackSize <= 0)
|
||||
stack.func_190918_g(1);
|
||||
if (stack.func_190926_b())
|
||||
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, event.getFilledBucket());
|
||||
|
||||
if (!player.inventory.addItemStackToInventory(event.getFilledBucket()))
|
||||
@@ -398,7 +400,7 @@ public class ForgeEventFactory
|
||||
public static int onItemExpire(EntityItem entity, ItemStack item)
|
||||
{
|
||||
if (item == null) return -1;
|
||||
ItemExpireEvent event = new ItemExpireEvent(entity, (item.getItem() == null ? 6000 : item.getItem().getEntityLifespan(item, entity.worldObj)));
|
||||
ItemExpireEvent event = new ItemExpireEvent(entity, (item.func_190926_b() ? 6000 : item.getItem().getEntityLifespan(item, entity.worldObj)));
|
||||
if (!MinecraftForge.EVENT_BUS.post(event)) return -1;
|
||||
return event.getExtraLife();
|
||||
}
|
||||
@@ -493,20 +495,20 @@ public class ForgeEventFactory
|
||||
return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.getAmount());
|
||||
}
|
||||
|
||||
public static boolean onPotionAttemptBrew(ItemStack[] stacks)
|
||||
public static boolean onPotionAttemptBrew(NonNullList<ItemStack> stacks)
|
||||
{
|
||||
ItemStack[] tmp = new ItemStack[stacks.length];
|
||||
for (int x = 0; x < tmp.length; x++)
|
||||
tmp[x] = ItemStack.copyItemStack(stacks[x]);
|
||||
NonNullList<ItemStack> tmp = NonNullList.func_191197_a(stacks.size(), ItemStack.field_190927_a);
|
||||
for (int x = 0; x < tmp.size(); x++)
|
||||
tmp.set(x, stacks.get(x).copy());
|
||||
|
||||
PotionBrewEvent.Pre event = new PotionBrewEvent.Pre(tmp);
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
{
|
||||
boolean changed = false;
|
||||
for (int x = 0; x < stacks.length; x++)
|
||||
for (int x = 0; x < stacks.size(); x++)
|
||||
{
|
||||
changed |= ItemStack.areItemStacksEqual(tmp[x], stacks[x]);
|
||||
stacks[x] = event.getItem(x);
|
||||
changed |= ItemStack.areItemStacksEqual(tmp.get(x), stacks.get(x));
|
||||
stacks.set(x, event.getItem(x));
|
||||
}
|
||||
if (changed)
|
||||
onPotionBrewed(stacks);
|
||||
@@ -515,7 +517,7 @@ public class ForgeEventFactory
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void onPotionBrewed(ItemStack[] brewingItemStacks)
|
||||
public static void onPotionBrewed(NonNullList<ItemStack> brewingItemStacks)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new PotionBrewEvent.Post(brewingItemStacks));
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package net.minecraftforge.event.brewing;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntityBrewingStand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
@@ -29,30 +30,30 @@ import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
|
||||
|
||||
public class PotionBrewEvent extends Event
|
||||
{
|
||||
private ItemStack[] stacks;
|
||||
private NonNullList<ItemStack> stacks;
|
||||
|
||||
protected PotionBrewEvent(ItemStack[] stacks)
|
||||
protected PotionBrewEvent(NonNullList<ItemStack> stacks)
|
||||
{
|
||||
this.stacks = stacks;
|
||||
}
|
||||
|
||||
public ItemStack getItem(int index)
|
||||
{
|
||||
if (index >= stacks.length) return null;
|
||||
return stacks[index];
|
||||
if (index >= stacks.size()) return null;
|
||||
return stacks.get(index);
|
||||
}
|
||||
|
||||
public void setItem(int index, ItemStack stack)
|
||||
{
|
||||
if (index < stacks.length)
|
||||
if (index < stacks.size())
|
||||
{
|
||||
stacks[index] = stack;
|
||||
stacks.set(index, stack);
|
||||
}
|
||||
}
|
||||
|
||||
public int getLength()
|
||||
{
|
||||
return stacks.length;
|
||||
return stacks.size();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +76,7 @@ public class PotionBrewEvent extends Event
|
||||
@Cancelable
|
||||
public static class Pre extends PotionBrewEvent
|
||||
{
|
||||
public Pre(ItemStack[] stacks)
|
||||
public Pre(NonNullList<ItemStack> stacks)
|
||||
{
|
||||
super(stacks);
|
||||
}
|
||||
@@ -96,7 +97,7 @@ public class PotionBrewEvent extends Event
|
||||
**/
|
||||
public static class Post extends PotionBrewEvent
|
||||
{
|
||||
public Post(ItemStack[] stacks)
|
||||
public Post(NonNullList<ItemStack> stacks)
|
||||
{
|
||||
super(stacks);
|
||||
}
|
||||
|
||||
@@ -52,18 +52,16 @@ import net.minecraft.util.EnumHand;
|
||||
public class MinecartInteractEvent extends MinecartEvent
|
||||
{
|
||||
private final EntityPlayer player;
|
||||
private final ItemStack item;
|
||||
private final EnumHand hand;
|
||||
|
||||
public MinecartInteractEvent(EntityMinecart minecart, EntityPlayer player, ItemStack item, EnumHand hand)
|
||||
public MinecartInteractEvent(EntityMinecart minecart, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
super(minecart);
|
||||
this.player = player;
|
||||
this.item = item;
|
||||
this.hand = hand;
|
||||
}
|
||||
|
||||
public EntityPlayer getPlayer() { return player; }
|
||||
public ItemStack getItem() { return item; }
|
||||
public ItemStack getItem() { return player.getHeldItem(hand); }
|
||||
public EnumHand getHand() { return hand; }
|
||||
}
|
||||
@@ -35,6 +35,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static net.minecraftforge.fml.common.eventhandler.Event.Result.DEFAULT;
|
||||
@@ -48,15 +49,13 @@ import static net.minecraftforge.fml.common.eventhandler.Event.Result.DENY;
|
||||
public class PlayerInteractEvent extends PlayerEvent
|
||||
{
|
||||
private final EnumHand hand;
|
||||
private final ItemStack stack;
|
||||
private final BlockPos pos;
|
||||
private final EnumFacing face;
|
||||
|
||||
private PlayerInteractEvent(EntityPlayer player, EnumHand hand, ItemStack stack, BlockPos pos, EnumFacing face)
|
||||
private PlayerInteractEvent(EntityPlayer player, EnumHand hand, BlockPos pos, EnumFacing face)
|
||||
{
|
||||
super(Preconditions.checkNotNull(player, "Null player in PlayerInteractEvent!"));
|
||||
this.hand = Preconditions.checkNotNull(hand, "Null hand in PlayerInteractEvent!");
|
||||
this.stack = stack;
|
||||
this.pos = Preconditions.checkNotNull(pos, "Null position in PlayerInteractEvent!");
|
||||
this.face = face;
|
||||
}
|
||||
@@ -78,9 +77,9 @@ public class PlayerInteractEvent extends PlayerEvent
|
||||
private final Vec3d localPos;
|
||||
private final Entity target;
|
||||
|
||||
public EntityInteractSpecific(EntityPlayer player, EnumHand hand, ItemStack stack, Entity target, Vec3d localPos)
|
||||
public EntityInteractSpecific(EntityPlayer player, EnumHand hand, Entity target, Vec3d localPos)
|
||||
{
|
||||
super(player, hand, stack, new BlockPos(target), null);
|
||||
super(player, hand, new BlockPos(target), null);
|
||||
this.localPos = localPos;
|
||||
this.target = target;
|
||||
}
|
||||
@@ -120,9 +119,9 @@ public class PlayerInteractEvent extends PlayerEvent
|
||||
{
|
||||
private final Entity target;
|
||||
|
||||
public EntityInteract(EntityPlayer player, EnumHand hand, ItemStack stack, Entity target)
|
||||
public EntityInteract(EntityPlayer player, EnumHand hand, Entity target)
|
||||
{
|
||||
super(player, hand, stack, new BlockPos(target), null);
|
||||
super(player, hand, new BlockPos(target), null);
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@@ -147,9 +146,8 @@ public class PlayerInteractEvent extends PlayerEvent
|
||||
private Result useItem = DEFAULT;
|
||||
private final Vec3d hitVec;
|
||||
|
||||
public RightClickBlock(EntityPlayer player, EnumHand hand, ItemStack stack,
|
||||
BlockPos pos, EnumFacing face, Vec3d hitVec) {
|
||||
super(player, hand, stack, pos, face);
|
||||
public RightClickBlock(EntityPlayer player, EnumHand hand, BlockPos pos, EnumFacing face, Vec3d hitVec) {
|
||||
super(player, hand, pos, face);
|
||||
this.hitVec = hitVec;
|
||||
}
|
||||
|
||||
@@ -218,9 +216,9 @@ public class PlayerInteractEvent extends PlayerEvent
|
||||
@Cancelable
|
||||
public static class RightClickItem extends PlayerInteractEvent
|
||||
{
|
||||
public RightClickItem(EntityPlayer player, EnumHand hand, ItemStack stack)
|
||||
public RightClickItem(EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
super(player, hand, stack, new BlockPos(player), null);
|
||||
super(player, hand, new BlockPos(player), null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,7 +231,7 @@ public class PlayerInteractEvent extends PlayerEvent
|
||||
{
|
||||
public RightClickEmpty(EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
super(player, hand, null, new BlockPos(player), null);
|
||||
super(player, hand, new BlockPos(player), null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +256,7 @@ public class PlayerInteractEvent extends PlayerEvent
|
||||
|
||||
public LeftClickBlock(EntityPlayer player, BlockPos pos, EnumFacing face, Vec3d hitVec)
|
||||
{
|
||||
super(player, EnumHand.MAIN_HAND, player.getHeldItem(EnumHand.MAIN_HAND), pos, face);
|
||||
super(player, EnumHand.MAIN_HAND, pos, face);
|
||||
this.hitVec = hitVec;
|
||||
}
|
||||
|
||||
@@ -317,7 +315,7 @@ public class PlayerInteractEvent extends PlayerEvent
|
||||
{
|
||||
public LeftClickEmpty(EntityPlayer player, ItemStack stack)
|
||||
{
|
||||
super(player, EnumHand.MAIN_HAND, stack, new BlockPos(player), null);
|
||||
super(player, EnumHand.MAIN_HAND, new BlockPos(player), null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,10 +330,10 @@ public class PlayerInteractEvent extends PlayerEvent
|
||||
/**
|
||||
* @return The itemstack involved in this interaction, or null if the hand was empty.
|
||||
*/
|
||||
@Nullable
|
||||
@Nonnull
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return stack;
|
||||
return getEntityPlayer().getHeldItem(hand);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -255,11 +255,13 @@ public class BlockEvent extends Event
|
||||
public static class NeighborNotifyEvent extends BlockEvent
|
||||
{
|
||||
private final EnumSet<EnumFacing> notifiedSides;
|
||||
private final boolean forceRedstoneUpdate;
|
||||
|
||||
public NeighborNotifyEvent(World world, BlockPos pos, IBlockState state, EnumSet<EnumFacing> notifiedSides)
|
||||
public NeighborNotifyEvent(World world, BlockPos pos, IBlockState state, EnumSet<EnumFacing> notifiedSides, boolean forceRedstoneUpdate)
|
||||
{
|
||||
super(world, pos, state);
|
||||
this.notifiedSides = notifiedSides;
|
||||
this.forceRedstoneUpdate = forceRedstoneUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -271,6 +273,15 @@ public class BlockEvent extends Event
|
||||
{
|
||||
return notifiedSides;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if redstone update was forced during setBlock call (0x16 to flags)
|
||||
* @return if the flag was set
|
||||
*/
|
||||
public boolean getForceRedstoneUpdate()
|
||||
{
|
||||
return forceRedstoneUpdate;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user