Removed RenderWorldEvent, encapsulated all public event fields.

This commit is contained in:
RainWarrior 2016-03-24 11:44:52 +03:00
parent 08c00662a0
commit 756c58d5cb
110 changed files with 1642 additions and 680 deletions

View File

@ -16,7 +16,7 @@
{
+ net.minecraftforge.event.world.NoteBlockEvent.Play e = new net.minecraftforge.event.world.NoteBlockEvent.Play(p_180648_1_, p_180648_2_, p_180648_3_, p_180648_5_, p_180648_4_);
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(e)) return false;
+ p_180648_4_ = e.instrument.ordinal();
+ p_180648_4_ = e.getInstrument().ordinal();
+ p_180648_5_ = e.getVanillaNoteId();
float f = (float)Math.pow(2.0D, (double)(p_180648_5_ - 12) / 12.0D);
p_180648_1_.func_184133_a((EntityPlayer)null, p_180648_2_, this.func_185576_e(p_180648_4_), SoundCategory.BLOCKS, 3.0F, f);

View File

@ -133,7 +133,7 @@
+
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return;
+
+ p_147108_1_ = event.gui;
+ p_147108_1_ = event.getGui();
+ if (old != null && p_147108_1_ != old)
+ {
+ old.func_146281_b();

View File

@ -55,12 +55,12 @@
+ net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Pre event = new net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Pre(this, guibutton, this.field_146292_n);
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event))
+ break;
+ guibutton = event.button;
+ guibutton = event.getButton();
this.field_146290_a = guibutton;
guibutton.func_146113_a(this.field_146297_k.func_147118_V());
this.func_146284_a(guibutton);
+ if (this.equals(this.field_146297_k.field_71462_r))
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Post(this, event.button, this.field_146292_n));
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Post(this, event.getButton(), this.field_146292_n));
}
}
}

View File

@ -64,9 +64,9 @@
+ IBlockState state = ActiveRenderInfo.func_186703_a(this.field_78531_r.field_71441_e, entity, p_78467_1_);
+ net.minecraftforge.client.event.EntityViewRenderEvent.CameraSetup event = new net.minecraftforge.client.event.EntityViewRenderEvent.CameraSetup(this, entity, state, p_78467_1_, yaw, pitch, roll);
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
+ GlStateManager.func_179114_b(event.roll, 0.0F, 0.0F, 1.0F);
+ GlStateManager.func_179114_b(event.pitch, 1.0F, 0.0F, 0.0F);
+ GlStateManager.func_179114_b(event.yaw, 0.0F, 1.0F, 0.0F);
+ GlStateManager.func_179114_b(event.getRoll(), 0.0F, 0.0F, 1.0F);
+ GlStateManager.func_179114_b(event.getPitch(), 1.0F, 0.0F, 0.0F);
+ GlStateManager.func_179114_b(event.getYaw(), 0.0F, 1.0F, 0.0F);
}
GlStateManager.func_179109_b(0.0F, -f, 0.0F);
@ -163,9 +163,9 @@
+ net.minecraftforge.client.event.EntityViewRenderEvent.FogColors event = new net.minecraftforge.client.event.EntityViewRenderEvent.FogColors(this, entity, iblockstate, p_78466_1_, this.field_175080_Q, this.field_175082_R, this.field_175081_S);
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
+
+ this.field_175080_Q = event.red;
+ this.field_175082_R = event.green;
+ this.field_175081_S = event.blue;
+ this.field_175080_Q = event.getRed();
+ this.field_175082_R = event.getGreen();
+ this.field_175081_S = event.getBlue();
+
GlStateManager.func_179082_a(this.field_175080_Q, this.field_175082_R, this.field_175081_S, 0.0F);
}

View File

@ -1,10 +0,0 @@
--- ../src-base/minecraft/net/minecraft/client/resources/LanguageManager.java
+++ ../src-work/minecraft/net/minecraft/client/resources/LanguageManager.java
@@ -73,6 +73,7 @@
}
field_135049_a.func_135022_a(p_110549_1_, list);
+ net.minecraftforge.fml.common.registry.LanguageRegistry.instance().mergeLanguageTable(field_135049_a.field_135032_a, this.field_135048_c);
LanguageMap.func_135063_a(field_135049_a.field_135032_a);
}

View File

@ -7,9 +7,9 @@
+ net.minecraftforge.event.CommandEvent event = new net.minecraftforge.event.CommandEvent(icommand, p_71556_1_, astring);
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event))
+ {
+ if (event.exception != null)
+ if (event.getException() != null)
+ {
+ com.google.common.base.Throwables.propagateIfPossible(event.exception);
+ com.google.common.base.Throwables.propagateIfPossible(event.getException());
+ }
+ return 1;
+ }

View File

@ -15,10 +15,10 @@
}
- entitylivingbase.func_70634_a(this.field_70165_t, this.field_70163_u, this.field_70161_v);
+ entitylivingbase.func_70634_a(event.targetX, event.targetY, event.targetZ);
+ entitylivingbase.func_70634_a(event.getTargetX(), event.getTargetY(), event.getTargetZ());
entitylivingbase.field_70143_R = 0.0F;
- entitylivingbase.func_70097_a(DamageSource.field_76379_h, 5.0F);
+ entitylivingbase.func_70097_a(DamageSource.field_76379_h, event.attackDamage);
+ entitylivingbase.func_70097_a(DamageSource.field_76379_h, event.getAttackDamage());
+ }
}
}

View File

@ -7,7 +7,7 @@
- boolean flag = this.func_184595_k(p_70825_1_, p_70825_3_, p_70825_5_);
+ net.minecraftforge.event.entity.living.EnderTeleportEvent event = new net.minecraftforge.event.entity.living.EnderTeleportEvent(this, p_70825_1_, p_70825_3_, p_70825_5_, 0);
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return false;
+ boolean flag = this.func_184595_k(event.targetX, event.targetY, event.targetZ);
+ boolean flag = this.func_184595_k(event.getTargetX(), event.getTargetY(), event.getTargetZ());
if (flag)
{

View File

@ -28,9 +28,9 @@
- int k = MathHelper.func_76128_c(this.field_70161_v);
- EntityZombie entityzombie = new EntityZombie(this.field_70170_p);
+ EntityZombie entityzombie;
+ if (summonAid.customSummonedAid != null && summonAid.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW)
+ if (summonAid.getCustomSummonedAid() != null && summonAid.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW)
+ {
+ entityzombie = summonAid.customSummonedAid;
+ entityzombie = summonAid.getCustomSummonedAid();
+ }
+ else
+ {

View File

@ -63,7 +63,7 @@
+ if (!iblockstate.func_177230_c().isAir(iblockstate, field_73092_a, p_180784_1_))
{
- block.func_180649_a(this.field_73092_a, p_180784_1_, this.field_73090_b);
+ if (event.useBlock != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY)
+ if (event.getUseBlock() != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY)
+ {
+ block.func_180649_a(this.field_73092_a, p_180784_1_, this.field_73090_b);
+ this.field_73092_a.func_175719_a((EntityPlayer)null, p_180784_1_, p_180784_2_);
@ -74,7 +74,7 @@
+ }
f = iblockstate.func_185903_a(this.field_73090_b, this.field_73090_b.field_70170_p, p_180784_1_);
}
+ if (event.useItem == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY)
+ if (event.getUseItem() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY)
+ {
+ if (f >= 1.0F)
+ {

View File

@ -57,21 +57,21 @@
+ {
+ net.minecraftforge.event.terraingen.BiomeEvent.GetWaterColor event = new net.minecraftforge.event.terraingen.BiomeEvent.GetWaterColor(this, field_76759_H);
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
+ return event.newColor;
+ return event.getNewColor();
+ }
+
+ public int getModdedBiomeGrassColor(int original)
+ {
+ net.minecraftforge.event.terraingen.BiomeEvent.GetGrassColor event = new net.minecraftforge.event.terraingen.BiomeEvent.GetGrassColor(this, original);
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
+ return event.newColor;
+ return event.getNewColor();
+ }
+
+ public int getModdedBiomeFoliageColor(int original)
+ {
+ net.minecraftforge.event.terraingen.BiomeEvent.GetFoliageColor event = new net.minecraftforge.event.terraingen.BiomeEvent.GetFoliageColor(this, original);
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
+ return event.newColor;
+ return event.getNewColor();
+ }
+
+ /**

View File

@ -33,6 +33,6 @@
+ {
+ net.minecraftforge.event.terraingen.WorldTypeEvent.InitBiomeGens event = new net.minecraftforge.event.terraingen.WorldTypeEvent.InitBiomeGens(worldType, seed, original);
+ net.minecraftforge.common.MinecraftForge.TERRAIN_GEN_BUS.post(event);
+ return event.newBiomeGens;
+ return event.getNewBiomeGens();
+ }
}

View File

@ -49,7 +49,7 @@
{
+ net.minecraftforge.event.terraingen.ChunkGeneratorEvent.InitNoiseField event = new net.minecraftforge.event.terraingen.ChunkGeneratorEvent.InitNoiseField(this, p_185963_1_, p_185963_2_, p_185963_3_, p_185963_4_, p_185963_5_, p_185963_6_, p_185963_7_);
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
+ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return event.noisefield;
+ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return event.getNoisefield();
+
if (p_185963_1_ == null)
{

View File

@ -34,7 +34,7 @@
+ net.minecraftforge.event.terraingen.ChunkGeneratorEvent.InitNoiseField event = new net.minecraftforge.event.terraingen.ChunkGeneratorEvent.InitNoiseField(this, p_185938_1_, p_185938_2_, p_185938_3_, p_185938_4_, p_185938_5_, p_185938_6_, p_185938_7_);
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
+ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return event.noisefield;
+ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return event.getNoisefield();
+
double d0 = 684.412D;
double d1 = 2053.236D;

View File

@ -50,7 +50,7 @@
+ {
+ net.minecraftforge.event.terraingen.WorldTypeEvent.BiomeSize event = new net.minecraftforge.event.terraingen.WorldTypeEvent.BiomeSize(worldType, original);
+ net.minecraftforge.common.MinecraftForge.TERRAIN_GEN_BUS.post(event);
+ return event.newSize;
+ return event.getNewSize();
+ }
+ /* ========================================= FORGE END ======================================*/
}

View File

@ -57,7 +57,7 @@
{
+ net.minecraftforge.event.terraingen.BiomeEvent.GetVillageBlockID event = new net.minecraftforge.event.terraingen.BiomeEvent.GetVillageBlockID(startPiece == null ? null : startPiece.biome, p_175847_1_);
+ net.minecraftforge.common.MinecraftForge.TERRAIN_GEN_BUS.post(event);
+ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return event.replacement;
+ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return event.getReplacement();
if (this.field_143014_b)
{
if (p_175847_1_.func_177230_c() == Blocks.field_150364_r || p_175847_1_.func_177230_c() == Blocks.field_150363_s)

View File

@ -63,9 +63,9 @@ public class ClientCommandHandler extends CommandHandler
CommandEvent event = new CommandEvent(icommand, sender, args);
if (MinecraftForge.EVENT_BUS.post(event))
{
if (event.exception != null)
if (event.getException() != null)
{
throw event.exception;
throw event.getException();
}
return 0;
}

View File

@ -196,7 +196,7 @@ public class ForgeHooksClient
{
FOVUpdateEvent fovUpdateEvent = new FOVUpdateEvent(entity, fov);
MinecraftForge.EVENT_BUS.post(fovUpdateEvent);
return fovUpdateEvent.newfov;
return fovUpdateEvent.getNewfov();
}
public static float getFOVModifier(EntityRenderer renderer, Entity entity, IBlockState state, double renderPartialTicks, float fov) {
@ -295,7 +295,7 @@ public class ForgeHooksClient
{
PlaySoundEvent e = new PlaySoundEvent(manager, sound);
MinecraftForge.EVENT_BUS.post(e);
return e.result;
return e.getResultSound();
}
//static RenderBlocks VertexBufferRB;
@ -316,7 +316,7 @@ public class ForgeHooksClient
public static float getFogDensity(EntityRenderer renderer, Entity entity, IBlockState state, float partial, float density)
{
EntityViewRenderEvent.FogDensity event = new EntityViewRenderEvent.FogDensity(renderer, entity, state, partial, density);
if (MinecraftForge.EVENT_BUS.post(event)) return event.density;
if (MinecraftForge.EVENT_BUS.post(event)) return event.getDensity();
return -1;
}
@ -325,31 +325,6 @@ public class ForgeHooksClient
MinecraftForge.EVENT_BUS.post(new EntityViewRenderEvent.RenderFogEvent(renderer, entity, state, partial, mode, distance));
}
/*
public static void setVertexBufferRB(RenderBlocks renderBlocks)
{
VertexBufferRB = renderBlocks;
}
public static void onPreRenderWorld(VertexBuffer VertexBuffer, int pass)
{
if(VertexBufferRB != null)
{
worldRenderPass = pass;
MinecraftForge.EVENT_BUS.post(new RenderWorldEvent.Pre(VertexBuffer, (ChunkCache)VertexBufferRB.blockAccess, VertexBufferRB, pass));
}
}
public static void onPostRenderWorld(VertexBuffer VertexBuffer, int pass)
{
if(VertexBufferRB != null)
{
MinecraftForge.EVENT_BUS.post(new RenderWorldEvent.Post(VertexBuffer, (ChunkCache)VertexBufferRB.blockAccess, VertexBufferRB, pass));
worldRenderPass = -1;
}
}
*/
public static void onModelBake(ModelManager modelManager, IRegistry<ModelResourceLocation, IBakedModel> modelRegistry, ModelLoader modelLoader)
{
MinecraftForge.EVENT_BUS.post(new ModelBakeEvent(modelManager, modelRegistry, modelLoader));

View File

@ -779,7 +779,7 @@ public class GuiIngameForge extends GuiIngame
if (MinecraftForge.EVENT_BUS.post(event)) return;
GlStateManager.pushMatrix();
GlStateManager.translate((float)event.posX, (float)event.posY, 0.0F);
GlStateManager.translate((float) event.getPosX(), (float) event.getPosY(), 0.0F);
persistantChatGUI.drawChat(updateCounter);
GlStateManager.popMatrix();

View File

@ -7,17 +7,32 @@ import net.minecraftforge.fml.common.eventhandler.Event;
@Cancelable
public class ClientChatReceivedEvent extends Event
{
public ITextComponent message;
private ITextComponent message;
private final byte type;
public ClientChatReceivedEvent(byte type, ITextComponent message)
{
this.type = type;
this.setMessage(message);
}
public ITextComponent getMessage()
{
return message;
}
public void setMessage(ITextComponent message)
{
this.message = message;
}
/**
* Introduced in 1.8:
* 0 : Standard Text Message
* 1 : 'System' message, displayed as standard text.
* 2 : 'Status' message, displayed above action bar, where song notifications are.
*/
public final byte type;
public ClientChatReceivedEvent(byte type, ITextComponent message)
public byte getType()
{
this.type = type;
this.message = message;
return type;
}
}

View File

@ -9,11 +9,11 @@ import net.minecraft.client.renderer.RenderGlobal;
@Cancelable
public class DrawBlockHighlightEvent extends Event
{
public final RenderGlobal context;
public final EntityPlayer player;
public final RayTraceResult target;
public final int subID;
public final float partialTicks;
private final RenderGlobal context;
private final EntityPlayer player;
private final RayTraceResult target;
private final int subID;
private final float partialTicks;
public DrawBlockHighlightEvent(RenderGlobal context, EntityPlayer player, RayTraceResult target, int subID, float partialTicks)
{
@ -24,4 +24,9 @@ public class DrawBlockHighlightEvent extends Event
this.partialTicks= partialTicks;
}
public RenderGlobal getContext() { return context; }
public EntityPlayer getPlayer() { return player; }
public RayTraceResult getTarget() { return target; }
public int getSubID() { return subID; }
public float getPartialTicks() { return partialTicks; }
}

View File

@ -52,11 +52,21 @@ public abstract class EntityViewRenderEvent extends Event
@Cancelable
public static class FogDensity extends EntityViewRenderEvent
{
public float density;
private float density;
public FogDensity(EntityRenderer renderer, Entity entity, IBlockState state, double renderPartialTicks, float density)
{
super(renderer, entity, state, renderPartialTicks);
this.setDensity(density);
}
public float getDensity()
{
return density;
}
public void setDensity(float density)
{
this.density = density;
}
}
@ -67,8 +77,8 @@ public abstract class EntityViewRenderEvent extends Event
@HasResult
public static class RenderFogEvent extends EntityViewRenderEvent
{
public final int fogMode;
public final float farPlaneDistance;
private final int fogMode;
private final float farPlaneDistance;
public RenderFogEvent(EntityRenderer renderer, Entity entity, IBlockState state, double renderPartialTicks, int fogMode, float farPlaneDistance)
{
@ -76,6 +86,16 @@ public abstract class EntityViewRenderEvent extends Event
this.fogMode = fogMode;
this.farPlaneDistance = farPlaneDistance;
}
public int getFogMode()
{
return fogMode;
}
public float getFarPlaneDistance()
{
return farPlaneDistance;
}
}
/**
@ -84,17 +104,24 @@ public abstract class EntityViewRenderEvent extends Event
*/
public static class FogColors extends EntityViewRenderEvent
{
public float red;
public float green;
public float blue;
private float red;
private float green;
private float blue;
public FogColors(EntityRenderer renderer, Entity entity, IBlockState state, double renderPartialTicks, float red, float green, float blue)
{
super(renderer, entity, state, renderPartialTicks);
this.red = red;
this.green = green;
this.blue = blue;
this.setRed(red);
this.setGreen(green);
this.setBlue(blue);
}
public float getRed() { return red; }
public void setRed(float red) { this.red = red; }
public float getGreen() { return green; }
public void setGreen(float green) { this.green = green; }
public float getBlue() { return blue; }
public void setBlue(float blue) { this.blue = blue; }
}
/**
@ -102,17 +129,24 @@ public abstract class EntityViewRenderEvent extends Event
*/
public static class CameraSetup extends EntityViewRenderEvent
{
public float yaw;
public float pitch;
public float roll;
private float yaw;
private float pitch;
private float roll;
public CameraSetup(EntityRenderer renderer, Entity entity, IBlockState state, double renderPartialTicks, float yaw, float pitch, float roll)
{
super(renderer, entity, state, renderPartialTicks);
this.yaw = yaw;
this.pitch = pitch;
this.roll = roll;
this.setYaw(yaw);
this.setPitch(pitch);
this.setRoll(roll);
}
public float getYaw() { return yaw; }
public void setYaw(float yaw) { this.yaw = yaw; }
public float getPitch() { return pitch; }
public void setPitch(float pitch) { this.pitch = pitch; }
public float getRoll() { return roll; }
public void setRoll(float roll) { this.roll = roll; }
}
/**

View File

@ -9,14 +9,34 @@ import net.minecraftforge.fml.common.eventhandler.Event;
*/
public class FOVUpdateEvent extends Event
{
public final EntityPlayer entity;
public final float fov;
public float newfov;
private final EntityPlayer entity;
private final float fov;
private float newfov;
public FOVUpdateEvent(EntityPlayer entity, float fov)
{
this.entity = entity;
this.fov = fov;
this.newfov = fov;
this.setNewfov(fov);
}
public EntityPlayer getEntity()
{
return entity;
}
public float getFov()
{
return fov;
}
public float getNewfov()
{
return newfov;
}
public void setNewfov(float newfov)
{
this.newfov = newfov;
}
}

View File

@ -14,8 +14,18 @@ import net.minecraft.client.gui.GuiScreen;
@Cancelable
public class GuiOpenEvent extends Event
{
public GuiScreen gui;
private GuiScreen gui;
public GuiOpenEvent(GuiScreen gui)
{
this.setGui(gui);
}
public GuiScreen getGui()
{
return gui;
}
public void setGui(GuiScreen gui)
{
this.gui = gui;
}

View File

@ -22,29 +22,44 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiScreenEvent extends Event
{
/**
* The GuiScreen object generating this event.
*/
public final GuiScreen gui;
private final GuiScreen gui;
public GuiScreenEvent(GuiScreen gui)
{
this.gui = gui;
}
/**
* The GuiScreen object generating this event.
*/
public GuiScreen getGui()
{
return gui;
}
public static class InitGuiEvent extends GuiScreenEvent
{
/**
* The {@code buttonList} field from the GuiScreen object referenced by {@code gui}.
*/
public List<GuiButton> buttonList;
private List<GuiButton> buttonList;
public InitGuiEvent(GuiScreen gui, List<GuiButton> buttonList)
{
super(gui);
this.setButtonList(buttonList);
}
/**
* The {@code buttonList} field from the GuiScreen object referenced by {@code gui}.
*/
public List<GuiButton> getButtonList()
{
return buttonList;
}
public void setButtonList(List<GuiButton> buttonList)
{
this.buttonList = buttonList;
}
/**
* This event fires just after initializing {@code GuiScreen.mc}, {@code GuiScreen.fontRendererObj},
* {@code GuiScreen.width}, and {@code GuiScreen.height}, and just before calling {@code GuiScreen.buttonList.clear()}
@ -78,18 +93,9 @@ public class GuiScreenEvent extends Event
public static class DrawScreenEvent extends GuiScreenEvent
{
/**
* The x coordinate of the mouse pointer on the screen.
*/
public final int mouseX;
/**
* The y coordinate of the mouse pointer on the screen.
*/
public final int mouseY;
/**
* Partial render ticks elapsed.
*/
public final float renderPartialTicks;
private final int mouseX;
private final int mouseY;
private final float renderPartialTicks;
public DrawScreenEvent(GuiScreen gui, int mouseX, int mouseY, float renderPartialTicks)
{
@ -98,7 +104,31 @@ public class GuiScreenEvent extends Event
this.mouseY = mouseY;
this.renderPartialTicks = renderPartialTicks;
}
/**
* The x coordinate of the mouse pointer on the screen.
*/
public int getMouseX()
{
return mouseX;
}
/**
* The y coordinate of the mouse pointer on the screen.
*/
public int getMouseY()
{
return mouseY;
}
/**
* Partial render ticks elapsed.
*/
public float getRenderPartialTicks()
{
return renderPartialTicks;
}
/**
* This event fires just before {@code GuiScreen.drawScreen()} is called.
* Cancel this event to skip {@code GuiScreen.drawScreen()}.
@ -162,22 +192,42 @@ public class GuiScreenEvent extends Event
public static class ActionPerformedEvent extends GuiScreenEvent
{
/**
* The button that was clicked.
*/
public GuiButton button;
/**
* A COPY of the {@code buttonList} field from the GuiScreen referenced by {@code gui}.
*/
public List<GuiButton> buttonList;
private GuiButton button;
private List<GuiButton> buttonList;
public ActionPerformedEvent(GuiScreen gui, GuiButton button, List<GuiButton> buttonList)
{
super(gui);
this.button = button;
this.buttonList = new ArrayList<GuiButton>(buttonList);
this.setButton(button);
this.setButtonList(new ArrayList<GuiButton>(buttonList));
}
/**
* The button that was clicked.
*/
public GuiButton getButton()
{
return button;
}
public void setButton(GuiButton button)
{
this.button = button;
}
/**
* A COPY of the {@code buttonList} field from the GuiScreen referenced by {@code gui}.
*/
public List<GuiButton> getButtonList()
{
return buttonList;
}
public void setButtonList(List<GuiButton> buttonList)
{
this.buttonList = buttonList;
}
/**
* This event fires once it has been determined that a GuiButton object has been clicked.
* Cancel this event to bypass {@code GuiScreen.actionPerformed()}.

View File

@ -12,14 +12,14 @@ import net.minecraftforge.fml.common.eventhandler.Event;
@Cancelable
public class MouseEvent extends Event
{
public final int x;
public final int y;
public final int dx;
public final int dy;
public final int dwheel;
public final int button;
public final boolean buttonstate;
public final long nanoseconds;
private final int x;
private final int y;
private final int dx;
private final int dy;
private final int dwheel;
private final int button;
private final boolean buttonstate;
private final long nanoseconds;
public MouseEvent()
{
@ -32,4 +32,13 @@ public class MouseEvent extends Event
this.buttonstate = Mouse.getEventButtonState();
this.nanoseconds = Mouse.getEventNanoseconds();
}
public int getX() { return x; }
public int getY() { return y; }
public int getDx() { return dx; }
public int getDy() { return dy; }
public int getDwheel() { return dwheel; }
public int getButton() { return button; }
public boolean isButtonstate() { return buttonstate; }
public long getNanoseconds() { return nanoseconds; }
}

View File

@ -12,25 +12,16 @@ import net.minecraftforge.fml.common.eventhandler.Event;
*/
@Cancelable
public class RenderBlockOverlayEvent extends Event {
public static enum OverlayType {
FIRE, BLOCK, WATER
}
/**
* The player which the overlay will apply to
*/
public final EntityPlayer player;
public final float renderPartialTicks;
/**
* The type of overlay to occur
*/
public final OverlayType overlayType;
/**
* If the overlay type is BLOCK, then this is the block which the overlay is getting it's icon from
*/
public final IBlockState blockForOverlay;
public final BlockPos blockPos;
private final EntityPlayer player;
private final float renderPartialTicks;
private final OverlayType overlayType;
private final IBlockState blockForOverlay;
private final BlockPos blockPos;
@Deprecated
public RenderBlockOverlayEvent(EntityPlayer player, float renderPartialTicks, OverlayType type, Block block, int x, int y, int z)
@ -48,4 +39,18 @@ public class RenderBlockOverlayEvent extends Event {
}
/**
* The player which the overlay will apply to
*/
public EntityPlayer getPlayer() { return player; }
public float getRenderPartialTicks() { return renderPartialTicks; }
/**
* The type of overlay to occur
*/
public OverlayType getOverlayType() { return overlayType; }
/**
* If the overlay type is BLOCK, then this is the block which the overlay is getting it's icon from
*/
public IBlockState getBlockForOverlay() { return blockForOverlay; }
public BlockPos getBlockPos() { return blockPos; }
}

View File

@ -10,6 +10,21 @@ import net.minecraft.client.gui.ScaledResolution;
@Cancelable
public class RenderGameOverlayEvent extends Event
{
public float getPartialTicks()
{
return partialTicks;
}
public ScaledResolution getResolution()
{
return resolution;
}
public ElementType getType()
{
return type;
}
public static enum ElementType
{
ALL,
@ -33,9 +48,9 @@ public class RenderGameOverlayEvent extends Event
SUBTITLES
}
public final float partialTicks;
public final ScaledResolution resolution;
public final ElementType type;
private final float partialTicks;
private final ScaledResolution resolution;
private final ElementType type;
public RenderGameOverlayEvent(float partialTicks, ScaledResolution resolution)
{
@ -46,8 +61,8 @@ public class RenderGameOverlayEvent extends Event
private RenderGameOverlayEvent(RenderGameOverlayEvent parent, ElementType type)
{
this.partialTicks = parent.partialTicks;
this.resolution = parent.resolution;
this.partialTicks = parent.getPartialTicks();
this.resolution = parent.getResolution();
this.type = type;
}
@ -70,25 +85,55 @@ public class RenderGameOverlayEvent extends Event
public static class Text extends Pre
{
public final ArrayList<String> left;
public final ArrayList<String> right;
private final ArrayList<String> left;
private final ArrayList<String> right;
public Text(RenderGameOverlayEvent parent, ArrayList<String> left, ArrayList<String> right)
{
super(parent, ElementType.TEXT);
this.left = left;
this.right = right;
}
public ArrayList<String> getLeft()
{
return left;
}
public ArrayList<String> getRight()
{
return right;
}
}
public static class Chat extends Pre
{
public int posX;
public int posY;
private int posX;
private int posY;
public Chat(RenderGameOverlayEvent parent, int posX, int posY)
{
super(parent, ElementType.CHAT);
this.setPosX(posX);
this.setPosY(posY);
}
public int getPosX()
{
return posX;
}
public void setPosX(int posX)
{
this.posX = posX;
}
public int getPosY()
{
return posY;
}
public void setPosY(int posY)
{
this.posY = posY;
}
}

View File

@ -7,13 +7,28 @@ import net.minecraft.client.renderer.RenderGlobal;
@Cancelable
public class RenderHandEvent extends Event
{
public final RenderGlobal context;
public final float partialTicks;
public final int renderPass;
private final RenderGlobal context;
private final float partialTicks;
private final int renderPass;
public RenderHandEvent(RenderGlobal context, float partialTicks, int renderPass)
{
this.context = context;
this.partialTicks = partialTicks;
this.renderPass = renderPass;
}
public RenderGlobal getContext()
{
return context;
}
public float getPartialTicks()
{
return partialTicks;
}
public int getRenderPass()
{
return renderPass;
}
}

View File

@ -14,9 +14,9 @@ import net.minecraftforge.fml.common.eventhandler.Event;
@Cancelable
public class RenderItemInFrameEvent extends Event
{
public final ItemStack item;
public final EntityItemFrame entityItemFrame;
public final RenderItemFrame renderer;
private final ItemStack item;
private final EntityItemFrame entityItemFrame;
private final RenderItemFrame renderer;
public RenderItemInFrameEvent(EntityItemFrame itemFrame, RenderItemFrame renderItemFrame)
{
@ -24,4 +24,19 @@ public class RenderItemInFrameEvent extends Event
entityItemFrame = itemFrame;
renderer = renderItemFrame;
}
public ItemStack getItem()
{
return item;
}
public EntityItemFrame getEntityItemFrame()
{
return entityItemFrame;
}
public RenderItemFrame getRenderer()
{
return renderer;
}
}

View File

@ -7,11 +7,11 @@ import net.minecraft.entity.EntityLivingBase;
public abstract class RenderLivingEvent<T extends EntityLivingBase> extends Event
{
public final EntityLivingBase entity;
public final RenderLivingBase<T> renderer;
public final double x;
public final double y;
public final double z;
private final EntityLivingBase entity;
private final RenderLivingBase<T> renderer;
private final double x;
private final double y;
private final double z;
public RenderLivingEvent(EntityLivingBase entity, RenderLivingBase<T> renderer, double x, double y, double z)
{
@ -21,7 +21,13 @@ public abstract class RenderLivingEvent<T extends EntityLivingBase> extends Even
this.y = y;
this.z = z;
}
public EntityLivingBase getEntity() { return entity; }
public RenderLivingBase<T> getRenderer() { return renderer; }
public double getX() { return x; }
public double getY() { return y; }
public double getZ() { return z; }
@Cancelable
public static class Pre<T extends EntityLivingBase> extends RenderLivingEvent<T>
{

View File

@ -8,11 +8,11 @@ import net.minecraftforge.event.entity.player.PlayerEvent;
public abstract class RenderPlayerEvent extends PlayerEvent
{
public final RenderPlayer renderer;
public final float partialRenderTick;
public final double x;
public final double y;
public final double z;
private final RenderPlayer renderer;
private final float partialRenderTick;
private final double x;
private final double y;
private final double z;
public RenderPlayerEvent(EntityPlayer player, RenderPlayer renderer, float partialRenderTick, double x, double y, double z)
{
@ -24,6 +24,12 @@ public abstract class RenderPlayerEvent extends PlayerEvent
this.z = z;
}
public RenderPlayer getRenderer() { return renderer; }
public float getPartialRenderTick() { return partialRenderTick; }
public double getX() { return x; }
public double getY() { return y; }
public double getZ() { return z; }
@Cancelable
public static class Pre extends RenderPlayerEvent
{
@ -50,10 +56,17 @@ public abstract class RenderPlayerEvent extends PlayerEvent
@Cancelable
public static class Pre extends Specials
{
public boolean renderHelmet = true;
public boolean renderCape = true;
public boolean renderItem = true;
private boolean renderHelmet = true;
private boolean renderCape = true;
private boolean renderItem = true;
public Pre(EntityPlayer player, RenderPlayer renderer, float partialTicks){ super(player, renderer, partialTicks); }
public boolean shouldRenderHelmet() { return renderHelmet; }
public void setRenderHelmet(boolean renderHelmet) { this.renderHelmet = renderHelmet; }
public boolean shouldRenderCape() { return renderCape; }
public void setRenderCape(boolean renderCape) { this.renderCape = renderCape; }
public boolean shouldRenderItem() { return renderItem; }
public void setRenderItem(boolean renderItem) { this.renderItem = renderItem; }
}
public static class Post extends Specials
@ -65,18 +78,38 @@ public abstract class RenderPlayerEvent extends PlayerEvent
@Deprecated
public static class SetArmorModel extends RenderPlayerEvent
{
/**
* Setting this to any value besides -1 will result in the function being
* Immediately exited with the return value specified.
*/
public int result = -1;
public final int slot;
public final ItemStack stack;
private int result = -1;
private final int slot;
private final ItemStack stack;
public SetArmorModel(EntityPlayer player, RenderPlayer renderer, int slot, float partialTick, ItemStack stack)
{
super(player, renderer, partialTick, 0D, 0D, 0D);
this.slot = slot;
this.stack = stack;
}
/**
* Setting this to any value besides -1 will result in the function being
* Immediately exited with the return value specified.
*/
public int getResultValue()
{
return result;
}
public void setResult(int result)
{
this.result = result;
}
public int getSlot()
{
return slot;
}
public ItemStack getStack()
{
return stack;
}
}
}

View File

@ -1,39 +0,0 @@
package net.minecraftforge.client.event;
import net.minecraftforge.fml.common.eventhandler.Event;
//import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.world.ChunkCache;
public abstract class RenderWorldEvent extends Event
{
public final VertexBuffer renderer;
public final ChunkCache chunkCache;
//public final RenderBlocks renderBlocks;
public final int pass;
public RenderWorldEvent(VertexBuffer renderer, ChunkCache chunkCache, /*RenderBlocks renderBlocks,*/ int pass)
{
this.renderer = renderer;
this.chunkCache = chunkCache;
//this.renderBlocks = renderBlocks;
this.pass = pass;
}
/**
* Fired when 16x16x16 chunk area is being redrawn.
* Fired after GL state is setup, before tessellator is started.
*/
public static class Pre extends RenderWorldEvent
{
public Pre(VertexBuffer renderer, ChunkCache chunkCache, /*RenderBlocks renderBlocks,*/ int pass){ super(renderer, chunkCache, /*renderBlocks,*/ pass); }
}
/**
* Fired after the tessellator is stopped, before the display list is ended.
*/
public static class Post extends RenderWorldEvent
{
public Post(VertexBuffer renderer, ChunkCache chunkCache, /*RenderBlocks renderBlocks,*/ int pass){ super(renderer, chunkCache, /*renderBlocks,*/ pass); }
}
}

View File

@ -5,11 +5,21 @@ import net.minecraft.client.renderer.RenderGlobal;
public class RenderWorldLastEvent extends Event
{
public final RenderGlobal context;
public final float partialTicks;
private final RenderGlobal context;
private final float partialTicks;
public RenderWorldLastEvent(RenderGlobal context, float partialTicks)
{
this.context = context;
this.partialTicks = partialTicks;
}
public RenderGlobal getContext()
{
return context;
}
public float getPartialTicks()
{
return partialTicks;
}
}

View File

@ -6,13 +6,18 @@ import net.minecraft.client.renderer.texture.TextureMap;
public class TextureStitchEvent extends Event
{
public final TextureMap map;
private final TextureMap map;
public TextureStitchEvent(TextureMap map)
{
this.map = map;
}
public TextureMap getMap()
{
return map;
}
/**
* Fired when the TextureMap is told to refresh it's stitched texture.
* Called after the Stitched list is cleared, but before any blocks or items

View File

@ -11,15 +11,35 @@ import net.minecraft.client.audio.SoundManager;
*/
public class PlaySoundEvent extends SoundEvent
{
public final String name;
public final ISound sound;
public ISound result;
private final String name;
private final ISound sound;
private ISound result;
public PlaySoundEvent(SoundManager manager, ISound sound)
{
super(manager);
this.sound = sound;
this.name = sound.getSoundLocation().getResourcePath();
this.result = sound;
this.setResultSound(sound);
}
public String getName()
{
return name;
}
public ISound getSound()
{
return sound;
}
public ISound getResultSound()
{
return result;
}
public void setResultSound(ISound result)
{
this.result = result;
}
}

View File

@ -6,12 +6,17 @@ import net.minecraft.client.audio.SoundManager;
public class SoundEvent extends Event
{
public final SoundManager manager;
private final SoundManager manager;
public SoundEvent(SoundManager manager)
{
this.manager = manager;
}
public SoundManager getManager()
{
return manager;
}
public static class SoundSourceEvent extends SoundEvent
{
public final ISound sound;

View File

@ -370,25 +370,45 @@ public class ForgeChunkManager
}
public static class ForceChunkEvent extends Event {
public final Ticket ticket;
public final ChunkCoordIntPair location;
private final Ticket ticket;
private final ChunkCoordIntPair location;
public ForceChunkEvent(Ticket ticket, ChunkCoordIntPair location)
{
this.ticket = ticket;
this.location = location;
}
public Ticket getTicket()
{
return ticket;
}
public ChunkCoordIntPair getLocation()
{
return location;
}
}
public static class UnforceChunkEvent extends Event {
public final Ticket ticket;
public final ChunkCoordIntPair location;
private final Ticket ticket;
private final ChunkCoordIntPair location;
public UnforceChunkEvent(Ticket ticket, ChunkCoordIntPair location)
{
this.ticket = ticket;
this.location = location;
}
public Ticket getTicket()
{
return ticket;
}
public ChunkCoordIntPair getLocation()
{
return location;
}
}

View File

@ -56,7 +56,6 @@ import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.WeightedRandom;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
@ -483,7 +482,7 @@ public class ForgeHooks
public static float[] onLivingFall(EntityLivingBase entity, float distance, float damageMultiplier)
{
LivingFallEvent event = new LivingFallEvent(entity, distance, damageMultiplier);
return (MinecraftForge.EVENT_BUS.post(event) ? null : new float[]{event.distance, event.damageMultiplier});
return (MinecraftForge.EVENT_BUS.post(event) ? null : new float[]{event.getDistance(), event.getDamageMultiplier()});
}
public static boolean isLivingOnLadder(IBlockState state, World world, BlockPos pos, EntityLivingBase entity)
@ -544,9 +543,9 @@ public class ForgeHooks
if (!player.worldObj.isRemote)
{
player.getEntityWorld().spawnEntityInWorld(event.entityItem);
player.getEntityWorld().spawnEntityInWorld(event.getEntityItem());
}
return event.entityItem;
return event.getEntityItem();
}
public static float getEnchantPower(World world, BlockPos pos)
@ -648,7 +647,7 @@ public class ForgeHooks
{
PlayerOpenContainerEvent event = new PlayerOpenContainerEvent(player, openContainer);
MinecraftForge.EVENT_BUS.post(event);
return event.getResult() == Event.Result.DEFAULT ? event.canInteractWith : event.getResult() == Event.Result.ALLOW ? true : false;
return event.getResult() == Event.Result.DEFAULT ? event.isCanInteractWith() : event.getResult() == Event.Result.ALLOW ? true : false;
}
public static int onBlockBreakEvent(World world, GameType gameType, EntityPlayerMP entityPlayer, BlockPos pos)
@ -800,11 +799,11 @@ public class ForgeHooks
{
AnvilUpdateEvent e = new AnvilUpdateEvent(left, right, name, baseCost);
if (MinecraftForge.EVENT_BUS.post(e)) return false;
if (e.output == null) return true;
if (e.getOutput() == null) return true;
outputSlot.setInventorySlotContents(0, e.output);
container.maximumCost = e.cost;
container.materialCost = e.materialCost;
outputSlot.setInventorySlotContents(0, e.getOutput());
container.maximumCost = e.getCost();
container.materialCost = e.getMaterialCost();
return false;
}
@ -812,7 +811,7 @@ public class ForgeHooks
{
AnvilRepairEvent e = new AnvilRepairEvent(player, left, right, output);
MinecraftForge.EVENT_BUS.post(e);
return e.breakChance;
return e.getBreakChance();
}
public static boolean onNoteChange(TileEntityNote te, byte old)

View File

@ -17,12 +17,12 @@ public class ForgeInternalHandler
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onEntityJoinWorld(EntityJoinWorldEvent event)
{
if (!event.world.isRemote)
if (!event.getWorld().isRemote)
{
ForgeChunkManager.loadEntity(event.entity);
ForgeChunkManager.loadEntity(event.getEntity());
}
Entity entity = event.entity;
Entity entity = event.getEntity();
if (entity.getClass().equals(EntityItem.class))
{
ItemStack stack = ((EntityItem)entity).getEntityItem();
@ -47,12 +47,12 @@ public class ForgeInternalHandler
if (item.hasCustomEntity(stack))
{
Entity newEntity = item.createEntity(event.world, entity, stack);
Entity newEntity = item.createEntity(event.getWorld(), entity, stack);
if (newEntity != null)
{
entity.setDead();
event.setCanceled(true);
event.world.spawnEntityInWorld(newEntity);
event.getWorld().spawnEntityInWorld(newEntity);
}
}
}
@ -61,20 +61,20 @@ public class ForgeInternalHandler
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onDimensionLoad(WorldEvent.Load event)
{
ForgeChunkManager.loadWorld(event.world);
ForgeChunkManager.loadWorld(event.getWorld());
}
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onDimensionSave(WorldEvent.Save event)
{
ForgeChunkManager.saveWorld(event.world);
ForgeChunkManager.saveWorld(event.getWorld());
}
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onDimensionUnload(WorldEvent.Unload event)
{
ForgeChunkManager.unloadWorld(event.world);
if (event.world instanceof WorldServer)
FakePlayerFactory.unloadWorld((WorldServer)event.world);
ForgeChunkManager.unloadWorld(event.getWorld());
if (event.getWorld() instanceof WorldServer)
FakePlayerFactory.unloadWorld((WorldServer) event.getWorld());
}
}

View File

@ -14,19 +14,29 @@ import net.minecraft.item.ItemStack;
@Cancelable
public class AnvilUpdateEvent extends Event
{
public final ItemStack left; // The left side of the input
public final ItemStack right; // The right side of the input
public final String name; // The name to set the item, if the user specified one.
public ItemStack output; // Set this to set the output stack
public int cost; // The base cost, set this to change it if output != null
public int materialCost; // The number of items from the right slot to be consumed during the repair. Leave as 0 to consume the entire stack.
private final ItemStack left; // The left side of the input
private final ItemStack right; // The right side of the input
private final String name; // The name to set the item, if the user specified one.
private ItemStack output; // Set this to set the output stack
private int cost; // The base cost, set this to change it if output != null
private int materialCost; // The number of items from the right slot to be consumed during the repair. Leave as 0 to consume the entire stack.
public AnvilUpdateEvent(ItemStack left, ItemStack right, String name, int cost)
{
this.left = left;
this.right = right;
this.name = name;
this.cost = cost;
this.materialCost = 0;
this.setCost(cost);
this.setMaterialCost(0);
}
public ItemStack getLeft() { return left; }
public ItemStack getRight() { return right; }
public String getName() { return name; }
public ItemStack getOutput() { return output; }
public void setOutput(ItemStack output) { this.output = output; }
public int getCost() { return cost; }
public void setCost(int cost) { this.cost = cost; }
public int getMaterialCost() { return materialCost; }
public void setMaterialCost(int materialCost) { this.materialCost = materialCost; }
}

View File

@ -26,15 +26,22 @@ import net.minecraft.command.ICommandSender;
public class CommandEvent extends Event
{
public final ICommand command;
public final ICommandSender sender;
public String[] parameters;
public Throwable exception;
private final ICommand command;
private final ICommandSender sender;
private String[] parameters;
private Throwable exception;
public CommandEvent(ICommand command, ICommandSender sender, String[] parameters)
{
this.command = command;
this.sender = sender;
this.parameters = parameters;
this.setParameters(parameters);
}
public ICommand getCommand() { return command; }
public ICommandSender getSender() { return sender; }
public String[] getParameters() { return parameters; }
public void setParameters(String[] parameters) { this.parameters = parameters; }
public Throwable getException() { return exception; }
public void setException(Throwable exception) { this.exception = exception; }
}

View File

@ -125,7 +125,7 @@ public class ForgeEventFactory
public static float getBreakSpeed(EntityPlayer player, IBlockState state, float original, BlockPos pos)
{
PlayerEvent.BreakSpeed event = new PlayerEvent.BreakSpeed(player, state, original, pos);
return (MinecraftForge.EVENT_BUS.post(event) ? -1 : event.newSpeed);
return (MinecraftForge.EVENT_BUS.post(event) ? -1 : event.getNewSpeed());
}
@Deprecated
@ -182,28 +182,28 @@ public class ForgeEventFactory
{
return null;
}
return event.list;
return event.getList();
}
public static int getMaxSpawnPackSize(EntityLiving entity)
{
LivingPackSizeEvent maxCanSpawnEvent = new LivingPackSizeEvent(entity);
MinecraftForge.EVENT_BUS.post(maxCanSpawnEvent);
return maxCanSpawnEvent.getResult() == Result.ALLOW ? maxCanSpawnEvent.maxPackSize : entity.getMaxSpawnedInChunk();
return maxCanSpawnEvent.getResult() == Result.ALLOW ? maxCanSpawnEvent.getMaxPackSize() : entity.getMaxSpawnedInChunk();
}
public static String getPlayerDisplayName(EntityPlayer player, String username)
{
PlayerEvent.NameFormat event = new PlayerEvent.NameFormat(player, username);
MinecraftForge.EVENT_BUS.post(event);
return event.displayname;
return event.getDisplayname();
}
public static float fireBlockHarvesting(List<ItemStack> drops, World world, BlockPos pos, IBlockState state, int fortune, float dropChance, boolean silkTouch, EntityPlayer player)
{
BlockEvent.HarvestDropsEvent event = new BlockEvent.HarvestDropsEvent(world, pos, state, fortune, dropChance, drops, player, silkTouch);
MinecraftForge.EVENT_BUS.post(event);
return event.dropChance;
return event.getDropChance();
}
public static ItemTooltipEvent onItemTooltip(ItemStack itemStack, EntityPlayer entityPlayer, List<String> toolTip, boolean showAdvancedItemTooltips)
@ -228,13 +228,13 @@ public class ForgeEventFactory
public static int onItemUseStart(EntityLivingBase entity, ItemStack item, int duration)
{
LivingEntityUseItemEvent event = new LivingEntityUseItemEvent.Start(entity, item, duration);
return MinecraftForge.EVENT_BUS.post(event) ? -1 : event.duration;
return MinecraftForge.EVENT_BUS.post(event) ? -1 : event.getDuration();
}
public static int onItemUseTick(EntityLivingBase entity, ItemStack item, int duration)
{
LivingEntityUseItemEvent event = new LivingEntityUseItemEvent.Tick(entity, item, duration);
return MinecraftForge.EVENT_BUS.post(event) ? -1 : event.duration;
return MinecraftForge.EVENT_BUS.post(event) ? -1 : event.getDuration();
}
public static boolean onUseItemStop(EntityLivingBase entity, ItemStack item, int duration)
@ -246,7 +246,7 @@ public class ForgeEventFactory
{
LivingEntityUseItemEvent.Finish event = new LivingEntityUseItemEvent.Finish(entity, item, duration, result);
MinecraftForge.EVENT_BUS.post(event);
return event.result;
return event.getResultStack();
}
public static void onStartEntityTracking(Entity entity, EntityPlayer player)
@ -279,7 +279,7 @@ public class ForgeEventFactory
public static ITextComponent onClientChat(byte type, ITextComponent message)
{
ClientChatReceivedEvent event = new ClientChatReceivedEvent(type, message);
return MinecraftForge.EVENT_BUS.post(event) ? null : event.message;
return MinecraftForge.EVENT_BUS.post(event) ? null : event.getMessage();
}
public static int onHoeUse(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos)
@ -332,7 +332,7 @@ public class ForgeEventFactory
{
EntityEvent.CanUpdate event = new EntityEvent.CanUpdate(entity);
MinecraftForge.EVENT_BUS.post(event);
return event.canUpdate;
return event.getCanUpdate();
}
public static PlaySoundAtEntityEvent onPlaySoundAtEntity(Entity entity, SoundEvent name, SoundCategory category, float volume, float pitch)
@ -347,7 +347,7 @@ public class ForgeEventFactory
if (item == null) return -1;
ItemExpireEvent event = new ItemExpireEvent(entity, (item.getItem() == null ? 6000 : item.getItem().getEntityLifespan(item, entity.worldObj)));
if (!MinecraftForge.EVENT_BUS.post(event)) return -1;
return event.extraLife;
return event.getExtraLife();
}
public static int onItemPickup(EntityItem entityItem, EntityPlayer entityIn, ItemStack itemstack)
@ -391,7 +391,7 @@ public class ForgeEventFactory
{
PlayerSleepInBedEvent event = new PlayerSleepInBedEvent(player, pos);
MinecraftForge.EVENT_BUS.post(event);
return event.result;
return event.getResultStatus();
}
public static void onPlayerWakeup(EntityPlayer player, boolean wakeImmediately, boolean updateWorldFlag, boolean setSpawn)
@ -442,7 +442,7 @@ public class ForgeEventFactory
public static float onLivingHeal(EntityLivingBase entity, float amount)
{
LivingHealEvent event = new LivingHealEvent(entity, amount);
return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.amount);
return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.getAmount());
}
public static boolean onPotionAttemptBrew(ItemStack[] stacks)

View File

@ -73,8 +73,7 @@ public class PotionBrewEvent extends Event
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
**/
@SuppressWarnings("deprecation")
public static class Post extends PotionBrewedEvent
public static class Post extends PotionBrewEvent
{
public Post(ItemStack[] stacks)
{

View File

@ -1,32 +0,0 @@
package net.minecraftforge.event.brewing;
import net.minecraft.item.ItemStack;
/**
* PotionBrewedEvent is fired when a potion is brewed in the brewing stand.
* <br>
* The event is fired during the TileEntityBrewingStand#brewPotions() method invocation.<br>
* <br>
* {@link #brewingStacks} contains the itemstack array from the TileEntityBrewer holding all items in Brewer.<br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
* This event does not have a result. {@link HasResult}<br>
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
**/
@Deprecated // remove in 1.9
public class PotionBrewedEvent extends PotionBrewEvent
{
/**
* The brewing stacks in the brewing stand. Each index has the possibility to be null, so make sure you check.
* Changing this array to another one has no effect.
*/
@Deprecated
public ItemStack[] brewingStacks;
public PotionBrewedEvent(ItemStack[] brewingStacks)
{
super(brewingStacks);
this.brewingStacks = brewingStacks;
}
}

View File

@ -14,13 +14,18 @@ import net.minecraft.entity.Entity;
**/
public class EntityEvent extends Event
{
public final Entity entity;
private final Entity entity;
public EntityEvent(Entity entity)
{
this.entity = entity;
}
public Entity getEntity()
{
return entity;
}
/**
* EntityConstructing is fired when an Entity is being created. <br>
* This event is fired within the constructor of the Entity.<br>
@ -54,11 +59,21 @@ public class EntityEvent extends Event
**/
public static class CanUpdate extends EntityEvent
{
public boolean canUpdate = false;
private boolean canUpdate = false;
public CanUpdate(Entity entity)
{
super(entity);
}
public boolean getCanUpdate()
{
return canUpdate;
}
public void setCanUpdate(boolean canUpdate)
{
this.canUpdate = canUpdate;
}
}
/**
@ -74,18 +89,27 @@ public class EntityEvent extends Event
**/
public static class EnteringChunk extends EntityEvent
{
public int newChunkX;
public int newChunkZ;
public int oldChunkX;
public int oldChunkZ;
private int newChunkX;
private int newChunkZ;
private int oldChunkX;
private int oldChunkZ;
public EnteringChunk(Entity entity, int newChunkX, int newChunkZ, int oldChunkX, int oldChunkZ)
{
super(entity);
this.newChunkX = newChunkX;
this.newChunkZ = newChunkZ;
this.oldChunkX = oldChunkX;
this.oldChunkZ = oldChunkZ;
this.setNewChunkX(newChunkX);
this.setNewChunkZ(newChunkZ);
this.setOldChunkX(oldChunkX);
this.setOldChunkZ(oldChunkZ);
}
public int getNewChunkX() { return newChunkX; }
public void setNewChunkX(int newChunkX) { this.newChunkX = newChunkX; }
public int getNewChunkZ() { return newChunkZ; }
public void setNewChunkZ(int newChunkZ) { this.newChunkZ = newChunkZ; }
public int getOldChunkX() { return oldChunkX; }
public void setOldChunkX(int oldChunkX) { this.oldChunkX = oldChunkX; }
public int getOldChunkZ() { return oldChunkZ; }
public void setOldChunkZ(int oldChunkZ) { this.oldChunkZ = oldChunkZ; }
}
}

View File

@ -22,11 +22,16 @@ import net.minecraft.world.World;
public class EntityJoinWorldEvent extends EntityEvent
{
public final World world;
private final World world;
public EntityJoinWorldEvent(Entity entity, World world)
{
super(entity);
this.world = world;
}
public World getWorld()
{
return world;
}
}

View File

@ -23,9 +23,9 @@ import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
public class EntityMountEvent extends EntityEvent
{
public final Entity entityMounting;
public final Entity entityBeingMounted;
public final World worldObj;
private final Entity entityMounting;
private final Entity entityBeingMounted;
private final World worldObj;
private final boolean isMounting;
@ -48,4 +48,18 @@ public class EntityMountEvent extends EntityEvent
return !isMounting;
}
public Entity getEntityMounting()
{
return entityMounting;
}
public Entity getEntityBeingMounted()
{
return entityBeingMounted;
}
public World getWorldObj()
{
return worldObj;
}
}

View File

@ -21,11 +21,16 @@ import net.minecraft.entity.effect.EntityLightningBolt;
@Cancelable
public class EntityStruckByLightningEvent extends EntityEvent
{
public final EntityLightningBolt lightning;
private final EntityLightningBolt lightning;
public EntityStruckByLightningEvent(Entity entity, EntityLightningBolt lightning)
{
super(entity);
this.lightning = lightning;
}
public EntityLightningBolt getLightning()
{
return lightning;
}
}

View File

@ -19,11 +19,16 @@ import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
@Cancelable
public class EntityTravelToDimensionEvent extends EntityEvent
{
public final int dimension;
private final int dimension;
public EntityTravelToDimensionEvent(Entity entity, int dimension)
{
super(entity);
this.dimension = dimension;
}
public int getDimension()
{
return dimension;
}
}

View File

@ -11,10 +11,7 @@ import net.minecraftforge.event.entity.EntityEvent;
*/
public class ItemEvent extends EntityEvent
{
/**
* The relevant EntityItem for this event, already cast for you.
*/
public final EntityItem entityItem;
private final EntityItem entityItem;
/**
* Creates a new event for an EntityItem.
@ -26,4 +23,12 @@ public class ItemEvent extends EntityEvent
super(itemEntity);
this.entityItem = itemEntity;
}
/**
* The relevant EntityItem for this event, already cast for you.
*/
public EntityItem getEntityItem()
{
return entityItem;
}
}

View File

@ -13,7 +13,7 @@ import net.minecraft.entity.item.EntityItem;
public class ItemExpireEvent extends ItemEvent
{
public int extraLife;
private int extraLife;
/**
* Creates a new event for an expiring EntityItem.
@ -24,6 +24,16 @@ public class ItemExpireEvent extends ItemEvent
public ItemExpireEvent(EntityItem entityItem, int extraLife)
{
super(entityItem);
this.setExtraLife(extraLife);
}
public int getExtraLife()
{
return extraLife;
}
public void setExtraLife(int extraLife)
{
this.extraLife = extraLife;
}
}

View File

@ -14,10 +14,7 @@ import net.minecraft.entity.player.EntityPlayer;
public class ItemTossEvent extends ItemEvent
{
/**
* The player tossing the item.
*/
public final EntityPlayer player;
private final EntityPlayer player;
/**
* Creates a new event for EntityItems tossed by a player.
@ -30,4 +27,12 @@ public class ItemTossEvent extends ItemEvent
super(entityItem);
this.player = player;
}
/**
* The player tossing the item.
*/
public EntityPlayer getPlayer()
{
return player;
}
}

View File

@ -12,17 +12,26 @@ import net.minecraft.entity.EntityLivingBase;
public class EnderTeleportEvent extends LivingEvent
{
public double targetX;
public double targetY;
public double targetZ;
public float attackDamage;
private double targetX;
private double targetY;
private double targetZ;
private float attackDamage;
public EnderTeleportEvent(EntityLivingBase entity, double targetX, double targetY, double targetZ, float attackDamage)
{
super(entity);
this.targetX = targetX;
this.targetY = targetY;
this.targetZ = targetZ;
this.attackDamage = attackDamage;
this.setTargetX(targetX);
this.setTargetY(targetY);
this.setTargetZ(targetZ);
this.setAttackDamage(attackDamage);
}
public double getTargetX() { return targetX; }
public void setTargetX(double targetX) { this.targetX = targetX; }
public double getTargetY() { return targetY; }
public void setTargetY(double targetY) { this.targetY = targetY; }
public double getTargetZ() { return targetZ; }
public void setTargetZ(double targetZ) { this.targetZ = targetZ; }
public float getAttackDamage() { return attackDamage; }
public void setAttackDamage(float attackDamage) { this.attackDamage = attackDamage; }
}

View File

@ -25,10 +25,15 @@ import net.minecraft.entity.EntityLivingBase;
@Cancelable
public class LivingDeathEvent extends LivingEvent
{
public final DamageSource source;
private final DamageSource source;
public LivingDeathEvent(EntityLivingBase entity, DamageSource source)
{
super(entity);
this.source = source;
}
public DamageSource getSource()
{
return source;
}
}

View File

@ -29,10 +29,10 @@ import net.minecraft.entity.EntityLivingBase;
@Cancelable
public class LivingDropsEvent extends LivingEvent
{
public final DamageSource source;
public final List<EntityItem> drops;
public final int lootingLevel;
public final boolean recentlyHit;
private final DamageSource source;
private final List<EntityItem> drops;
private final int lootingLevel;
private final boolean recentlyHit;
public LivingDropsEvent(EntityLivingBase entity, DamageSource source, List<EntityItem> drops, int lootingLevel, boolean recentlyHit)
{
@ -42,4 +42,24 @@ public class LivingDropsEvent extends LivingEvent
this.lootingLevel = lootingLevel;
this.recentlyHit = recentlyHit;
}
public DamageSource getSource()
{
return source;
}
public List<EntityItem> getDrops()
{
return drops;
}
public int getLootingLevel()
{
return lootingLevel;
}
public boolean isRecentlyHit()
{
return recentlyHit;
}
}

View File

@ -6,13 +6,28 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable;
public abstract class LivingEntityUseItemEvent extends LivingEvent
{
public final ItemStack item;
public int duration;
private final ItemStack item;
private int duration;
private LivingEntityUseItemEvent(EntityLivingBase entity, ItemStack item, int duration)
{
super(entity);
this.item = item;
this.setDuration(duration);
}
public ItemStack getItem()
{
return item;
}
public int getDuration()
{
return duration;
}
public void setDuration(int duration)
{
this.duration = duration;
}
@ -84,10 +99,20 @@ public abstract class LivingEntityUseItemEvent extends LivingEvent
*/
public static class Finish extends LivingEntityUseItemEvent
{
public ItemStack result;
private ItemStack result;
public Finish(EntityLivingBase entity, ItemStack item, int duration, ItemStack result)
{
super(entity, item, duration);
this.setResultStack(result);
}
public ItemStack getResultStack()
{
return result;
}
public void setResultStack(ItemStack result)
{
this.result = result;
}
}

View File

@ -13,13 +13,18 @@ import net.minecraftforge.event.entity.EntityEvent;
**/
public class LivingEvent extends EntityEvent
{
public final EntityLivingBase entityLiving;
private final EntityLivingBase entityLiving;
public LivingEvent(EntityLivingBase entity)
{
super(entity);
entityLiving = entity;
}
public EntityLivingBase getEntityLiving()
{
return entityLiving;
}
/**
* LivingUpdateEvent is fired when an Entity is updated. <br>
* This event is fired whenever an Entity is updated in

View File

@ -12,10 +12,10 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable;
@Cancelable
public class LivingExperienceDropEvent extends LivingEvent
{
final EntityPlayer attackingPlayer;
final int originalExperiencePoints;
private final EntityPlayer attackingPlayer;
private final int originalExperiencePoints;
int droppedExperiencePoints;
private int droppedExperiencePoints;
public LivingExperienceDropEvent(EntityLivingBase entity, EntityPlayer attackingPlayer, int originalExperience)
{

View File

@ -22,12 +22,17 @@ import net.minecraft.entity.EntityLivingBase;
@Cancelable
public class LivingFallEvent extends LivingEvent
{
public float distance;
public float damageMultiplier;
private float distance;
private float damageMultiplier;
public LivingFallEvent(EntityLivingBase entity, float distance, float damageMultiplier)
{
super(entity);
this.distance = distance;
this.damageMultiplier = damageMultiplier;
this.setDistance(distance);
this.setDamageMultiplier(damageMultiplier);
}
public float getDistance() { return distance; }
public void setDistance(float distance) { this.distance = distance; }
public float getDamageMultiplier() { return damageMultiplier; }
public void setDamageMultiplier(float damageMultiplier) { this.damageMultiplier = damageMultiplier; }
}

View File

@ -21,10 +21,20 @@ import net.minecraft.entity.EntityLivingBase;
@Cancelable
public class LivingHealEvent extends LivingEvent
{
public float amount;
private float amount;
public LivingHealEvent(EntityLivingBase entity, float amount)
{
super(entity);
this.setAmount(amount);
}
public float getAmount()
{
return amount;
}
public void setAmount(float amount)
{
this.amount = amount;
}
}

View File

@ -6,18 +6,28 @@ import net.minecraft.entity.EntityLiving;
@HasResult
public class LivingPackSizeEvent extends LivingEvent
{
/**
* This event is fired when the spawning system determines the
* maximum amount of the selected entity that can spawn at the same
* time.
*
* If you set the result to 'ALLOW', it means that you want to return
* the value of maxPackSize as the maximum pack size for current entity.
*/
public int maxPackSize;
private int maxPackSize;
public LivingPackSizeEvent(EntityLiving entity)
{
super(entity);
}
/**
* This event is fired when the spawning system determines the
* maximum amount of the selected entity that can spawn at the same
* time.
*
* If you set the result to 'ALLOW', it means that you want to return
* the value of maxPackSize as the maximum pack size for current entity.
*/
public int getMaxPackSize()
{
return maxPackSize;
}
public void setMaxPackSize(int maxPackSize)
{
this.maxPackSize = maxPackSize;
}
}

View File

@ -21,11 +21,15 @@ import net.minecraft.entity.EntityLivingBase;
public class LivingSetAttackTargetEvent extends LivingEvent
{
public final EntityLivingBase target;
private final EntityLivingBase target;
public LivingSetAttackTargetEvent(EntityLivingBase entity, EntityLivingBase target)
{
super(entity);
this.target = target;
}
public EntityLivingBase getTarget()
{
return target;
}
}

View File

@ -19,10 +19,10 @@ import net.minecraft.world.World;
**/
public class LivingSpawnEvent extends LivingEvent
{
public final World world;
public final float x;
public final float y;
public final float z;
private final World world;
private final float x;
private final float y;
private final float z;
public LivingSpawnEvent(EntityLiving entity, World world, float x, float y, float z)
{
@ -33,6 +33,10 @@ public class LivingSpawnEvent extends LivingEvent
this.z = z;
}
public World getWorld() { return world; }
public float getX() { return x; }
public float getY() { return y; }
public float getZ() { return z; }
/**
* Fires before mob spawn events.
*

View File

@ -1,6 +1,5 @@
package net.minecraftforge.event.entity.living;
import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.world.World;
@ -22,7 +21,7 @@ public class ZombieEvent extends EntityEvent {
public EntityZombie getSummoner()
{
return (EntityZombie) entity;
return (EntityZombie) getEntity();
}
/**
@ -50,17 +49,14 @@ public class ZombieEvent extends EntityEvent {
**/
@HasResult
public static class SummonAidEvent extends ZombieEvent {
/**
* Populate this field to have a custom zombie instead of a normal zombie summoned
*/
public EntityZombie customSummonedAid;
private EntityZombie customSummonedAid;
public final World world;
public final int x;
public final int y;
public final int z;
public final EntityLivingBase attacker;
public final double summonChance;
private final World world;
private final int x;
private final int y;
private final int z;
private final EntityLivingBase attacker;
private final double summonChance;
public SummonAidEvent(EntityZombie entity, World world, int x, int y, int z, EntityLivingBase attacker, double summonChance)
{
@ -72,6 +68,17 @@ public class ZombieEvent extends EntityEvent {
this.attacker = attacker;
this.summonChance = summonChance;
}
/**
* Populate this field to have a custom zombie instead of a normal zombie summoned
*/
public EntityZombie getCustomSummonedAid() { return customSummonedAid; }
public void setCustomSummonedAid(EntityZombie customSummonedAid) { this.customSummonedAid = customSummonedAid; }
public World getWorld() { return world; }
public int getX() { return x; }
public int getY() { return y; }
public int getZ() { return z; }
public EntityLivingBase getAttacker() { return attacker; }
public double getSummonChance() { return summonChance; }
}
}

View File

@ -18,11 +18,16 @@ import net.minecraft.entity.item.EntityMinecart;
**/
public class MinecartCollisionEvent extends MinecartEvent
{
public final Entity collider;
private final Entity collider;
public MinecartCollisionEvent(EntityMinecart minecart, Entity collider)
{
super(minecart);
this.collider = collider;
}
public Entity getCollider()
{
return collider;
}
}

View File

@ -14,11 +14,16 @@ import net.minecraftforge.event.entity.EntityEvent;
**/
public class MinecartEvent extends EntityEvent
{
public final EntityMinecart minecart;
private final EntityMinecart minecart;
public MinecartEvent(EntityMinecart minecart)
{
super(minecart);
this.minecart = minecart;
}
public EntityMinecart getMinecart()
{
return minecart;
}
}

View File

@ -18,11 +18,16 @@ import net.minecraft.util.math.BlockPos;
**/
public class MinecartUpdateEvent extends MinecartEvent
{
public final BlockPos pos;
private final BlockPos pos;
public MinecartUpdateEvent(EntityMinecart minecart, BlockPos pos)
{
super(minecart);
this.pos = pos;
}
public BlockPos getPos()
{
return pos;
}
}

View File

@ -10,10 +10,15 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable;
@Cancelable
public class AchievementEvent extends PlayerEvent {
public final Achievement achievement;
private final Achievement achievement;
public AchievementEvent(EntityPlayer player, Achievement achievement)
{
super(player);
this.achievement = achievement;
}
public Achievement getAchievement()
{
return achievement;
}
}

View File

@ -5,18 +5,11 @@ import net.minecraft.item.ItemStack;
public class AnvilRepairEvent extends PlayerEvent
{
/**
* Fired when the player removes a "repaired" item from the Anvil's Output slot.
*
* breakChance specifies as a percentage the chance that the anvil will be "damaged" when used.
*
* ItemStacks are the inputs/output from the anvil. They cannot be edited.
*/
public final ItemStack left; // The left side of the input
public final ItemStack right; // The right side of the input
public final ItemStack output; // Set this to set the output stack
public float breakChance; // Anvil's chance to break (reduced by 1 durability) when this is complete. Default is 12% (0.12f)
private final ItemStack left; // The left side of the input
private final ItemStack right; // The right side of the input
private final ItemStack output; // Set this to set the output stack
private float breakChance; // Anvil's chance to break (reduced by 1 durability) when this is complete. Default is 12% (0.12f)
public AnvilRepairEvent(EntityPlayer player, ItemStack output, ItemStack left, ItemStack right)
{
@ -24,6 +17,19 @@ public class AnvilRepairEvent extends PlayerEvent
this.output = output;
this.left = left;
this.right = right;
this.breakChance = 0.12f;
this.setBreakChance(0.12f);
}
/**
* Fired when the player removes a "repaired" item from the Anvil's Output slot.
*
* breakChance specifies as a percentage the chance that the anvil will be "damaged" when used.
*
* ItemStacks are the inputs/output from the anvil. They cannot be edited.
*/
public ItemStack getLeft() { return left; }
public ItemStack getRight() { return right; }
public ItemStack getOutput() { return output; }
public float getBreakChance() { return breakChance; }
public void setBreakChance(float breakChance) { this.breakChance = breakChance; }
}

View File

@ -21,10 +21,15 @@ import net.minecraft.entity.player.EntityPlayer;
@Cancelable
public class AttackEntityEvent extends PlayerEvent
{
public final Entity target;
private final Entity target;
public AttackEntityEvent(EntityPlayer player, Entity target)
{
super(player);
this.target = target;
}
public Entity getTarget()
{
return target;
}
}

View File

@ -7,23 +7,23 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
* This event is called when a player attempts to use Bonemeal on a block.
* It can be canceled to completely prevent any further processing.
*
* You can also set the result to ALLOW to mark the event as processed
* and use up a bonemeal from the stack but do no further processing.
*
* setResult(ALLOW) is the same as the old setHandled()
*/
@Cancelable
@Event.HasResult
public class BonemealEvent extends PlayerEvent
{
/**
* This event is called when a player attempts to use Bonemeal on a block.
* It can be canceled to completely prevent any further processing.
*
* You can also set the result to ALLOW to mark the event as processed
* and use up a bonemeal from the stack but do no further processing.
*
* setResult(ALLOW) is the same as the old setHandled()
*/
public final World world;
public final BlockPos pos;
public final IBlockState block;
private final World world;
private final BlockPos pos;
private final IBlockState block;
public BonemealEvent(EntityPlayer player, World world, BlockPos pos, IBlockState block)
{
@ -32,4 +32,19 @@ public class BonemealEvent extends PlayerEvent
this.pos = pos;
this.block = block;
}
public World getWorld()
{
return world;
}
public BlockPos getPos()
{
return pos;
}
public IBlockState getBlock()
{
return block;
}
}

View File

@ -5,25 +5,30 @@ import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
/**
* This event is called when a player collides with a EntityItem on the ground.
* The event can be canceled, and no further processing will be done.
*
* You can set the result of this event to ALLOW which will trigger the
* processing of achievements, FML's event, play the sound, and kill the
* entity if all the items are picked up.
*
* setResult(ALLOW) is the same as the old setHandled()
*/
@Cancelable
@Event.HasResult
public class EntityItemPickupEvent extends PlayerEvent
{
/**
* This event is called when a player collides with a EntityItem on the ground.
* The event can be canceled, and no further processing will be done.
*
* You can set the result of this event to ALLOW which will trigger the
* processing of achievements, FML's event, play the sound, and kill the
* entity if all the items are picked up.
*
* setResult(ALLOW) is the same as the old setHandled()
*/
public final EntityItem item;
private final EntityItem item;
public EntityItemPickupEvent(EntityPlayer player, EntityItem item)
{
super(player);
this.item = item;
}
public EntityItem getItem()
{
return item;
}
}

View File

@ -7,19 +7,19 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
/**
* This event is fired when a player attempts to use a Empty bucket, it
* can be canceled to completely prevent any further processing.
*
* If you set the result to 'ALLOW', it means that you have processed
* the event and wants the basic functionality of adding the new
* ItemStack to your inventory and reducing the stack size to process.
* setResult(ALLOW) is the same as the old setHandled();
*/
@Cancelable
@Event.HasResult
public class FillBucketEvent extends PlayerEvent
{
/**
* This event is fired when a player attempts to use a Empty bucket, it
* can be canceled to completely prevent any further processing.
*
* If you set the result to 'ALLOW', it means that you have processed
* the event and wants the basic functionality of adding the new
* ItemStack to your inventory and reducing the stack size to process.
* setResult(ALLOW) is the same as the old setHandled();
*/
private final ItemStack current;
private final World world;

View File

@ -6,18 +6,9 @@ import net.minecraft.item.ItemStack;
public class ItemTooltipEvent extends PlayerEvent
{
/**
* Whether the advanced information on item tooltips is being shown, toggled by F3+H.
*/
public final boolean showAdvancedItemTooltips;
/**
* The {@link ItemStack} with the tooltip.
*/
public final ItemStack itemStack;
/**
* The {@link ItemStack} tooltip.
*/
public final List<String> toolTip;
private final boolean showAdvancedItemTooltips;
private final ItemStack itemStack;
private final List<String> toolTip;
/**
* This event is fired in {@link ItemStack#getTooltip(EntityPlayer, boolean)}, which in turn is called from it's respective GUIContainer.
@ -29,4 +20,28 @@ public class ItemTooltipEvent extends PlayerEvent
this.toolTip = toolTip;
this.showAdvancedItemTooltips = showAdvancedItemTooltips;
}
/**
* Whether the advanced information on item tooltips is being shown, toggled by F3+H.
*/
public boolean isShowAdvancedItemTooltips()
{
return showAdvancedItemTooltips;
}
/**
* The {@link ItemStack} with the tooltip.
*/
public ItemStack getItemStack()
{
return itemStack;
}
/**
* The {@link ItemStack} tooltip.
*/
public List<String> getToolTip()
{
return toolTip;
}
}

View File

@ -18,7 +18,7 @@ import net.minecraftforge.event.entity.living.LivingDropsEvent;
@Cancelable
public class PlayerDropsEvent extends LivingDropsEvent
{
public final EntityPlayer entityPlayer;
private final EntityPlayer entityPlayer;
/**
* Creates a new event containing all the items that will drop into the
@ -36,4 +36,9 @@ public class PlayerDropsEvent extends LivingDropsEvent
this.entityPlayer = entity;
}
public EntityPlayer getEntityPlayer()
{
return entityPlayer;
}
}

View File

@ -18,13 +18,18 @@ import net.minecraftforge.event.entity.living.LivingEvent;
**/
public class PlayerEvent extends LivingEvent
{
public final EntityPlayer entityPlayer;
private final EntityPlayer entityPlayer;
public PlayerEvent(EntityPlayer player)
{
super(player);
entityPlayer = player;
}
public EntityPlayer getEntityPlayer()
{
return entityPlayer;
}
/**
* HarvestCheck is fired when a player attempts to harvest a block.<br>
* This event is fired whenever a player attempts to harvest a block in
@ -80,19 +85,25 @@ public class PlayerEvent extends LivingEvent
@Cancelable
public static class BreakSpeed extends PlayerEvent
{
public final IBlockState state;
public final float originalSpeed;
public float newSpeed = 0.0f;
public final BlockPos pos; // Y position of -1 notes unknown location
private final IBlockState state;
private final float originalSpeed;
private float newSpeed = 0.0f;
private final BlockPos pos; // Y position of -1 notes unknown location
public BreakSpeed(EntityPlayer player, IBlockState state, float original, BlockPos pos)
{
super(player);
this.state = state;
this.originalSpeed = original;
this.newSpeed = original;
this.setNewSpeed(original);
this.pos = pos;
}
public IBlockState getState() { return state; }
public float getOriginalSpeed() { return originalSpeed; }
public float getNewSpeed() { return newSpeed; }
public void setNewSpeed(float newSpeed) { this.newSpeed = newSpeed; }
public BlockPos getPos() { return pos; }
}
/**
@ -113,13 +124,28 @@ public class PlayerEvent extends LivingEvent
**/
public static class NameFormat extends PlayerEvent
{
public final String username;
public String displayname;
private final String username;
private String displayname;
public NameFormat(EntityPlayer player, String username) {
super(player);
this.username = username;
this.displayname = username;
this.setDisplayname(username);
}
public String getUsername()
{
return username;
}
public String getDisplayname()
{
return displayname;
}
public void setDisplayname(String displayname)
{
this.displayname = displayname;
}
}
@ -129,15 +155,8 @@ public class PlayerEvent extends LivingEvent
*/
public static class Clone extends PlayerEvent
{
/**
* The old EntityPlayer that this new entity is a clone of.
*/
public final EntityPlayer original;
/**
* True if this event was fired because the player died.
* False if it was fired because the entity switched dimensions.
*/
public final boolean wasDeath;
private final EntityPlayer original;
private final boolean wasDeath;
public Clone(EntityPlayer _new, EntityPlayer oldPlayer, boolean wasDeath)
{
@ -145,6 +164,23 @@ public class PlayerEvent extends LivingEvent
this.original = oldPlayer;
this.wasDeath = wasDeath;
}
/**
* The old EntityPlayer that this new entity is a clone of.
*/
public EntityPlayer getOriginal()
{
return original;
}
/**
* True if this event was fired because the player died.
* False if it was fired because the entity switched dimensions.
*/
public boolean isWasDeath()
{
return wasDeath;
}
}
/**
@ -153,10 +189,7 @@ public class PlayerEvent extends LivingEvent
*/
public static class StartTracking extends PlayerEvent {
/**
* The Entity now being tracked.
*/
public final Entity target;
private final Entity target;
public StartTracking(EntityPlayer player, Entity target)
{
@ -164,6 +197,13 @@ public class PlayerEvent extends LivingEvent
this.target = target;
}
/**
* The Entity now being tracked.
*/
public Entity getTarget()
{
return target;
}
}
/**
@ -172,10 +212,7 @@ public class PlayerEvent extends LivingEvent
*/
public static class StopTracking extends PlayerEvent {
/**
* The Entity no longer being tracked.
*/
public final Entity target;
private final Entity target;
public StopTracking(EntityPlayer player, Entity target)
{
@ -183,6 +220,13 @@ public class PlayerEvent extends LivingEvent
this.target = target;
}
/**
* The Entity no longer being tracked.
*/
public Entity getTarget()
{
return target;
}
}
/**
@ -192,16 +236,8 @@ public class PlayerEvent extends LivingEvent
* containing additional mod related player data.
*/
public static class LoadFromFile extends PlayerEvent {
/**
* The directory where player data is being stored. Use this
* to locate your mod additional file.
*/
public final File playerDirectory;
/**
* The UUID is the standard for player related file storage.
* It is broken out here for convenience for quick file generation.
*/
public final String playerUUID;
private final File playerDirectory;
private final String playerUUID;
public LoadFromFile(EntityPlayer player, File originDirectory, String playerUUID)
{
@ -218,7 +254,25 @@ public class PlayerEvent extends LivingEvent
public File getPlayerFile(String suffix)
{
if ("dat".equals(suffix)) throw new IllegalArgumentException("The suffix 'dat' is reserved");
return new File(this.playerDirectory, this.playerUUID+"."+suffix);
return new File(this.getPlayerDirectory(), this.getPlayerUUID() +"."+suffix);
}
/**
* The directory where player data is being stored. Use this
* to locate your mod additional file.
*/
public File getPlayerDirectory()
{
return playerDirectory;
}
/**
* The UUID is the standard for player related file storage.
* It is broken out here for convenience for quick file generation.
*/
public String getPlayerUUID()
{
return playerUUID;
}
}
/**
@ -235,16 +289,8 @@ public class PlayerEvent extends LivingEvent
* corrupt the world state.
*/
public static class SaveToFile extends PlayerEvent {
/**
* The directory where player data is being stored. Use this
* to locate your mod additional file.
*/
public final File playerDirectory;
/**
* The UUID is the standard for player related file storage.
* It is broken out here for convenience for quick file generation.
*/
public final String playerUUID;
private final File playerDirectory;
private final String playerUUID;
public SaveToFile(EntityPlayer player, File originDirectory, String playerUUID)
{
@ -261,7 +307,25 @@ public class PlayerEvent extends LivingEvent
public File getPlayerFile(String suffix)
{
if ("dat".equals(suffix)) throw new IllegalArgumentException("The suffix 'dat' is reserved");
return new File(this.playerDirectory, this.playerUUID+"."+suffix);
return new File(this.getPlayerDirectory(), this.getPlayerUUID() +"."+suffix);
}
/**
* The directory where player data is being stored. Use this
* to locate your mod additional file.
*/
public File getPlayerDirectory()
{
return playerDirectory;
}
/**
* The UUID is the standard for player related file storage.
* It is broken out here for convenience for quick file generation.
*/
public String getPlayerUUID()
{
return playerUUID;
}
}
}

View File

@ -42,14 +42,14 @@ public class PlayerInteractEvent extends PlayerEvent
LEFT_CLICK_BLOCK
}
public final Action action;
public final World world;
public final BlockPos pos;
public final EnumFacing face; // Can be null if unknown
public final Vec3d localPos; // Can be null if unknown
private final Action action;
private final World world;
private final BlockPos pos;
private final EnumFacing face; // Can be null if unknown
private final Vec3d localPos; // Can be null if unknown
public Result useBlock = DEFAULT;
public Result useItem = DEFAULT;
private Result useBlock = DEFAULT;
private Result useItem = DEFAULT;
@Deprecated
public PlayerInteractEvent(EntityPlayer player, Action action, BlockPos pos, EnumFacing face, World world)
@ -63,7 +63,7 @@ public class PlayerInteractEvent extends PlayerEvent
this.action = action;
this.pos = pos;
this.face = face;
if (face == null) useBlock = DENY;
if (face == null) setUseBlock(DENY);
this.world = world;
this.localPos = localPos;
}
@ -72,7 +72,17 @@ public class PlayerInteractEvent extends PlayerEvent
public void setCanceled(boolean cancel)
{
super.setCanceled(cancel);
useBlock = (cancel ? DENY : useBlock == DENY ? DEFAULT : useBlock);
useItem = (cancel ? DENY : useItem == DENY ? DEFAULT : useItem);
setUseBlock((cancel ? DENY : getUseBlock() == DENY ? DEFAULT : getUseBlock()));
setUseItem((cancel ? DENY : getUseItem() == DENY ? DEFAULT : getUseItem()));
}
public Action getAction() { return action; }
public World getWorld() { return world; }
public BlockPos getPos() { return pos; }
public EnumFacing getFace() { return face; }
public Vec3d getLocalPos() { return localPos; }
public Result getUseBlock() { return useBlock; }
public void setUseBlock(Result useBlock) { this.useBlock = useBlock; }
public Result getUseItem() { return useItem; }
public void setUseItem(Result useItem) { this.useItem = useItem; }
}

View File

@ -4,26 +4,30 @@ import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
/**
* This event is fired when a player attempts to view a container during
* player tick.
*
* setResult ALLOW to allow the container to stay open
* setResult DENY to force close the container (denying access)
*
* DEFAULT is vanilla behavior
*
*/
@HasResult
public class PlayerOpenContainerEvent extends PlayerEvent
{
public final boolean canInteractWith;
/**
* This event is fired when a player attempts to view a container during
* player tick.
*
* setResult ALLOW to allow the container to stay open
* setResult DENY to force close the container (denying access)
*
* DEFAULT is vanilla behavior
*
*/
private final boolean canInteractWith;
public PlayerOpenContainerEvent(EntityPlayer player, Container openContainer)
{
super(player);
this.canInteractWith = openContainer.canInteractWith(player);
}
public boolean isCanInteractWith()
{
return canInteractWith;
}
}

View File

@ -11,11 +11,16 @@ import net.minecraft.entity.player.EntityPlayer;
@Cancelable
public class PlayerPickupXpEvent extends PlayerEvent
{
public final EntityXPOrb orb;
private final EntityXPOrb orb;
public PlayerPickupXpEvent(EntityPlayer player, EntityXPOrb orb)
{
super(player);
this.orb = orb;
}
public EntityXPOrb getOrb()
{
return orb;
}
}

View File

@ -7,12 +7,8 @@ import net.minecraft.util.math.BlockPos;
@Cancelable
public class PlayerSetSpawnEvent extends PlayerEvent
{
/**
* This event is called before a player's spawn point is changed.
* The event can be canceled, and no further processing will be done.
*/
public final boolean forced;
public final BlockPos newSpawn;
private final boolean forced;
private final BlockPos newSpawn;
public PlayerSetSpawnEvent(EntityPlayer player, BlockPos newSpawn, boolean forced) {
super(player);
@ -20,4 +16,17 @@ public class PlayerSetSpawnEvent extends PlayerEvent
this.forced = forced;
}
/**
* This event is called before a player's spawn point is changed.
* The event can be canceled, and no further processing will be done.
*/
public boolean isForced()
{
return forced;
}
public BlockPos getNewSpawn()
{
return newSpawn;
}
}

View File

@ -20,8 +20,8 @@ import net.minecraft.util.math.BlockPos;
**/
public class PlayerSleepInBedEvent extends PlayerEvent
{
public EnumStatus result = null;
public final BlockPos pos;
private EnumStatus result = null;
private final BlockPos pos;
public PlayerSleepInBedEvent(EntityPlayer player, BlockPos pos)
{
@ -29,4 +29,18 @@ public class PlayerSleepInBedEvent extends PlayerEvent
this.pos = pos;
}
public EnumStatus getResultStatus()
{
return result;
}
public void setResult(EnumStatus result)
{
this.result = result;
}
public BlockPos getPos()
{
return pos;
}
}

View File

@ -17,7 +17,7 @@ import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
public class SleepingLocationCheckEvent extends PlayerEvent
{
public final BlockPos sleepingLocation;
private final BlockPos sleepingLocation;
public SleepingLocationCheckEvent(EntityPlayer player, BlockPos sleepingLocation)
{
@ -25,4 +25,8 @@ public class SleepingLocationCheckEvent extends PlayerEvent
this.sleepingLocation = sleepingLocation;
}
public BlockPos getSleepingLocation()
{
return sleepingLocation;
}
}

View File

@ -7,23 +7,23 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
/**
* This event is fired when a player attempts to use a Hoe on a block, it
* can be canceled to completely prevent any further processing.
*
* You can also set the result to ALLOW to mark the event as processed
* and damage the hoe.
*
* setResult(ALLOW) is the same as the old setHandled();
*/
@Cancelable
@Event.HasResult
public class UseHoeEvent extends PlayerEvent
{
/**
* This event is fired when a player attempts to use a Hoe on a block, it
* can be canceled to completely prevent any further processing.
*
* You can also set the result to ALLOW to mark the event as processed
* and damage the hoe.
*
* setResult(ALLOW) is the same as the old setHandled();
*/
public final ItemStack current;
public final World world;
public final BlockPos pos;
private final ItemStack current;
private final World world;
private final BlockPos pos;
public UseHoeEvent(EntityPlayer player, ItemStack current, World world, BlockPos pos)
{
@ -32,4 +32,19 @@ public class UseHoeEvent extends PlayerEvent
this.world = world;
this.pos = pos;
}
public ItemStack getCurrent()
{
return current;
}
public World getWorld()
{
return world;
}
public BlockPos getPos()
{
return pos;
}
}

View File

@ -1,7 +1,6 @@
package net.minecraftforge.event.terraingen;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
import net.minecraft.block.state.IBlockState;
import net.minecraft.world.biome.BiomeDecorator;
import net.minecraft.world.biome.BiomeGenBase;
@ -15,13 +14,18 @@ import net.minecraft.world.biome.BiomeGenBase;
**/
public class BiomeEvent extends Event
{
public final BiomeGenBase biome;
private final BiomeGenBase biome;
public BiomeEvent(BiomeGenBase biome)
{
this.biome = biome;
}
public BiomeGenBase getBiome()
{
return biome;
}
/**
* CreateDecorator is fired when a BiomeDecorator is created.<br>
* This event is fired whenever a BiomeDecorator is created in
@ -38,14 +42,29 @@ public class BiomeEvent extends Event
**/
public static class CreateDecorator extends BiomeEvent
{
public final BiomeDecorator originalBiomeDecorator;
public BiomeDecorator newBiomeDecorator;
private final BiomeDecorator originalBiomeDecorator;
private BiomeDecorator newBiomeDecorator;
public CreateDecorator(BiomeGenBase biome, BiomeDecorator original)
{
super(biome);
originalBiomeDecorator = original;
newBiomeDecorator = original;
setNewBiomeDecorator(original);
}
public BiomeDecorator getOriginalBiomeDecorator()
{
return originalBiomeDecorator;
}
public BiomeDecorator getNewBiomeDecorator()
{
return newBiomeDecorator;
}
public void setNewBiomeDecorator(BiomeDecorator newBiomeDecorator)
{
this.newBiomeDecorator = newBiomeDecorator;
}
}
@ -58,14 +77,29 @@ public class BiomeEvent extends Event
**/
public static class BiomeColor extends BiomeEvent
{
public final int originalColor;
public int newColor;
private final int originalColor;
private int newColor;
public BiomeColor(BiomeGenBase biome, int original)
{
super(biome);
originalColor = original;
newColor = original;
setNewColor(original);
}
public int getOriginalColor()
{
return originalColor;
}
public int getNewColor()
{
return newColor;
}
public void setNewColor(int newColor)
{
this.newColor = newColor;
}
}
@ -78,14 +112,29 @@ public class BiomeEvent extends Event
@HasResult
public static class GetVillageBlockID extends BiomeEvent
{
public final IBlockState original;
public IBlockState replacement;
private final IBlockState original;
private IBlockState replacement;
public GetVillageBlockID(BiomeGenBase biome, IBlockState original)
{
super(biome);
this.original = original;
}
public IBlockState getOriginal()
{
return original;
}
public IBlockState getReplacement()
{
return replacement;
}
public void setReplacement(IBlockState replacement)
{
this.replacement = replacement;
}
}
/**

View File

@ -14,7 +14,12 @@ public class ChunkGeneratorEvent extends Event
this.gen = gen;
}
public IChunkGenerator getGenerator() { return this.gen; }
public IChunkGenerator getGenerator() { return this.getGen(); }
public IChunkGenerator getGen()
{
return gen;
}
/**
* This event is fired when a chunks blocks are replaced by a biomes top and
@ -25,10 +30,10 @@ public class ChunkGeneratorEvent extends Event
@HasResult
public static class ReplaceBiomeBlocks extends ChunkGeneratorEvent
{
public final int x;
public final int z;
public final ChunkPrimer primer;
public final World world; // CAN BE NULL
private final int x;
private final int z;
private final ChunkPrimer primer;
private final World world; // CAN BE NULL
public ReplaceBiomeBlocks(IChunkGenerator chunkProvider, int x, int z, ChunkPrimer primer, World world)
{
@ -39,6 +44,10 @@ public class ChunkGeneratorEvent extends Event
this.world = world;
}
public int getX() { return x; }
public int getZ() { return z; }
public ChunkPrimer getPrimer() { return primer; }
public World getWorld() { return world; }
}
/**
@ -49,18 +58,18 @@ public class ChunkGeneratorEvent extends Event
@HasResult
public static class InitNoiseField extends ChunkGeneratorEvent
{
public double[] noisefield;
public final int posX;
public final int posY;
public final int posZ;
public final int sizeX;
public final int sizeY;
public final int sizeZ;
private double[] noisefield;
private final int posX;
private final int posY;
private final int posZ;
private final int sizeX;
private final int sizeY;
private final int sizeZ;
public InitNoiseField(IChunkGenerator chunkProvider, double[] noisefield, int posX, int posY, int posZ, int sizeX, int sizeY, int sizeZ)
{
super(chunkProvider);
this.noisefield = noisefield;
this.setNoisefield(noisefield);
this.posX = posX;
this.posY = posY;
this.posZ = posZ;
@ -69,5 +78,13 @@ public class ChunkGeneratorEvent extends Event
this.sizeZ = sizeZ;
}
public double[] getNoisefield() { return noisefield; }
public void setNoisefield(double[] noisefield) { this.noisefield = noisefield; }
public int getPosX() { return posX; }
public int getPosY() { return posY; }
public int getPosZ() { return posZ; }
public int getSizeX() { return sizeX; }
public int getSizeY() { return sizeY; }
public int getSizeZ() { return sizeZ; }
}
}

View File

@ -23,9 +23,9 @@ import net.minecraft.world.World;
**/
public class DecorateBiomeEvent extends Event
{
public final World world;
public final Random rand;
public final BlockPos pos;
private final World world;
private final Random rand;
private final BlockPos pos;
public DecorateBiomeEvent(World world, Random rand, BlockPos pos)
{
@ -34,6 +34,21 @@ public class DecorateBiomeEvent extends Event
this.pos = pos;
}
public World getWorld()
{
return world;
}
public Random getRand()
{
return rand;
}
public BlockPos getPos()
{
return pos;
}
/**
* This event is fired before a chunk is decorated with a biome feature.
*/
@ -64,11 +79,16 @@ public class DecorateBiomeEvent extends Event
@HasResult
public static class Decorate extends DecorateBiomeEvent
{
public EventType getType()
{
return type;
}
/** Use CUSTOM to filter custom event types
*/
public static enum EventType { BIG_SHROOM, CACTUS, CLAY, DEAD_BUSH, LILYPAD, FLOWERS, GRASS, LAKE_WATER, LAKE_LAVA, PUMPKIN, REED, SAND, SAND_PASS2, SHROOM, TREE, CUSTOM }
public final EventType type;
private final EventType type;
public Decorate(World world, Random rand, BlockPos pos, EventType type)
{

View File

@ -41,6 +41,6 @@ public class DeferredBiomeDecorator extends BiomeDecorator {
BiomeEvent.CreateDecorator event = new BiomeEvent.CreateDecorator(biome, wrapped);
MinecraftForge.TERRAIN_GEN_BUS.post(event);
biome.theBiomeDecorator = event.newBiomeDecorator;
biome.theBiomeDecorator = event.getNewBiomeDecorator();
}
}

View File

@ -9,14 +9,18 @@ public class InitMapGenEvent extends Event
*/
public static enum EventType { CAVE, MINESHAFT, NETHER_BRIDGE, NETHER_CAVE, RAVINE, SCATTERED_FEATURE, STRONGHOLD, VILLAGE, OCEAN_MONUMENT, CUSTOM }
public final EventType type;
public final MapGenBase originalGen;
public MapGenBase newGen;
private final EventType type;
private final MapGenBase originalGen;
private MapGenBase newGen;
InitMapGenEvent(EventType type, MapGenBase original)
{
this.type = type;
this.originalGen = original;
this.newGen = original;
this.setNewGen(original);
}
public EventType getType() { return type; }
public MapGenBase getOriginalGen() { return originalGen; }
public MapGenBase getNewGen() { return newGen; }
public void setNewGen(MapGenBase newGen) { this.newGen = newGen; }
}

View File

@ -20,9 +20,9 @@ import net.minecraft.world.gen.feature.WorldGenerator;
**/
public class OreGenEvent extends Event
{
public final World world;
public final Random rand;
public final BlockPos pos;
private final World world;
private final Random rand;
private final BlockPos pos;
public OreGenEvent(World world, Random rand, BlockPos pos)
{
@ -31,6 +31,21 @@ public class OreGenEvent extends Event
this.pos = pos;
}
public World getWorld()
{
return world;
}
public Random getRand()
{
return rand;
}
public BlockPos getPos()
{
return pos;
}
/**
* OreGenEvent.Pre is fired just before a chunk is populated with ores.<br>
* This event is fired just before ore generation in
@ -89,8 +104,8 @@ public class OreGenEvent extends Event
{
public static enum EventType { COAL, DIAMOND, DIRT, GOLD, GRAVEL, IRON, LAPIS, REDSTONE, QUARTZ, DIORITE, GRANITE, ANDESITE, EMERALD, SILVERFISH, CUSTOM }
public final EventType type;
public final WorldGenerator generator;
private final EventType type;
private final WorldGenerator generator;
public GenerateMinable(World world, Random rand, WorldGenerator generator, BlockPos pos, EventType type)
{
@ -98,5 +113,15 @@ public class OreGenEvent extends Event
this.generator = generator;
this.type = type;
}
public EventType getType()
{
return type;
}
public WorldGenerator getGenerator()
{
return generator;
}
}
}

View File

@ -23,11 +23,11 @@ import net.minecraftforge.fml.common.eventhandler.Event;
**/
public class PopulateChunkEvent extends ChunkGeneratorEvent
{
public final World world;
public final Random rand;
public final int chunkX;
public final int chunkZ;
public final boolean hasVillageGenerated;
private final World world;
private final Random rand;
private final int chunkX;
private final int chunkZ;
private final boolean hasVillageGenerated;
public PopulateChunkEvent(IChunkGenerator gen, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated)
{
@ -39,6 +39,11 @@ public class PopulateChunkEvent extends ChunkGeneratorEvent
this.hasVillageGenerated = hasVillageGenerated;
}
public World getWorld() { return world; }
public Random getRand() { return rand; }
public int getChunkX() { return chunkX; }
public int getChunkZ() { return chunkZ; }
public boolean isHasVillageGenerated() { return hasVillageGenerated; }
/**
* PopulateChunkEvent.Pre is fired just before a chunk is populated a terrain feature.<br>
* This event is fired just before terrain feature generation in
@ -100,11 +105,16 @@ public class PopulateChunkEvent extends ChunkGeneratorEvent
@HasResult
public static class Populate extends PopulateChunkEvent
{
public EventType getType()
{
return type;
}
/** Use CUSTOM to filter custom event types
*/
public static enum EventType { DUNGEON, FIRE, GLOWSTONE, ICE, LAKE, LAVA, NETHER_LAVA, NETHER_LAVA2, ANIMALS, CUSTOM }
public final EventType type;
private final EventType type;
public Populate(IChunkGenerator gen, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated, EventType type)
{

View File

@ -24,8 +24,8 @@ import net.minecraftforge.event.world.WorldEvent;
@HasResult
public class SaplingGrowTreeEvent extends WorldEvent
{
public final BlockPos pos;
public final Random rand;
private final BlockPos pos;
private final Random rand;
public SaplingGrowTreeEvent(World world, Random rand, BlockPos pos)
{
@ -33,4 +33,14 @@ public class SaplingGrowTreeEvent extends WorldEvent
this.rand = rand;
this.pos = pos;
}
public BlockPos getPos()
{
return pos;
}
public Random getRand()
{
return rand;
}
}

View File

@ -26,7 +26,7 @@ public abstract class TerrainGen
{
InitMapGenEvent event = new InitMapGenEvent(type, original);
MinecraftForge.TERRAIN_GEN_BUS.post(event);
return event.newGen;
return event.getNewGen();
}
public static boolean populate(IChunkGenerator chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated, Populate.EventType type)

View File

@ -15,13 +15,18 @@ import net.minecraft.world.WorldType;
**/
public class WorldTypeEvent extends Event
{
public final WorldType worldType;
private final WorldType worldType;
public WorldTypeEvent(WorldType worldType)
{
this.worldType = worldType;
}
public WorldType getWorldType()
{
return worldType;
}
/**
* BiomeSize is fired when vanilla Minecraft attempts to generate biomes.<br>
* This event is fired during biome generation in
@ -39,14 +44,29 @@ public class WorldTypeEvent extends Event
**/
public static class BiomeSize extends WorldTypeEvent
{
public final int originalSize;
public int newSize;
private final int originalSize;
private int newSize;
public BiomeSize(WorldType worldType, int original)
{
super(worldType);
originalSize = original;
newSize = original;
setNewSize(original);
}
public int getOriginalSize()
{
return originalSize;
}
public int getNewSize()
{
return newSize;
}
public void setNewSize(int newSize)
{
this.newSize = newSize;
}
}
@ -68,16 +88,36 @@ public class WorldTypeEvent extends Event
**/
public static class InitBiomeGens extends WorldTypeEvent
{
public final long seed;
public final GenLayer[] originalBiomeGens;
public GenLayer[] newBiomeGens;
private final long seed;
private final GenLayer[] originalBiomeGens;
private GenLayer[] newBiomeGens;
public InitBiomeGens(WorldType worldType, long seed, GenLayer[] original)
{
super(worldType);
this.seed = seed;
originalBiomeGens = original;
newBiomeGens = original.clone();
setNewBiomeGens(original.clone());
}
public long getSeed()
{
return seed;
}
public GenLayer[] getOriginalBiomeGens()
{
return originalBiomeGens;
}
public GenLayer[] getNewBiomeGens()
{
return newBiomeGens;
}
public void setNewBiomeGens(GenLayer[] newBiomeGens)
{
this.newBiomeGens = newBiomeGens;
}
}
}

View File

@ -22,9 +22,9 @@ public class BlockEvent extends Event
{
private static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("forge.debugBlockEvent", "false"));
public final World world;
public final BlockPos pos;
public final IBlockState state;
private final World world;
private final BlockPos pos;
private final IBlockState state;
public BlockEvent(World world, BlockPos pos, IBlockState state)
{
this.pos = pos;
@ -32,6 +32,21 @@ public class BlockEvent extends Event
this.state = state;
}
public World getWorld()
{
return world;
}
public BlockPos getPos()
{
return pos;
}
public IBlockState getState()
{
return state;
}
/**
* Fired when a block is about to drop it's harvested items. The {@link #drops} array can be amended, as can the {@link #dropChance}.
* <strong>Note well:</strong> the {@link #harvester} player field is null in a variety of scenarios. Code expecting null.
@ -45,21 +60,28 @@ public class BlockEvent extends Event
*/
public static class HarvestDropsEvent extends BlockEvent
{
public final int fortuneLevel;
public final List<ItemStack> drops;
public final boolean isSilkTouching;
public float dropChance; // Change to e.g. 1.0f, if you manipulate the list and want to guarantee it always drops
public final EntityPlayer harvester; // May be null for non-player harvesting such as explosions or machines
private final int fortuneLevel;
private final List<ItemStack> drops;
private final boolean isSilkTouching;
private float dropChance; // Change to e.g. 1.0f, if you manipulate the list and want to guarantee it always drops
private final EntityPlayer harvester; // May be null for non-player harvesting such as explosions or machines
public HarvestDropsEvent(World world, BlockPos pos, IBlockState state, int fortuneLevel, float dropChance, List<ItemStack> drops, EntityPlayer harvester, boolean isSilkTouching)
{
super(world, pos, state);
this.fortuneLevel = fortuneLevel;
this.dropChance = dropChance;
this.setDropChance(dropChance);
this.drops = drops;
this.isSilkTouching = isSilkTouching;
this.harvester = harvester;
}
public int getFortuneLevel() { return fortuneLevel; }
public List<ItemStack> getDrops() { return drops; }
public boolean isSilkTouching() { return isSilkTouching; }
public float getDropChance() { return dropChance; }
public void setDropChance(float dropChance) { this.dropChance = dropChance; }
public EntityPlayer getHarvester() { return harvester; }
}
/**
@ -124,11 +146,11 @@ public class BlockEvent extends Event
@Cancelable
public static class PlaceEvent extends BlockEvent
{
public final EntityPlayer player;
public final ItemStack itemInHand;
public final BlockSnapshot blockSnapshot;
public final IBlockState placedBlock;
public final IBlockState placedAgainst;
private final EntityPlayer player;
private final ItemStack itemInHand;
private final BlockSnapshot blockSnapshot;
private final IBlockState placedBlock;
private final IBlockState placedAgainst;
public PlaceEvent(BlockSnapshot blockSnapshot, IBlockState placedAgainst, EntityPlayer player)
{
@ -140,9 +162,15 @@ public class BlockEvent extends Event
this.placedAgainst = placedAgainst;
if (DEBUG)
{
System.out.printf("Created PlaceEvent - [PlacedBlock: %s ][PlacedAgainst: %s ][ItemStack: %s ][Player: %s ]\n", placedBlock, placedAgainst, itemInHand, player);
System.out.printf("Created PlaceEvent - [PlacedBlock: %s ][PlacedAgainst: %s ][ItemStack: %s ][Player: %s ]\n", getPlacedBlock(), placedAgainst, getItemInHand(), player);
}
}
public EntityPlayer getPlayer() { return player; }
public ItemStack getItemInHand() { return itemInHand; }
public BlockSnapshot getBlockSnapshot() { return blockSnapshot; }
public IBlockState getPlacedBlock() { return placedBlock; }
public IBlockState getPlacedAgainst() { return placedAgainst; }
}
/**
@ -163,7 +191,7 @@ public class BlockEvent extends Event
this.blockSnapshots = ImmutableList.copyOf(blockSnapshots);
if (DEBUG)
{
System.out.printf("Created MultiPlaceEvent - [PlacedAgainst: %s ][ItemInHand: %s ][Player: %s ]\n", placedAgainst, this.itemInHand, player);
System.out.printf("Created MultiPlaceEvent - [PlacedAgainst: %s ][ItemInHand: %s ][Player: %s ]\n", placedAgainst, this.getItemInHand(), player);
}
}

View File

@ -16,15 +16,25 @@ import net.minecraft.entity.player.EntityPlayerMP;
**/
public class ChunkWatchEvent extends Event
{
public final ChunkCoordIntPair chunk;
public final EntityPlayerMP player;
private final ChunkCoordIntPair chunk;
private final EntityPlayerMP player;
public ChunkWatchEvent(ChunkCoordIntPair chunk, EntityPlayerMP player)
{
this.chunk = chunk;
this.player = player;
}
public ChunkCoordIntPair getChunk()
{
return chunk;
}
public EntityPlayerMP getPlayer()
{
return player;
}
/**
* ChunkWatchEvent.Watch is fired when an EntityPlayer begins watching a chunk.<br>
* This event is fired when a chunk is added to the watched chunks of an EntityPlayer in

View File

@ -21,8 +21,8 @@ import net.minecraft.world.World;
*/
public class ExplosionEvent extends Event
{
public final World world;
public final Explosion explosion;
private final World world;
private final Explosion explosion;
public ExplosionEvent(World world, Explosion explosion)
{
@ -30,6 +30,16 @@ public class ExplosionEvent extends Event
this.explosion = explosion;
}
public World getWorld()
{
return world;
}
public Explosion getExplosion()
{
return explosion;
}
/** ExplosionEvent.Start is fired before the explosion actually occurs. Canceling this event will stop the explosion.<br>
* <br>
* This event is {@link Cancelable}.<br>
@ -64,7 +74,7 @@ public class ExplosionEvent extends Event
/** return the list of blocks affected by the explosion. */
public List<BlockPos> getAffectedBlocks()
{
return explosion.getAffectedBlockPositions();
return getExplosion().getAffectedBlockPositions();
}
/** return the list of entities affected by the explosion. */

View File

@ -67,12 +67,22 @@ public class NoteBlockEvent extends BlockEvent
@Cancelable
public static class Play extends NoteBlockEvent
{
public Instrument instrument;
private Instrument instrument;
public Play(World world, BlockPos pos, IBlockState state, int note, int instrument)
{
super(world, pos, state, note);
this.instrument = Instrument.fromId(instrument);
this.setInstrument(Instrument.fromId(instrument));
}
public Instrument getInstrument()
{
return instrument;
}
public void setInstrument(Instrument instrument)
{
this.instrument = instrument;
}
}
@ -83,8 +93,8 @@ public class NoteBlockEvent extends BlockEvent
@Cancelable
public static class Change extends NoteBlockEvent
{
public final Note oldNote;
public final Octave oldOctave;
private final Note oldNote;
private final Octave oldOctave;
public Change(World world, BlockPos pos, IBlockState state, int oldNote, int newNote)
{
@ -92,6 +102,16 @@ public class NoteBlockEvent extends BlockEvent
this.oldNote = Note.fromId(oldNote);
this.oldOctave = Octave.fromId(oldNote);
}
public Note getOldNote()
{
return oldNote;
}
public Octave getOldOctave()
{
return oldOctave;
}
}
/**

View File

@ -22,13 +22,18 @@ import net.minecraftforge.fml.common.eventhandler.Event;
**/
public class WorldEvent extends Event
{
public final World world;
private final World world;
public WorldEvent(World world)
{
this.world = world;
}
public World getWorld()
{
return world;
}
/**
* WorldEvent.Load is fired when Minecraft loads a world.<br>
* This event is fired when a world is loaded in
@ -96,9 +101,9 @@ public class WorldEvent extends Event
@Cancelable
public static class PotentialSpawns extends WorldEvent
{
public final EnumCreatureType type;
public final BlockPos pos;
public final List<SpawnListEntry> list;
private final EnumCreatureType type;
private final BlockPos pos;
private final List<SpawnListEntry> list;
public PotentialSpawns(World world, EnumCreatureType type, BlockPos pos, List<SpawnListEntry> oldList)
{
@ -114,6 +119,21 @@ public class WorldEvent extends Event
this.list = new ArrayList<SpawnListEntry>();
}
}
public EnumCreatureType getType()
{
return type;
}
public BlockPos getPos()
{
return pos;
}
public List<SpawnListEntry> getList()
{
return list;
}
}
/**
@ -123,11 +143,16 @@ public class WorldEvent extends Event
@Cancelable
public static class CreateSpawnPosition extends WorldEvent
{
public final WorldSettings settings;
private final WorldSettings settings;
public CreateSpawnPosition(World world, WorldSettings settings)
{
super(world);
this.settings = settings;
}
public WorldSettings getSettings()
{
return settings;
}
}
}

View File

@ -389,11 +389,16 @@ public abstract class FluidContainerRegistry
public static class FluidContainerRegisterEvent extends Event
{
public final FluidContainerData data;
private final FluidContainerData data;
public FluidContainerRegisterEvent(FluidContainerData data)
{
this.data = data.copy();
}
public FluidContainerData getData()
{
return data;
}
}
}

Some files were not shown because too many files have changed in this diff Show More