First push of some small patches and introduction of basic events. As well as the first cases for Forge's Access Transformer

This commit is contained in:
LexManos 2012-08-05 03:20:07 -07:00
parent 5672b783da
commit 1fb042621c
29 changed files with 1904 additions and 170 deletions

View file

@ -1,20 +1,10 @@
[
{
"modid" : "mod_MinecraftForge",
"name" : "Minecraft Forge",
"version" : "{version}",
"url" : "http://MinecraftForge.net",
"credits" : "Lots of people have contributed to MinecraftForge",
"authors": [
"LexManos",
"Eloraam",
"Spacetoad"
],
"description": "Minecraft Forge is a common open source API allowing a broad range of mods to work cooperatively together.\nIt allows many mods to be created without them editing the main Minecraft code.",
"logoFile" : "/forge_logo.png",
"updateUrl" : "http://minecraftforge.net/forum/index.php/topic,5.0.html",
"parent" : "",
"screenshots": [
]
}
]
#Main Forge Access Transformer configuration file
# RailLogic.getNAdjacentTracks
public ahh.a(Lahh;)I
# Tessellator
public avd.u # drawMode
public avd.v # xOffset
public avd.w # yOffset
public avd.x # zOffset
public-f avd.a # instance remove final
public avd.z # isDrawing

View file

@ -0,0 +1,36 @@
package net.minecraftforge.common;
public enum Orientation
{
/** -Y */
DOWN,
/** +Y */
UP,
/** -Z */
NORTH,
/** +Z */
SOUTH,
/** -X */
WEST,
/** +X */
EAST,
/**
* Used only by getOrientation, for invalid inputs
*/
UNKNOWN;
public static Orientation getOrientation(int id)
{
if (Orientation.values().length < id)
{
return Orientation.values()[id];
}
return UNKNOWN;
}
}

View file

@ -0,0 +1,38 @@
package net.minecraftforge.event.entity;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.ItemStack;
public class ArrowLooseEvent extends PlayerEvent
{
private final ItemStack bow;
private int charge;
public ArrowLooseEvent(EntityPlayer player, ItemStack bow, int charge)
{
super(player);
this.bow = bow;
this.charge = charge;
}
@Override
public boolean isCancelable()
{
return true;
}
public ItemStack getBow()
{
return bow;
}
public int getCharge()
{
return charge;
}
public void setCharge(int charge)
{
this.charge = charge;
}
}

View file

@ -0,0 +1,31 @@
package net.minecraftforge.event.entity;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.ItemStack;
public class ArrowNockEvent extends PlayerEvent
{
private ItemStack result;
public ArrowNockEvent(EntityPlayer player, ItemStack result)
{
super(player);
this.result = result;
}
@Override
public boolean isCancelable()
{
return true;
}
public ItemStack getResultStack()
{
return result;
}
public void setResultStack(ItemStack result)
{
this.result = result;
}
}

View file

@ -0,0 +1,19 @@
package net.minecraftforge.event.entity;
import net.minecraft.src.Entity;
import net.minecraftforge.event.Event;
public class EntityEvent extends Event
{
private final Entity entity;
public EntityEvent(Entity entity)
{
this.entity = entity;
}
public Entity getEntity()
{
return entity;
}
}

View file

@ -0,0 +1,34 @@
package net.minecraftforge.event.entity;
import net.minecraft.src.Entity;
import net.minecraft.src.EntityItem;
import net.minecraft.src.EntityPlayer;
public class EntityItemPickupEvent extends EntityEvent
{
private final EntityItem item;
private final EntityPlayer player;
public EntityItemPickupEvent(EntityItem item, EntityPlayer player)
{
super(item);
this.item = item;
this.player = player;
}
public EntityItem getItem()
{
return item;
}
public EntityPlayer getPlayer()
{
return player;
}
@Override
public boolean isCancelable()
{
return true;
}
}

View file

@ -0,0 +1,66 @@
package net.minecraftforge.event.entity;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.ItemStack;
import net.minecraft.src.MovingObjectPosition;
import net.minecraft.src.World;
public class FillBucketEvent extends PlayerEvent
{
private final ItemStack current;
private final World world;
private final MovingObjectPosition target;
private ItemStack result;
private boolean handeled = false;
public FillBucketEvent(EntityPlayer player, ItemStack current, World world, MovingObjectPosition target)
{
super(player);
this.current = current;
this.world = world;
this.target = target;
}
@Override
public boolean isCancelable()
{
return true;
}
public ItemStack getCurrentItem()
{
return current;
}
public World getWorld()
{
return world;
}
public MovingObjectPosition getTarget()
{
return target;
}
public boolean isHandeled()
{
return handeled;
}
public void setHandeled()
{
handeled = true;
}
public ItemStack getResult()
{
return result;
}
public void setResult(ItemStack result)
{
this.result = result;
}
}

View file

@ -0,0 +1,19 @@
package net.minecraftforge.event.entity;
import net.minecraft.src.Entity;
import net.minecraft.src.EntityPlayer;
public class PlayerEvent extends EntityEvent
{
private final EntityPlayer player;
public PlayerEvent(EntityPlayer player)
{
super(player);
this.player = player;
}
public EntityPlayer getPlayer()
{
return player;
}
}

View file

@ -0,0 +1,36 @@
package net.minecraftforge.event.world;
import net.minecraft.src.Chunk;
import net.minecraft.src.NBTTagCompound;
public class ChunkDataEvent extends ChunkEvent
{
private final NBTTagCompound data;
public ChunkDataEvent(Chunk chunk, NBTTagCompound data)
{
super(chunk);
this.data = data;
}
public NBTTagCompound getData()
{
return data;
}
public static class Load extends ChunkDataEvent
{
public Load(Chunk chunk, NBTTagCompound data)
{
super(chunk, data);
}
}
public static class Save extends ChunkDataEvent
{
public Save(Chunk chunk, NBTTagCompound data)
{
super(chunk, data);
}
}
}

View file

@ -0,0 +1,37 @@
package net.minecraftforge.event.world;
import net.minecraft.src.Chunk;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.World;
public class ChunkEvent extends WorldEvent
{
private final Chunk chunk;
public ChunkEvent(Chunk chunk)
{
super(chunk.worldObj);
this.chunk = chunk;
}
public Chunk getChunk()
{
return chunk;
}
public static class Load extends ChunkEvent
{
public Load(Chunk chunk)
{
super(chunk);
}
}
public static class Unload extends ChunkEvent
{
public Unload(Chunk chunk)
{
super(chunk);
}
}
}

View file

@ -0,0 +1,19 @@
package net.minecraftforge.event.world;
import net.minecraft.src.World;
import net.minecraftforge.event.Event;
public class WorldEvent extends Event
{
private final World world;
public WorldEvent(World world)
{
this.world = world;
}
public World getWorld()
{
return world;
}
}

View file

@ -1,150 +0,0 @@
!SESSION 2012-08-02 22:58:54.381 -----------------------------------------------
eclipse.buildId=I20120608-1400
java.version=1.7.0_05
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments: -product org.eclipse.epp.package.java.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product
!ENTRY org.eclipse.core.contenttype 4 0 2012-08-02 23:03:18.905
!MESSAGE Could not create content describer for org.eclipse.wb.core.javaSourceGUI. Content type has been disabled.
!STACK 0
java.lang.NullPointerException
at org.eclipse.wb.internal.core.DesignerPlugin.getPreferences(DesignerPlugin.java:103)
at org.eclipse.wb.internal.core.editor.describer.JavaSourceUiDescriber.isGUISource(JavaSourceUiDescriber.java:65)
at org.eclipse.wb.internal.core.editor.describer.JavaSourceUiDescriber.describe(JavaSourceUiDescriber.java:52)
at org.eclipse.core.internal.content.ContentTypeCatalog.describe(ContentTypeCatalog.java:218)
at org.eclipse.core.internal.content.ContentTypeCatalog.collectMatchingByContents(ContentTypeCatalog.java:190)
at org.eclipse.core.internal.content.ContentTypeCatalog.internalFindContentTypesFor(ContentTypeCatalog.java:403)
at org.eclipse.core.internal.content.ContentTypeCatalog.internalFindContentTypesFor(ContentTypeCatalog.java:450)
at org.eclipse.core.internal.content.ContentTypeCatalog.getDescriptionFor(ContentTypeCatalog.java:346)
at org.eclipse.core.internal.content.ContentTypeCatalog.getDescriptionFor(ContentTypeCatalog.java:360)
at org.eclipse.core.internal.content.ContentTypeMatcher.getDescriptionFor(ContentTypeMatcher.java:86)
at org.eclipse.core.internal.resources.ContentDescriptionManager.readDescription(ContentDescriptionManager.java:445)
at org.eclipse.core.internal.resources.ContentDescriptionManager.getDescriptionFor(ContentDescriptionManager.java:355)
at org.eclipse.core.internal.resources.File.internalGetCharset(File.java:246)
at org.eclipse.core.internal.resources.File.getCharset(File.java:207)
at org.eclipse.core.internal.resources.File.getCharset(File.java:194)
at org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsCharArray(Util.java:1156)
at org.eclipse.jdt.internal.core.search.JavaSearchDocument.getCharContents(JavaSearchDocument.java:53)
at org.eclipse.jdt.internal.core.search.indexing.SourceIndexer.indexDocument(SourceIndexer.java:60)
at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.indexDocument(JavaSearchParticipant.java:73)
at org.eclipse.jdt.internal.core.search.indexing.IndexManager.indexDocument(IndexManager.java:462)
at org.eclipse.jdt.internal.core.search.indexing.IndexManager$1.execute(IndexManager.java:886)
at org.eclipse.jdt.internal.core.search.processing.JobManager.run(JobManager.java:405)
at java.lang.Thread.run(Unknown Source)
!SESSION 2012-08-02 23:21:22.086 -----------------------------------------------
eclipse.buildId=I20120608-1400
java.version=1.7.0_05
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments: -product org.eclipse.epp.package.java.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product
!ENTRY org.eclipse.core.contenttype 4 0 2012-08-02 23:22:30.532
!MESSAGE Could not create content describer for org.eclipse.wb.core.javaSourceGUI. Content type has been disabled.
!STACK 0
java.lang.NullPointerException
at org.eclipse.wb.internal.core.DesignerPlugin.getPreferences(DesignerPlugin.java:103)
at org.eclipse.wb.internal.core.editor.describer.JavaSourceUiDescriber.isGUISource(JavaSourceUiDescriber.java:65)
at org.eclipse.wb.internal.core.editor.describer.JavaSourceUiDescriber.describe(JavaSourceUiDescriber.java:52)
at org.eclipse.core.internal.content.ContentTypeCatalog.describe(ContentTypeCatalog.java:218)
at org.eclipse.core.internal.content.ContentTypeCatalog.collectMatchingByContents(ContentTypeCatalog.java:190)
at org.eclipse.core.internal.content.ContentTypeCatalog.internalFindContentTypesFor(ContentTypeCatalog.java:403)
at org.eclipse.core.internal.content.ContentTypeCatalog.internalFindContentTypesFor(ContentTypeCatalog.java:450)
at org.eclipse.core.internal.content.ContentTypeCatalog.getDescriptionFor(ContentTypeCatalog.java:346)
at org.eclipse.core.internal.content.ContentTypeCatalog.getDescriptionFor(ContentTypeCatalog.java:360)
at org.eclipse.core.internal.content.ContentTypeMatcher.getDescriptionFor(ContentTypeMatcher.java:86)
at org.eclipse.core.internal.resources.ContentDescriptionManager.readDescription(ContentDescriptionManager.java:445)
at org.eclipse.core.internal.resources.ContentDescriptionManager.getDescriptionFor(ContentDescriptionManager.java:355)
at org.eclipse.core.internal.resources.File.internalGetCharset(File.java:246)
at org.eclipse.core.internal.resources.File.getCharset(File.java:207)
at org.eclipse.core.internal.resources.File.getCharset(File.java:194)
at org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsCharArray(Util.java:1156)
at org.eclipse.jdt.internal.core.search.JavaSearchDocument.getCharContents(JavaSearchDocument.java:53)
at org.eclipse.jdt.internal.core.search.indexing.SourceIndexer.indexDocument(SourceIndexer.java:60)
at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.indexDocument(JavaSearchParticipant.java:73)
at org.eclipse.jdt.internal.core.search.indexing.IndexManager.indexDocument(IndexManager.java:462)
at org.eclipse.jdt.internal.core.search.indexing.IndexManager$1.execute(IndexManager.java:886)
at org.eclipse.jdt.internal.core.search.processing.JobManager.run(JobManager.java:405)
at java.lang.Thread.run(Unknown Source)
!SESSION 2012-08-02 23:28:01.397 -----------------------------------------------
eclipse.buildId=I20120608-1400
java.version=1.7.0_05
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments: -product org.eclipse.epp.package.java.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product
!ENTRY org.eclipse.core.contenttype 4 0 2012-08-02 23:29:44.040
!MESSAGE Could not create content describer for org.eclipse.wb.core.javaSourceGUI. Content type has been disabled.
!STACK 0
java.lang.NullPointerException
at org.eclipse.wb.internal.core.DesignerPlugin.getPreferences(DesignerPlugin.java:103)
at org.eclipse.wb.internal.core.editor.describer.JavaSourceUiDescriber.isGUISource(JavaSourceUiDescriber.java:65)
at org.eclipse.wb.internal.core.editor.describer.JavaSourceUiDescriber.describe(JavaSourceUiDescriber.java:52)
at org.eclipse.core.internal.content.ContentTypeCatalog.describe(ContentTypeCatalog.java:218)
at org.eclipse.core.internal.content.ContentTypeCatalog.collectMatchingByContents(ContentTypeCatalog.java:190)
at org.eclipse.core.internal.content.ContentTypeCatalog.internalFindContentTypesFor(ContentTypeCatalog.java:403)
at org.eclipse.core.internal.content.ContentTypeCatalog.internalFindContentTypesFor(ContentTypeCatalog.java:450)
at org.eclipse.core.internal.content.ContentTypeCatalog.getDescriptionFor(ContentTypeCatalog.java:346)
at org.eclipse.core.internal.content.ContentTypeCatalog.getDescriptionFor(ContentTypeCatalog.java:360)
at org.eclipse.core.internal.content.ContentTypeMatcher.getDescriptionFor(ContentTypeMatcher.java:86)
at org.eclipse.core.internal.resources.ContentDescriptionManager.readDescription(ContentDescriptionManager.java:445)
at org.eclipse.core.internal.resources.ContentDescriptionManager.getDescriptionFor(ContentDescriptionManager.java:355)
at org.eclipse.core.internal.resources.File.internalGetCharset(File.java:246)
at org.eclipse.core.internal.resources.File.getCharset(File.java:207)
at org.eclipse.core.internal.resources.File.getCharset(File.java:194)
at org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsCharArray(Util.java:1156)
at org.eclipse.jdt.internal.core.search.JavaSearchDocument.getCharContents(JavaSearchDocument.java:53)
at org.eclipse.jdt.internal.core.search.indexing.SourceIndexer.indexDocument(SourceIndexer.java:60)
at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.indexDocument(JavaSearchParticipant.java:73)
at org.eclipse.jdt.internal.core.search.indexing.IndexManager.indexDocument(IndexManager.java:462)
at org.eclipse.jdt.internal.core.search.indexing.IndexManager$1.execute(IndexManager.java:886)
at org.eclipse.jdt.internal.core.search.processing.JobManager.run(JobManager.java:405)
at java.lang.Thread.run(Unknown Source)
!ENTRY org.eclipse.core.jobs 4 2 2012-08-02 23:29:44.534
!MESSAGE An internal error occurred during: "Searching for local changes".
!STACK 0
java.lang.NullPointerException
at org.eclipse.core.internal.refresh.PollingMonitor.run(PollingMonitor.java:149)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
!SESSION 2012-08-03 00:08:54.763 -----------------------------------------------
eclipse.buildId=I20120608-1400
java.version=1.7.0_05
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments: -product org.eclipse.epp.package.java.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product
!ENTRY org.eclipse.jdt.ui 4 10001 2012-08-03 01:02:56.471
!MESSAGE Internal Error
!STACK 1
Java Model Exception: Java Model Status [Timed out while retrieving the attached javadoc for Class [in Class.class [in java.lang [in C:\Program Files\Java\jre7\lib\rt.jar]]] ]
at org.eclipse.jdt.internal.core.JavaElement.getURLContents(JavaElement.java:808)
at org.eclipse.jdt.internal.core.BinaryType.getJavadocContents(BinaryType.java:1037)
at org.eclipse.jdt.internal.core.BinaryMethod.getAttachedJavadoc(BinaryMethod.java:639)
at org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.getHTMLContent(JavadocContentAccess2.java:463)
at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo(JavadocHover.java:619)
at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.internalGetHoverInfo(JavadocHover.java:565)
at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo2(JavadocHover.java:557)
at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:163)
at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:129)
at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo2(JavaEditorTextHoverProxy.java:85)
at org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:166)
!SUBENTRY 1 org.eclipse.jdt.core 4 1012 2012-08-03 01:02:56.479
!MESSAGE Timed out while retrieving the attached javadoc for Class [in Class.class [in java.lang [in C:\Program Files\Java\jre7\lib\rt.jar]]]
!SESSION 2012-08-03 01:09:14.440 -----------------------------------------------
eclipse.buildId=I20120608-1400
java.version=1.7.0_05
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments: -product org.eclipse.epp.package.java.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product
!ENTRY org.eclipse.m2e.logback.appender 4 0 2012-08-03 01:36:04.826
!MESSAGE Failed to open search index.
!ENTRY org.eclipse.m2e.logback.appender 4 0 2012-08-03 01:38:09.454
!MESSAGE Failed to open search index.

View file

@ -0,0 +1,28 @@
--- ../src_base/common/net/minecraft/src/AnvilChunkLoader.java
+++ ../src_work/common/net/minecraft/src/AnvilChunkLoader.java
@@ -10,6 +10,9 @@
import java.util.List;
import java.util.Set;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.world.ChunkDataEvent;
+
public class AnvilChunkLoader implements IThreadedFileIO, IChunkLoader
{
private List chunksToRemove = new ArrayList();
@@ -94,6 +97,7 @@
var5 = this.readChunkFromNBT(par1World, par4NBTTagCompound.getCompoundTag("Level"));
}
+ MinecraftForge.eventBus.post(new ChunkDataEvent.Load(var5, par4NBTTagCompound));
return var5;
}
}
@@ -109,6 +113,7 @@
var3.setTag("Level", var4);
this.writeChunkToNBT(par2Chunk, par1World, var4);
this.func_75824_a(par2Chunk.getChunkCoordIntPair(), var3);
+ MinecraftForge.eventBus.post(new ChunkDataEvent.Save(par2Chunk, var3));
}
catch (Exception var5)
{

View file

@ -0,0 +1,106 @@
--- ../src_base/common/net/minecraft/src/BlockButton.java
+++ ../src_work/common/net/minecraft/src/BlockButton.java
@@ -1,6 +1,10 @@
package net.minecraft.src;
import java.util.Random;
+
+import net.minecraftforge.common.Orientation;
+
+import static net.minecraftforge.common.Orientation.*;
public class BlockButton extends Block
{
@@ -50,7 +54,11 @@
*/
public boolean canPlaceBlockOnSide(World par1World, int par2, int par3, int par4, int par5)
{
- return par5 == 2 && par1World.isBlockNormalCube(par2, par3, par4 + 1) ? true : (par5 == 3 && par1World.isBlockNormalCube(par2, par3, par4 - 1) ? true : (par5 == 4 && par1World.isBlockNormalCube(par2 + 1, par3, par4) ? true : par5 == 5 && par1World.isBlockNormalCube(par2 - 1, par3, par4)));
+ Orientation dir = Orientation.getOrientation(par5);
+ return (dir == NORTH && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH)) ||
+ (dir == SOUTH && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH)) ||
+ (dir == WEST && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST)) ||
+ (dir == EAST && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST));
}
/**
@@ -58,7 +66,10 @@
*/
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
{
- return par1World.isBlockNormalCube(par2 - 1, par3, par4) ? true : (par1World.isBlockNormalCube(par2 + 1, par3, par4) ? true : (par1World.isBlockNormalCube(par2, par3, par4 - 1) ? true : par1World.isBlockNormalCube(par2, par3, par4 + 1)));
+ return (par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST)) ||
+ (par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST)) ||
+ (par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH)) ||
+ (par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH));
}
/**
@@ -69,20 +80,22 @@
int var9 = par1World.getBlockMetadata(par2, par3, par4);
int var10 = var9 & 8;
var9 &= 7;
-
- if (par5 == 2 && par1World.isBlockNormalCube(par2, par3, par4 + 1))
+
+ Orientation dir = Orientation.getOrientation(par5);
+
+ if (dir == NORTH && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH))
{
var9 = 4;
}
- else if (par5 == 3 && par1World.isBlockNormalCube(par2, par3, par4 - 1))
+ else if (dir == SOUTH && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH))
{
var9 = 3;
}
- else if (par5 == 4 && par1World.isBlockNormalCube(par2 + 1, par3, par4))
+ else if (dir == WEST && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST))
{
var9 = 2;
}
- else if (par5 == 5 && par1World.isBlockNormalCube(par2 - 1, par3, par4))
+ else if (dir == EAST && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST))
{
var9 = 1;
}
@@ -99,7 +112,11 @@
*/
private int getOrientation(World par1World, int par2, int par3, int par4)
{
- return par1World.isBlockNormalCube(par2 - 1, par3, par4) ? 1 : (par1World.isBlockNormalCube(par2 + 1, par3, par4) ? 2 : (par1World.isBlockNormalCube(par2, par3, par4 - 1) ? 3 : (par1World.isBlockNormalCube(par2, par3, par4 + 1) ? 4 : 1)));
+ if (par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST)) return 1;
+ if (par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST)) return 2;
+ if (par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH)) return 3;
+ if (par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH)) return 4;
+ return 1;
}
/**
@@ -113,22 +130,22 @@
int var6 = par1World.getBlockMetadata(par2, par3, par4) & 7;
boolean var7 = false;
- if (!par1World.isBlockNormalCube(par2 - 1, par3, par4) && var6 == 1)
+ if (!par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST) && var6 == 1)
{
var7 = true;
}
- if (!par1World.isBlockNormalCube(par2 + 1, par3, par4) && var6 == 2)
+ if (!par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST) && var6 == 2)
{
var7 = true;
}
- if (!par1World.isBlockNormalCube(par2, par3, par4 - 1) && var6 == 3)
+ if (!par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH) && var6 == 3)
{
var7 = true;
}
- if (!par1World.isBlockNormalCube(par2, par3, par4 + 1) && var6 == 4)
+ if (!par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH) && var6 == 4)
{
var7 = true;
}

View file

@ -0,0 +1,157 @@
--- ../src_base/common/net/minecraft/src/BlockLever.java
+++ ../src_work/common/net/minecraft/src/BlockLever.java
@@ -1,4 +1,7 @@
package net.minecraft.src;
+
+import net.minecraftforge.common.Orientation;
+import static net.minecraftforge.common.Orientation.*;
public class BlockLever extends Block
{
@@ -47,7 +50,13 @@
*/
public boolean canPlaceBlockOnSide(World par1World, int par2, int par3, int par4, int par5)
{
- return par5 == 0 && par1World.isBlockNormalCube(par2, par3 + 1, par4) ? true : (par5 == 1 && par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) ? true : (par5 == 2 && par1World.isBlockNormalCube(par2, par3, par4 + 1) ? true : (par5 == 3 && par1World.isBlockNormalCube(par2, par3, par4 - 1) ? true : (par5 == 4 && par1World.isBlockNormalCube(par2 + 1, par3, par4) ? true : par5 == 5 && par1World.isBlockNormalCube(par2 - 1, par3, par4)))));
+ Orientation dir = Orientation.getOrientation(par5);
+ return (dir == DOWN && par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN )) ||
+ (dir == UP && par1World.isBlockSolidOnSide(par2, par3 - 1, par4, UP )) ||
+ (dir == NORTH && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH)) ||
+ (dir == SOUTH && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH)) ||
+ (dir == WEST && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST )) ||
+ (dir == EAST && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST ));
}
/**
@@ -55,7 +64,12 @@
*/
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
{
- return par1World.isBlockNormalCube(par2 - 1, par3, par4) ? true : (par1World.isBlockNormalCube(par2 + 1, par3, par4) ? true : (par1World.isBlockNormalCube(par2, par3, par4 - 1) ? true : (par1World.isBlockNormalCube(par2, par3, par4 + 1) ? true : (par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) ? true : par1World.isBlockNormalCube(par2, par3 + 1, par4)))));
+ return par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST ) ||
+ par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST ) ||
+ par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH) ||
+ par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH) ||
+ par1World.isBlockSolidOnSide(par2, par3 - 1, par4, UP ) ||
+ par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN );
}
/**
@@ -68,32 +82,32 @@
var9 &= 7;
var9 = -1;
- if (par5 == 0 && par1World.isBlockNormalCube(par2, par3 + 1, par4))
+ if (par5 == 0 && par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN))
{
var9 = par1World.rand.nextBoolean() ? 0 : 7;
}
- if (par5 == 1 && par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4))
+ if (par5 == 1 && par1World.isBlockSolidOnSide(par2, par3 - 1, par4, UP))
{
var9 = 5 + par1World.rand.nextInt(2);
}
- if (par5 == 2 && par1World.isBlockNormalCube(par2, par3, par4 + 1))
+ if (par5 == 2 && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH))
{
var9 = 4;
}
- if (par5 == 3 && par1World.isBlockNormalCube(par2, par3, par4 - 1))
+ if (par5 == 3 && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH))
{
var9 = 3;
}
- if (par5 == 4 && par1World.isBlockNormalCube(par2 + 1, par3, par4))
+ if (par5 == 4 && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST))
{
var9 = 2;
}
- if (par5 == 5 && par1World.isBlockNormalCube(par2 - 1, par3, par4))
+ if (par5 == 5 && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST))
{
var9 = 1;
}
@@ -144,42 +158,42 @@
int var6 = par1World.getBlockMetadata(par2, par3, par4) & 7;
boolean var7 = false;
- if (!par1World.isBlockNormalCube(par2 - 1, par3, par4) && var6 == 1)
- {
- var7 = true;
- }
-
- if (!par1World.isBlockNormalCube(par2 + 1, par3, par4) && var6 == 2)
- {
- var7 = true;
- }
-
- if (!par1World.isBlockNormalCube(par2, par3, par4 - 1) && var6 == 3)
- {
- var7 = true;
- }
-
- if (!par1World.isBlockNormalCube(par2, par3, par4 + 1) && var6 == 4)
- {
- var7 = true;
- }
-
- if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) && var6 == 5)
- {
- var7 = true;
- }
-
- if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) && var6 == 6)
- {
- var7 = true;
- }
-
- if (!par1World.isBlockNormalCube(par2, par3 + 1, par4) && var6 == 0)
- {
- var7 = true;
- }
-
- if (!par1World.isBlockNormalCube(par2, par3 + 1, par4) && var6 == 7)
+ if (!par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST) && var6 == 1)
+ {
+ var7 = true;
+ }
+
+ if (!par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST) && var6 == 2)
+ {
+ var7 = true;
+ }
+
+ if (!par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH) && var6 == 3)
+ {
+ var7 = true;
+ }
+
+ if (!par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH) && var6 == 4)
+ {
+ var7 = true;
+ }
+
+ if (!par1World.isBlockSolidOnSide(par2, par3 - 1, par4, UP) && var6 == 5)
+ {
+ var7 = true;
+ }
+
+ if (!par1World.isBlockSolidOnSide(par2, par3 - 1, par4, UP) && var6 == 6)
+ {
+ var7 = true;
+ }
+
+ if (!par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN) && var6 == 0)
+ {
+ var7 = true;
+ }
+
+ if (!par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN) && var6 == 7)
{
var7 = true;
}

View file

@ -0,0 +1,222 @@
--- ../src_base/common/net/minecraft/src/BlockRail.java
+++ ../src_work/common/net/minecraft/src/BlockRail.java
@@ -1,11 +1,27 @@
package net.minecraft.src;
import java.util.Random;
+
+import net.minecraftforge.common.Orientation;
+import static net.minecraftforge.common.Orientation.*;
public class BlockRail extends Block
{
/** Power related rails have this field at true. */
private final boolean isPowered;
+
+ /**
+ * Forge: Moved render type to a field and a setter.
+ * This allows for a mod to change the render type
+ * for vanilla rails, and any mod rails that extend
+ * this class.
+ */
+ private int renderType = 9;
+
+ public void setRenderType(int value)
+ {
+ renderType = value;
+ }
/**
* Returns true if the block at the coordinates of world passed is a valid rail block (current is rail, powered or
@@ -14,7 +30,7 @@
public static final boolean isRailBlockAt(World par0World, int par1, int par2, int par3)
{
int var4 = par0World.getBlockId(par1, par2, par3);
- return var4 == Block.rail.blockID || var4 == Block.railPowered.blockID || var4 == Block.railDetector.blockID;
+ return isRailBlock(var4);
}
/**
@@ -22,7 +38,7 @@
*/
public static final boolean isRailBlock(int par0)
{
- return par0 == Block.rail.blockID || par0 == Block.railPowered.blockID || par0 == Block.railDetector.blockID;
+ return Block.blocksList[par0] instanceof BlockRail;
}
protected BlockRail(int par1, int par2, boolean par3)
@@ -119,7 +135,7 @@
*/
public int getRenderType()
{
- return 9;
+ return renderType;
}
/**
@@ -135,7 +151,7 @@
*/
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
{
- return par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4);
+ return par1World.isBlockSolidOnSide(par2, par3 - 1, par4, UP);
}
/**
@@ -172,27 +188,27 @@
boolean var8 = false;
- if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4))
+ if (!par1World.isBlockSolidOnSide(par2, par3 - 1, par4, UP))
{
var8 = true;
}
- if (var7 == 2 && !par1World.doesBlockHaveSolidTopSurface(par2 + 1, par3, par4))
+ if (var7 == 2 && !par1World.isBlockSolidOnSide(par2 + 1, par3, par4, UP))
{
var8 = true;
}
- if (var7 == 3 && !par1World.doesBlockHaveSolidTopSurface(par2 - 1, par3, par4))
+ if (var7 == 3 && !par1World.isBlockSolidOnSide(par2 - 1, par3, par4, UP))
{
var8 = true;
}
- if (var7 == 4 && !par1World.doesBlockHaveSolidTopSurface(par2, par3, par4 - 1))
+ if (var7 == 4 && !par1World.isBlockSolidOnSide(par2, par3, par4 - 1, UP))
{
var8 = true;
}
- if (var7 == 5 && !par1World.doesBlockHaveSolidTopSurface(par2, par3, par4 + 1))
+ if (var7 == 5 && !par1World.isBlockSolidOnSide(par2, par3, par4 + 1, UP))
{
var8 = true;
}
@@ -393,9 +409,121 @@
/**
* Return true if the blocks passed is a power related rail.
- */
+ * @deprecated
+ * This function is no longer called by Minecraft
+ */
+ @Deprecated
static boolean isPoweredBlockRail(BlockRail par0BlockRail)
{
return par0BlockRail.isPowered;
}
+
+ /**
+ * Return true if the rail can make corners.
+ * Used by placement logic.
+ * @param world The world.
+ * @param x The rail X coordinate.
+ * @param y The rail Y coordinate.
+ * @param z The rail Z coordinate.
+ * @return True if the rail can make corners.
+ */
+ public boolean isFlexibleRail(World world, int y, int x, int z)
+ {
+ return !isPowered;
+ }
+
+ /**
+ * Returns true if the rail can make up and down slopes.
+ * Used by placement logic.
+ * @param world The world.
+ * @param x The rail X coordinate.
+ * @param y The rail Y coordinate.
+ * @param z The rail Z coordinate.
+ * @return True if the rail can make slopes.
+ */
+ public boolean canMakeSlopes(World world, int x, int y, int z)
+ {
+ return true;
+ }
+
+ /**
+ * Return the rails metadata (without the power bit if the rail uses one).
+ * Can be used to make the cart think the rail something other than it is,
+ * for example when making diamond junctions or switches.
+ * The cart parameter will often be null unless it it called from EntityMinecart.
+ *
+ * Valid rail metadata is defined as follows:
+ * 0x0: flat track going North-South
+ * 0x1: flat track going West-East
+ * 0x2: track ascending to the East
+ * 0x3: track ascending to the West
+ * 0x4: track ascending to the North
+ * 0x5: track ascending to the South
+ * 0x6: WestNorth corner (connecting East and South)
+ * 0x7: EastNorth corner (connecting West and South)
+ * 0x8: EastSouth corner (connecting West and North)
+ * 0x9: WestSouth corner (connecting East and North)
+ *
+ * All directions are Notch defined.
+ * In MC Beta 1.8.3 the Sun rises in the North.
+ * In MC 1.0.0 the Sun rises in the East.
+ *
+ * @param world The world.
+ * @param cart The cart asking for the metadata, null if it is not called by EntityMinecart.
+ * @param y The rail X coordinate.
+ * @param x The rail Y coordinate.
+ * @param z The rail Z coordinate.
+ * @return The metadata.
+ */
+ public int getBasicRailMetadata(IBlockAccess world, EntityMinecart cart, int x, int y, int z)
+ {
+ int meta = world.getBlockMetadata(x, y, z);
+ if(isPowered)
+ {
+ meta = meta & 7;
+ }
+ return meta;
+ }
+
+ /**
+ * Returns the max speed of the rail at the specified position.
+ * @param world The world.
+ * @param cart The cart on the rail, may be null.
+ * @param x The rail X coordinate.
+ * @param y The rail Y coordinate.
+ * @param z The rail Z coordinate.
+ * @return The max speed of the current rail.
+ */
+ public float getRailMaxSpeed(World world, EntityMinecart cart, int y, int x, int z)
+ {
+ return 0.4f;
+ }
+
+ /**
+ * This function is called by any minecart that passes over this rail.
+ * It is called once per update tick that the minecart is on the rail.
+ * @param world The world.
+ * @param cart The cart on the rail.
+ * @param y The rail X coordinate.
+ * @param x The rail Y coordinate.
+ * @param z The rail Z coordinate.
+ */
+ public void onMinecartPass(World world, EntityMinecart cart, int y, int x, int z)
+ {
+ }
+
+ /**
+ * Return true if this rail uses the 4th bit as a power bit.
+ * Avoid using this function when getBasicRailMetadata() can be used instead.
+ * The only reason to use this function is if you wish to change the rails metadata.
+ * @param world The world.
+ * @param x The rail X coordinate.
+ * @param y The rail Y coordinate.
+ * @param z The rail Z coordinate.
+ * @return True if the 4th bit is a power bit.
+ */
+ public boolean hasPowerBit(World world, int x, int y, int z)
+ {
+ return isPowered;
+ }
}

View file

@ -0,0 +1,100 @@
--- ../src_base/common/net/minecraft/src/BlockTripWireSource.java
+++ ../src_work/common/net/minecraft/src/BlockTripWireSource.java
@@ -1,6 +1,9 @@
package net.minecraft.src;
import java.util.Random;
+
+import net.minecraftforge.common.Orientation;
+import static net.minecraftforge.common.Orientation.*;
public class BlockTripWireSource extends Block
{
@@ -58,7 +61,11 @@
*/
public boolean canPlaceBlockOnSide(World par1World, int par2, int par3, int par4, int par5)
{
- return par5 == 2 && par1World.isBlockNormalCube(par2, par3, par4 + 1) ? true : (par5 == 3 && par1World.isBlockNormalCube(par2, par3, par4 - 1) ? true : (par5 == 4 && par1World.isBlockNormalCube(par2 + 1, par3, par4) ? true : par5 == 5 && par1World.isBlockNormalCube(par2 - 1, par3, par4)));
+ Orientation dir = Orientation.getOrientation(par5);
+ return (dir == NORTH && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH)) ||
+ (dir == SOUTH && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH)) ||
+ (dir == WEST && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST )) ||
+ (dir == EAST && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST ));
}
/**
@@ -66,7 +73,10 @@
*/
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
{
- return par1World.isBlockNormalCube(par2 - 1, par3, par4) ? true : (par1World.isBlockNormalCube(par2 + 1, par3, par4) ? true : (par1World.isBlockNormalCube(par2, par3, par4 - 1) ? true : par1World.isBlockNormalCube(par2, par3, par4 + 1)));
+ return par1World.isBlockSolidOnSide(par2 - 1, par3, par4, SOUTH) ||
+ par1World.isBlockSolidOnSide(par2 + 1, par3, par4, NORTH) ||
+ par1World.isBlockSolidOnSide(par2, par3, par4 - 1, EAST ) ||
+ par1World.isBlockSolidOnSide(par2, par3, par4 + 1, WEST );
}
/**
@@ -76,22 +86,22 @@
{
byte var9 = 0;
- if (par5 == 2 && par1World.isBlockNormalCubeDefault(par2, par3, par4 + 1, true))
+ if (par5 == 2 && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, WEST, true))
{
var9 = 2;
}
- if (par5 == 3 && par1World.isBlockNormalCubeDefault(par2, par3, par4 - 1, true))
+ if (par5 == 3 && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, EAST, true))
{
var9 = 0;
}
- if (par5 == 4 && par1World.isBlockNormalCubeDefault(par2 + 1, par3, par4, true))
+ if (par5 == 4 && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, NORTH, true))
{
var9 = 1;
}
- if (par5 == 5 && par1World.isBlockNormalCubeDefault(par2 - 1, par3, par4, true))
+ if (par5 == 5 && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, SOUTH, true))
{
var9 = 3;
}
@@ -113,22 +123,22 @@
int var7 = var6 & 3;
boolean var8 = false;
- if (!par1World.isBlockNormalCube(par2 - 1, par3, par4) && var7 == 3)
+ if (!par1World.isBlockSolidOnSide(par2 - 1, par3, par4, SOUTH) && var7 == 3)
{
var8 = true;
}
- if (!par1World.isBlockNormalCube(par2 + 1, par3, par4) && var7 == 1)
+ if (!par1World.isBlockSolidOnSide(par2 + 1, par3, par4, NORTH) && var7 == 1)
{
var8 = true;
}
- if (!par1World.isBlockNormalCube(par2, par3, par4 - 1) && var7 == 0)
+ if (!par1World.isBlockSolidOnSide(par2, par3, par4 - 1, EAST) && var7 == 0)
{
var8 = true;
}
- if (!par1World.isBlockNormalCube(par2, par3, par4 + 1) && var7 == 2)
+ if (!par1World.isBlockSolidOnSide(par2, par3, par4 + 1, WEST) && var7 == 2)
{
var8 = true;
}
@@ -149,7 +159,7 @@
boolean var12 = (par6 & 8) == 8;
boolean var13 = par5 == Block.tripWireSource.blockID;
boolean var14 = false;
- boolean var15 = !par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4);
+ boolean var15 = !par1World.isBlockSolidOnSide(par2, par3 - 1, par4, UP);
int var16 = Direction.offsetX[var10];
int var17 = Direction.offsetZ[var10];
int var18 = 0;

View file

@ -0,0 +1,11 @@
--- ../src_base/common/net/minecraft/src/CraftingManager.java
+++ ../src_work/common/net/minecraft/src/CraftingManager.java
@@ -255,7 +255,7 @@
}
}
- if (var2 == 2 && var3.itemID == var4.itemID && var3.stackSize == 1 && var4.stackSize == 1 && Item.itemsList[var3.itemID].isDamageable())
+ if (var2 == 2 && var3.itemID == var4.itemID && var3.stackSize == 1 && var4.stackSize == 1 && Item.itemsList[var3.itemID].isRepairable())
{
Item var10 = Item.itemsList[var3.itemID];
int var12 = var10.getMaxDamage() - var3.getItemDamageForDisplay();

View file

@ -0,0 +1,36 @@
--- ../src_base/common/net/minecraft/src/EntityItem.java
+++ ../src_work/common/net/minecraft/src/EntityItem.java
@@ -1,6 +1,9 @@
package net.minecraft.src;
import java.util.Iterator;
+
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.entity.EntityItemPickupEvent;
public class EntityItem extends Entity
{
@@ -238,6 +241,23 @@
{
int var2 = this.item.stackSize;
+ EntityItemPickupEvent event = new EntityItemPickupEvent(this, par1EntityPlayer);
+ MinecraftForge.eventBus.post(event);
+
+ if (delayBeforeCanPickup == 0 && (!event.isCanceled() || item.stackSize <= 0))
+ {
+ //FML Notify pickup
+ worldObj.playSoundAtEntity(this, "random.pop", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
+ par1EntityPlayer.onItemPickup(this, var2);
+
+ if (item.stackSize <= 0)
+ {
+ setDead();
+ }
+ }
+
+ var2 = item.stackSize;
+
if (this.delayBeforeCanPickup == 0 && par1EntityPlayer.inventory.addItemStackToInventory(this.item))
{
if (this.item.itemID == Block.wood.blockID)

View file

@ -0,0 +1,11 @@
--- ../src_base/common/net/minecraft/src/Explosion.java
+++ ../src_work/common/net/minecraft/src/Explosion.java
@@ -76,7 +76,7 @@
if (var25 > 0)
{
- var14 -= (Block.blocksList[var25].getExplosionResistance(this.exploder) + 0.3F) * var21;
+ var14 -= (Block.blocksList[var25].getExplosionResistance(this.exploder, worldObj, var22, var23, var24, explosionX, explosionY, explosionZ) + 0.3F) * var21;
}
if (var14 > 0.0F)

View file

@ -0,0 +1,47 @@
--- ../src_base/common/net/minecraft/src/ItemBow.java
+++ ../src_work/common/net/minecraft/src/ItemBow.java
@@ -1,4 +1,8 @@
package net.minecraft.src;
+
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.entity.ArrowLooseEvent;
+import net.minecraftforge.event.entity.ArrowNockEvent;
public class ItemBow extends Item
{
@@ -15,11 +19,20 @@
*/
public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4)
{
+ int var6 = this.getMaxItemUseDuration(par1ItemStack) - par4;
+
+ ArrowLooseEvent event = new ArrowLooseEvent(par3EntityPlayer, par1ItemStack, var6);
+ MinecraftForge.eventBus.post(event);
+ if (event.isCanceled())
+ {
+ return;
+ }
+ var6 = event.getCharge();
+
boolean var5 = par3EntityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0;
if (var5 || par3EntityPlayer.inventory.hasItem(Item.arrow.shiftedIndex))
{
- int var6 = this.getMaxItemUseDuration(par1ItemStack) - par4;
float var7 = (float)var6 / 20.0F;
var7 = (var7 * var7 + var7 * 2.0F) / 3.0F;
@@ -104,6 +117,13 @@
*/
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
+ ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack);
+ MinecraftForge.eventBus.post(event);
+ if (event.isCanceled())
+ {
+ return event.getResultStack();
+ }
+
if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Item.arrow.shiftedIndex))
{
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));

View file

@ -0,0 +1,35 @@
--- ../src_base/common/net/minecraft/src/ItemBucket.java
+++ ../src_work/common/net/minecraft/src/ItemBucket.java
@@ -1,4 +1,6 @@
package net.minecraft.src;
+
+import net.minecraftforge.event.entity.FillBucketEvent;
public class ItemBucket extends Item
{
@@ -31,6 +33,17 @@
}
else
{
+ FillBucketEvent event = new FillBucketEvent(par3EntityPlayer, par1ItemStack, par2World, var12);
+ if (event.isCanceled())
+ {
+ return par1ItemStack;
+ }
+
+ if (event.isHandeled())
+ {
+ return event.getResult();
+ }
+
if (var12.typeOfHit == EnumMovingObjectType.TILE)
{
int var13 = var12.blockX;
@@ -41,6 +54,7 @@
{
return par1ItemStack;
}
+
if (this.isFull == 0)
{

View file

@ -0,0 +1,12 @@
--- ../src_base/common/net/minecraft/src/MovingObjectPosition.java
+++ ../src_work/common/net/minecraft/src/MovingObjectPosition.java
@@ -25,6 +25,9 @@
/** The hit entity */
public Entity entityHit;
+
+ /** Used to determine what sub-segment is hit */
+ public int subHit = -1;
public MovingObjectPosition(int par1, int par2, int par3, int par4, Vec3 par5Vec3)
{

View file

@ -0,0 +1,70 @@
--- ../src_base/common/net/minecraft/src/RailLogic.java
+++ ../src_work/common/net/minecraft/src/RailLogic.java
@@ -19,6 +19,7 @@
private List connectedTracks;
final BlockRail rail;
+ private final boolean canMakeSlopes;
public RailLogic(BlockRail par1BlockRail, World par2World, int par3, int par4, int par5)
{
@@ -29,18 +30,11 @@
this.trackY = par4;
this.trackZ = par5;
int var6 = par2World.getBlockId(par3, par4, par5);
- int var7 = par2World.getBlockMetadata(par3, par4, par5);
-
- if (BlockRail.isPoweredBlockRail((BlockRail)Block.blocksList[var6]))
- {
- this.isPoweredRail = true;
- var7 &= -9;
- }
- else
- {
- this.isPoweredRail = false;
- }
-
+
+ BlockRail target = (BlockRail)Block.blocksList[var6];
+ int var7 = target.getBasicRailMetadata(par2World, null, par3, par4, par5);
+ isPoweredRail = !target.isFlexibleRail(par2World, par3, par4, par5);
+ canMakeSlopes = target.canMakeSlopes(par2World, par3, par4, par5);
this.setConnections(var7);
}
@@ -267,7 +261,7 @@
}
}
- if (var6 == 0)
+ if (var6 == 0 && canMakeSlopes)
{
if (BlockRail.isRailBlockAt(this.worldObj, this.trackX, this.trackY + 1, this.trackZ - 1))
{
@@ -280,7 +274,7 @@
}
}
- if (var6 == 1)
+ if (var6 == 1 && canMakeSlopes)
{
if (BlockRail.isRailBlockAt(this.worldObj, this.trackX + 1, this.trackY + 1, this.trackZ))
{
@@ -431,7 +425,7 @@
}
}
- if (var7 == 0)
+ if (var7 == 0 && canMakeSlopes)
{
if (BlockRail.isRailBlockAt(this.worldObj, this.trackX, this.trackY + 1, this.trackZ - 1))
{
@@ -444,7 +438,7 @@
}
}
- if (var7 == 1)
+ if (var7 == 1 && canMakeSlopes)
{
if (BlockRail.isRailBlockAt(this.worldObj, this.trackX + 1, this.trackY + 1, this.trackZ))
{

View file

@ -0,0 +1,369 @@
--- ../src_base/minecraft/net/minecraft/src/Chunk.java
+++ ../src_work/minecraft/net/minecraft/src/Chunk.java
@@ -7,6 +7,9 @@
import java.util.List;
import java.util.Map;
import java.util.Random;
+
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.world.ChunkEvent;
public class Chunk
{
@@ -120,7 +123,9 @@
{
for (int var8 = 0; var8 < var5; ++var8)
{
- byte var9 = par2ArrayOfByte[var6 << 11 | var7 << 7 | var8];
+ /* FORGE: The following change, a cast from unsigned byte to int,
+ * fixes a vanilla bug when generating new chunks that contain a block ID > 127 */
+ int var9 = par2ArrayOfByte[var6 << 11 | var7 << 7 | var8] & 0xFF;
if (var9 != 0)
{
@@ -132,6 +137,48 @@
}
this.storageArrays[var10].setExtBlockID(var6, var8 & 15, var7, var9);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Metadata sensitive Chunk constructor for use in new ChunkProviders that
+ * use metadata sensitive blocks during generation.
+ *
+ * @param world The world this chunk belongs to
+ * @param ids A ByteArray containing all the BlockID's to set this chunk to
+ * @param metadata A ByteArray containing all the metadata to set this chunk to
+ * @param chunkX The chunk's X position
+ * @param chunkZ The Chunk's Z position
+ */
+ public Chunk(World world, byte[] ids, byte[] metadata, int chunkX, int chunkY)
+ {
+ this(world, chunkX, chunkY);
+ int var5 = ids.length / 256;
+
+ for (int x = 0; x < 16; ++x)
+ {
+ for (int z = 0; z < 16; ++z)
+ {
+ for (int y = 0; y < var5; ++y)
+ {
+ int idx = x << 11 | z << 7 | y;
+ int id = ids[idx] & 0xFF;
+ int meta = metadata[idx];
+
+ if (id != 0)
+ {
+ int var10 = y >> 4;
+
+ if (this.storageArrays[var10] == null)
+ {
+ this.storageArrays[var10] = new ExtendedBlockStorage(var10 << 4);
+ }
+
+ this.storageArrays[var10].setExtBlockID(x, y & 15, z, id);
+ this.storageArrays[var10].setExtBlockMetadata(x, y & 15, z, meta);
}
}
}
@@ -503,7 +550,7 @@
*/
public int getBlockID(int par1, int par2, int par3)
{
- if (par2 >> 4 >= this.storageArrays.length)
+ if (par2 >> 4 >= this.storageArrays.length || par2 >> 4 < 0)
{
return 0;
}
@@ -519,7 +566,7 @@
*/
public int getBlockMetadata(int par1, int par2, int par3)
{
- if (par2 >> 4 >= this.storageArrays.length)
+ if (par2 >> 4 >= this.storageArrays.length || par2 >> 4 < 0)
{
return 0;
}
@@ -560,6 +607,11 @@
}
else
{
+ if (par2 >> 4 >= storageArrays.length || par2 >> 4 < 0)
+ {
+ return false;
+ }
+
ExtendedBlockStorage var10 = this.storageArrays[par2 >> 4];
boolean var11 = false;
@@ -590,7 +642,7 @@
{
Block.blocksList[var8].breakBlock(this.worldObj, var12, par2, var13, var8, var9);
}
- else if (Block.blocksList[var8] instanceof BlockContainer && var8 != par4)
+ else if (Block.blocksList[var8] != null && Block.blocksList[var8].hasTileEntity(var9))
{
this.worldObj.removeBlockTileEntity(var12, par2, var13);
}
@@ -634,29 +686,21 @@
Block.blocksList[par4].onBlockAdded(this.worldObj, var12, par2, var13);
}
- if (Block.blocksList[par4] instanceof BlockContainer)
+ if (Block.blocksList[par4] != null && Block.blocksList[par4].hasTileEntity(par5))
{
var14 = this.getChunkBlockTileEntity(par1, par2, par3);
if (var14 == null)
{
- var14 = ((BlockContainer)Block.blocksList[par4]).createNewTileEntity(this.worldObj);
+ var14 = Block.blocksList[par4].getTileEntity(this.worldObj, par5);
this.worldObj.setBlockTileEntity(var12, par2, var13, var14);
}
if (var14 != null)
{
var14.updateContainingBlockInfo();
+ var14.blockMetadata = par5;
}
- }
- }
- else if (var8 > 0 && Block.blocksList[var8] instanceof BlockContainer)
- {
- var14 = this.getChunkBlockTileEntity(par1, par2, par3);
-
- if (var14 != null)
- {
- var14.updateContainingBlockInfo();
}
}
@@ -671,7 +715,7 @@
*/
public boolean setBlockMetadata(int par1, int par2, int par3, int par4)
{
- ExtendedBlockStorage var5 = this.storageArrays[par2 >> 4];
+ ExtendedBlockStorage var5 = (par2 >> 4 >= storageArrays.length || par2 >> 4 < 0 ? null : storageArrays[par2 >> 4]);
if (var5 == null)
{
@@ -691,7 +735,7 @@
var5.setExtBlockMetadata(par1, par2 & 15, par3, par4);
int var7 = var5.getExtBlockID(par1, par2 & 15, par3);
- if (var7 > 0 && Block.blocksList[var7] instanceof BlockContainer)
+ if (var7 > 0 && Block.blocksList[var7] != null && Block.blocksList[var7].hasTileEntity(par4))
{
TileEntity var8 = this.getChunkBlockTileEntity(par1, par2, par3);
@@ -712,7 +756,7 @@
*/
public int getSavedLightValue(EnumSkyBlock par1EnumSkyBlock, int par2, int par3, int par4)
{
- ExtendedBlockStorage var5 = this.storageArrays[par3 >> 4];
+ ExtendedBlockStorage var5 = (par3 >> 4 >= storageArrays.length || par3 >> 4 < 0 ? null : storageArrays[par3 >> 4]);
return var5 == null ? (this.canBlockSeeTheSky(par2, par3, par4) ? par1EnumSkyBlock.defaultLightValue : 0) : (par1EnumSkyBlock == EnumSkyBlock.Sky ? var5.getExtSkylightValue(par2, par3 & 15, par4) : (par1EnumSkyBlock == EnumSkyBlock.Block ? var5.getExtBlocklightValue(par2, par3 & 15, par4) : par1EnumSkyBlock.defaultLightValue));
}
@@ -722,6 +766,11 @@
*/
public void setLightValue(EnumSkyBlock par1EnumSkyBlock, int par2, int par3, int par4, int par5)
{
+ if (par3 >> 4 >= storageArrays.length || par3 >> 4 < 0)
+ {
+ return;
+ }
+
ExtendedBlockStorage var6 = this.storageArrays[par3 >> 4];
if (var6 == null)
@@ -750,7 +799,7 @@
*/
public int getBlockLightValue(int par1, int par2, int par3, int par4)
{
- ExtendedBlockStorage var5 = this.storageArrays[par2 >> 4];
+ ExtendedBlockStorage var5 = (par2 >> 4 >= storageArrays.length || par2 >> 4 < 0 ? null : storageArrays[par2 >> 4]);
if (var5 == null)
{
@@ -853,33 +902,32 @@
ChunkPosition var4 = new ChunkPosition(par1, par2, par3);
TileEntity var5 = (TileEntity)this.chunkTileEntityMap.get(var4);
+ if (var5 != null && var5.isInvalid())
+ {
+ chunkTileEntityMap.remove(var4);
+ var5 = null;
+ }
+
if (var5 == null)
{
int var6 = this.getBlockID(par1, par2, par3);
-
- if (var6 <= 0 || !Block.blocksList[var6].hasTileEntity())
+ int meta = this.getBlockMetadata(par1, par2, par3);
+
+ if (var6 <= 0 || !Block.blocksList[var6].hasTileEntity(meta))
{
return null;
}
if (var5 == null)
{
- var5 = ((BlockContainer)Block.blocksList[var6]).createNewTileEntity(this.worldObj);
+ var5 = Block.blocksList[var6].createNewTileEntity(this.worldObj, meta);
this.worldObj.setBlockTileEntity(this.xPosition * 16 + par1, par2, this.zPosition * 16 + par3, var5);
}
var5 = (TileEntity)this.chunkTileEntityMap.get(var4);
}
- if (var5 != null && var5.isInvalid())
- {
- this.chunkTileEntityMap.remove(var4);
- return null;
- }
- else
- {
- return var5;
- }
+ return var5;
}
/**
@@ -894,7 +942,7 @@
if (this.isChunkLoaded)
{
- this.worldObj.loadedTileEntityList.add(par1TileEntity);
+ this.worldObj.addTileEntity(par1TileEntity);
}
}
@@ -909,8 +957,14 @@
par4TileEntity.yCoord = par2;
par4TileEntity.zCoord = this.zPosition * 16 + par3;
- if (this.getBlockID(par1, par2, par3) != 0 && Block.blocksList[this.getBlockID(par1, par2, par3)] instanceof BlockContainer)
- {
+ Block block = Block.blocksList[getBlockID(par1, par2, par3)];
+ if (block != null && block.hasTileEntity(getBlockMetadata(par1, par2, par3)))
+ {
+ TileEntity old = (TileEntity)chunkTileEntityMap.get(var5);
+ if (old != null)
+ {
+ old.invalidate();
+ }
par4TileEntity.validate();
this.chunkTileEntityMap.put(var5, par4TileEntity);
}
@@ -949,6 +1003,7 @@
List var4 = var1[var3];
this.worldObj.addLoadedEntities(var4);
}
+ MinecraftForge.eventBus.post(new ChunkEvent.Load(this));
}
/**
@@ -973,6 +1028,7 @@
List var4 = var5[var3];
this.worldObj.unloadEntities(var4);
}
+ MinecraftForge.eventBus.post(new ChunkEvent.Unload(this));
}
/**
@@ -989,8 +1045,8 @@
*/
public void getEntitiesWithinAABBForEntity(Entity par1Entity, AxisAlignedBB par2AxisAlignedBB, List par3List)
{
- int var4 = MathHelper.floor_double((par2AxisAlignedBB.minY - 2.0D) / 16.0D);
- int var5 = MathHelper.floor_double((par2AxisAlignedBB.maxY + 2.0D) / 16.0D);
+ int var4 = MathHelper.floor_double((par2AxisAlignedBB.minY - World.MAX_ENTITY_RADIUS) / 16.0D);
+ int var5 = MathHelper.floor_double((par2AxisAlignedBB.maxY + World.MAX_ENTITY_RADIUS) / 16.0D);
if (var4 < 0)
{
@@ -1038,8 +1094,8 @@
*/
public void getEntitiesOfTypeWithinAAAB(Class par1Class, AxisAlignedBB par2AxisAlignedBB, List par3List)
{
- int var4 = MathHelper.floor_double((par2AxisAlignedBB.minY - 2.0D) / 16.0D);
- int var5 = MathHelper.floor_double((par2AxisAlignedBB.maxY + 2.0D) / 16.0D);
+ int var4 = MathHelper.floor_double((par2AxisAlignedBB.minY - World.MAX_ENTITY_RADIUS) / 16.0D);
+ int var5 = MathHelper.floor_double((par2AxisAlignedBB.maxY + World.MAX_ENTITY_RADIUS) / 16.0D);
if (var4 < 0)
{
@@ -1221,6 +1277,15 @@
*/
public void fillChunk(byte[] par1ArrayOfByte, int par2, int par3, boolean par4)
{
+ Iterator iterator = chunkTileEntityMap.values().iterator();
+ while(iterator.hasNext())
+ {
+ TileEntity tileEntity = (TileEntity)iterator.next();
+ tileEntity.updateContainingBlockInfo();
+ tileEntity.getBlockMetadata();
+ tileEntity.getBlockType();
+ }
+
int var5 = 0;
int var6;
@@ -1317,12 +1382,26 @@
}
this.generateHeightMap();
- Iterator var10 = this.chunkTileEntityMap.values().iterator();
-
- while (var10.hasNext())
- {
- TileEntity var9 = (TileEntity)var10.next();
- var9.updateContainingBlockInfo();
+
+ List<TileEntity> invalidList = new ArrayList<TileEntity>();
+ iterator = chunkTileEntityMap.values().iterator();
+ while (iterator.hasNext())
+ {
+ TileEntity tileEntity = (TileEntity)iterator.next();
+ int x = tileEntity.xCoord & 15;
+ int y = tileEntity.yCoord;
+ int z = tileEntity.zCoord & 15;
+ Block block = tileEntity.getBlockType();
+ if (block == null || block.blockID != getBlockID(x, y, z) || tileEntity.getBlockMetadata() != getBlockMetadata(x, y, z))
+ {
+ invalidList.add(tileEntity);
+ }
+ tileEntity.updateContainingBlockInfo();
+ }
+
+ for (TileEntity tileEntity : invalidList)
+ {
+ tileEntity.invalidate();
}
}
@@ -1431,4 +1510,18 @@
}
}
}
+
+ /** FORGE: Used to remove only invalid TileEntities */
+ public void cleanChunkBlockTileEntity(int x, int y, int z)
+ {
+ ChunkPosition position = new ChunkPosition(x, y, z);
+ if (isChunkLoaded)
+ {
+ TileEntity entity = (TileEntity)chunkTileEntityMap.get(position);
+ if (entity != null && entity.isInvalid())
+ {
+ chunkTileEntityMap.remove(position);
+ }
+ }
+ }
}

View file

@ -0,0 +1,12 @@
--- ../src_base/minecraft/net/minecraft/src/World.java
+++ ../src_work/minecraft/net/minecraft/src/World.java
@@ -273,7 +273,8 @@
public boolean blockHasTileEntity(int par1, int par2, int par3)
{
int var4 = this.getBlockId(par1, par2, par3);
- return Block.blocksList[var4] != null && Block.blocksList[var4].hasTileEntity();
+ int meta = this.getBlockMetadata(par1, par2, par3);
+ return Block.blocksList[var4] != null && Block.blocksList[var4].hasTileEntity(meta);
}
/**

View file

@ -0,0 +1,11 @@
--- ../src_base/minecraft/net/minecraft/src/WorldRenderer.java
+++ ../src_work/minecraft/net/minecraft/src/WorldRenderer.java
@@ -187,7 +187,7 @@
if (var23 != null)
{
- if (var11 == 0 && var23.hasTileEntity())
+ if (var11 == 0 && var23.hasTileEntity(var9.getBlockMetadata(var17, var15, var16)))
{
TileEntity var20 = var9.getBlockTileEntity(var17, var15, var16);

View file

@ -0,0 +1,320 @@
--- ../src_base/minecraft_server/net/minecraft/src/Chunk.java
+++ ../src_work/minecraft_server/net/minecraft/src/Chunk.java
@@ -7,6 +7,9 @@
import java.util.List;
import java.util.Map;
import java.util.Random;
+
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.world.ChunkEvent;
public class Chunk
{
@@ -120,7 +123,9 @@
{
for (int var8 = 0; var8 < var5; ++var8)
{
- byte var9 = par2ArrayOfByte[var6 << 11 | var7 << 7 | var8];
+ /* FORGE: The following change, a cast from unsigned byte to int,
+ * fixes a vanilla bug when generating new chunks that contain a block ID > 127 */
+ int var9 = par2ArrayOfByte[var6 << 11 | var7 << 7 | var8] & 0xFF;
if (var9 != 0)
{
@@ -132,6 +137,48 @@
}
this.storageArrays[var10].setExtBlockID(var6, var8 & 15, var7, var9);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Metadata sensitive Chunk constructor for use in new ChunkProviders that
+ * use metadata sensitive blocks during generation.
+ *
+ * @param world The world this chunk belongs to
+ * @param ids A ByteArray containing all the BlockID's to set this chunk to
+ * @param metadata A ByteArray containing all the metadata to set this chunk to
+ * @param chunkX The chunk's X position
+ * @param chunkZ The Chunk's Z position
+ */
+ public Chunk(World world, byte[] ids, byte[] metadata, int chunkX, int chunkY)
+ {
+ this(world, chunkX, chunkY);
+ int var5 = ids.length / 256;
+
+ for (int x = 0; x < 16; ++x)
+ {
+ for (int z = 0; z < 16; ++z)
+ {
+ for (int y = 0; y < var5; ++y)
+ {
+ int idx = x << 11 | z << 7 | y;
+ int id = ids[idx] & 0xFF;
+ int meta = metadata[idx];
+
+ if (id != 0)
+ {
+ int var10 = y >> 4;
+
+ if (this.storageArrays[var10] == null)
+ {
+ this.storageArrays[var10] = new ExtendedBlockStorage(var10 << 4);
+ }
+
+ this.storageArrays[var10].setExtBlockID(x, y & 15, z, id);
+ this.storageArrays[var10].setExtBlockMetadata(x, y & 15, z, meta);
}
}
}
@@ -463,7 +510,7 @@
*/
public int getBlockID(int par1, int par2, int par3)
{
- if (par2 >> 4 >= this.storageArrays.length)
+ if (par2 >> 4 >= this.storageArrays.length || par2 >> 4 < 0)
{
return 0;
}
@@ -479,7 +526,7 @@
*/
public int getBlockMetadata(int par1, int par2, int par3)
{
- if (par2 >> 4 >= this.storageArrays.length)
+ if (par2 >> 4 >= this.storageArrays.length || par2 >> 4 < 0)
{
return 0;
}
@@ -520,6 +567,11 @@
}
else
{
+ if (par2 >> 4 >= storageArrays.length || par2 >> 4 < 0)
+ {
+ return false;
+ }
+
ExtendedBlockStorage var10 = this.storageArrays[par2 >> 4];
boolean var11 = false;
@@ -550,7 +602,7 @@
{
Block.blocksList[var8].breakBlock(this.worldObj, var12, par2, var13, var8, var9);
}
- else if (Block.blocksList[var8] instanceof BlockContainer && var8 != par4)
+ else if (Block.blocksList[var8] != null && Block.blocksList[var8].hasTileEntity(var9))
{
this.worldObj.removeBlockTileEntity(var12, par2, var13);
}
@@ -594,29 +646,21 @@
Block.blocksList[par4].onBlockAdded(this.worldObj, var12, par2, var13);
}
- if (Block.blocksList[par4] instanceof BlockContainer)
+ if (Block.blocksList[par4] != null && Block.blocksList[par4].hasTileEntity(par5))
{
var14 = this.getChunkBlockTileEntity(par1, par2, par3);
if (var14 == null)
{
- var14 = ((BlockContainer)Block.blocksList[par4]).createNewTileEntity(this.worldObj);
+ var14 = Block.blocksList[par4].getTileEntity(this.worldObj, par5);
this.worldObj.setBlockTileEntity(var12, par2, var13, var14);
}
if (var14 != null)
{
var14.updateContainingBlockInfo();
+ var14.blockMetadata = par5;
}
- }
- }
- else if (var8 > 0 && Block.blocksList[var8] instanceof BlockContainer)
- {
- var14 = this.getChunkBlockTileEntity(par1, par2, par3);
-
- if (var14 != null)
- {
- var14.updateContainingBlockInfo();
}
}
@@ -631,7 +675,7 @@
*/
public boolean setBlockMetadata(int par1, int par2, int par3, int par4)
{
- ExtendedBlockStorage var5 = this.storageArrays[par2 >> 4];
+ ExtendedBlockStorage var5 = (par2 >> 4 >= storageArrays.length || par2 >> 4 < 0 ? null : storageArrays[par2 >> 4]);
if (var5 == null)
{
@@ -651,7 +695,7 @@
var5.setExtBlockMetadata(par1, par2 & 15, par3, par4);
int var7 = var5.getExtBlockID(par1, par2 & 15, par3);
- if (var7 > 0 && Block.blocksList[var7] instanceof BlockContainer)
+ if (var7 > 0 && Block.blocksList[var7] != null && Block.blocksList[var7].hasTileEntity(par4))
{
TileEntity var8 = this.getChunkBlockTileEntity(par1, par2, par3);
@@ -672,7 +716,7 @@
*/
public int getSavedLightValue(EnumSkyBlock par1EnumSkyBlock, int par2, int par3, int par4)
{
- ExtendedBlockStorage var5 = this.storageArrays[par3 >> 4];
+ ExtendedBlockStorage var5 = (par3 >> 4 >= storageArrays.length || par3 >> 4 < 0 ? null : storageArrays[par3 >> 4]);
return var5 == null ? (this.canBlockSeeTheSky(par2, par3, par4) ? par1EnumSkyBlock.defaultLightValue : 0) : (par1EnumSkyBlock == EnumSkyBlock.Sky ? var5.getExtSkylightValue(par2, par3 & 15, par4) : (par1EnumSkyBlock == EnumSkyBlock.Block ? var5.getExtBlocklightValue(par2, par3 & 15, par4) : par1EnumSkyBlock.defaultLightValue));
}
@@ -682,6 +726,11 @@
*/
public void setLightValue(EnumSkyBlock par1EnumSkyBlock, int par2, int par3, int par4, int par5)
{
+ if (par3 >> 4 >= storageArrays.length || par3 >> 4 < 0)
+ {
+ return;
+ }
+
ExtendedBlockStorage var6 = this.storageArrays[par3 >> 4];
if (var6 == null)
@@ -710,7 +759,7 @@
*/
public int getBlockLightValue(int par1, int par2, int par3, int par4)
{
- ExtendedBlockStorage var5 = this.storageArrays[par2 >> 4];
+ ExtendedBlockStorage var5 = (par2 >> 4 >= storageArrays.length || par2 >> 4 < 0 ? null : storageArrays[par2 >> 4]);
if (var5 == null)
{
@@ -813,33 +862,32 @@
ChunkPosition var4 = new ChunkPosition(par1, par2, par3);
TileEntity var5 = (TileEntity)this.chunkTileEntityMap.get(var4);
+ if (var5 != null && var5.isInvalid())
+ {
+ chunkTileEntityMap.remove(var4);
+ var5 = null;
+ }
+
if (var5 == null)
{
int var6 = this.getBlockID(par1, par2, par3);
-
- if (var6 <= 0 || !Block.blocksList[var6].hasTileEntity())
+ int meta = this.getBlockMetadata(par1, par2, par3);
+
+ if (var6 <= 0 || !Block.blocksList[var6].hasTileEntity(meta))
{
return null;
}
if (var5 == null)
{
- var5 = ((BlockContainer)Block.blocksList[var6]).createNewTileEntity(this.worldObj);
+ var5 = Block.blocksList[var6].createNewTileEntity(this.worldObj, meta);
this.worldObj.setBlockTileEntity(this.xPosition * 16 + par1, par2, this.zPosition * 16 + par3, var5);
}
var5 = (TileEntity)this.chunkTileEntityMap.get(var4);
}
- if (var5 != null && var5.isInvalid())
- {
- this.chunkTileEntityMap.remove(var4);
- return null;
- }
- else
- {
- return var5;
- }
+ return var5;
}
/**
@@ -854,7 +902,7 @@
if (this.isChunkLoaded)
{
- this.worldObj.loadedTileEntityList.add(par1TileEntity);
+ this.worldObj.addTileEntity(par1TileEntity);
}
}
@@ -869,8 +917,14 @@
par4TileEntity.yCoord = par2;
par4TileEntity.zCoord = this.zPosition * 16 + par3;
- if (this.getBlockID(par1, par2, par3) != 0 && Block.blocksList[this.getBlockID(par1, par2, par3)] instanceof BlockContainer)
- {
+ Block block = Block.blocksList[getBlockID(par1, par2, par3)];
+ if (block != null && block.hasTileEntity(getBlockMetadata(par1, par2, par3)))
+ {
+ TileEntity old = (TileEntity)chunkTileEntityMap.get(var5);
+ if (old != null)
+ {
+ old.invalidate();
+ }
par4TileEntity.validate();
this.chunkTileEntityMap.put(var5, par4TileEntity);
}
@@ -909,6 +963,7 @@
List var4 = var1[var3];
this.worldObj.addLoadedEntities(var4);
}
+ MinecraftForge.eventBus.post(new ChunkEvent.Load(this));
}
/**
@@ -933,6 +988,7 @@
List var4 = var5[var3];
this.worldObj.unloadEntities(var4);
}
+ MinecraftForge.eventBus.post(new ChunkEvent.Unload(this));
}
/**
@@ -949,8 +1005,8 @@
*/
public void getEntitiesWithinAABBForEntity(Entity par1Entity, AxisAlignedBB par2AxisAlignedBB, List par3List)
{
- int var4 = MathHelper.floor_double((par2AxisAlignedBB.minY - 2.0D) / 16.0D);
- int var5 = MathHelper.floor_double((par2AxisAlignedBB.maxY + 2.0D) / 16.0D);
+ int var4 = MathHelper.floor_double((par2AxisAlignedBB.minY - World.MAX_ENTITY_RADIUS) / 16.0D);
+ int var5 = MathHelper.floor_double((par2AxisAlignedBB.maxY + World.MAX_ENTITY_RADIUS) / 16.0D);
if (var4 < 0)
{
@@ -998,8 +1054,8 @@
*/
public void getEntitiesOfTypeWithinAAAB(Class par1Class, AxisAlignedBB par2AxisAlignedBB, List par3List)
{
- int var4 = MathHelper.floor_double((par2AxisAlignedBB.minY - 2.0D) / 16.0D);
- int var5 = MathHelper.floor_double((par2AxisAlignedBB.maxY + 2.0D) / 16.0D);
+ int var4 = MathHelper.floor_double((par2AxisAlignedBB.minY - World.MAX_ENTITY_RADIUS) / 16.0D);
+ int var5 = MathHelper.floor_double((par2AxisAlignedBB.maxY + World.MAX_ENTITY_RADIUS) / 16.0D);
if (var4 < 0)
{
@@ -1281,4 +1337,18 @@
}
}
}
+
+ /** FORGE: Used to remove only invalid TileEntities */
+ public void cleanChunkBlockTileEntity(int x, int y, int z)
+ {
+ ChunkPosition position = new ChunkPosition(x, y, z);
+ if (isChunkLoaded)
+ {
+ TileEntity entity = (TileEntity)chunkTileEntityMap.get(position);
+ if (entity != null && entity.isInvalid())
+ {
+ chunkTileEntityMap.remove(position);
+ }
+ }
+ }
}

View file

@ -0,0 +1,12 @@
--- ../src_base/minecraft_server/net/minecraft/src/World.java
+++ ../src_work/minecraft_server/net/minecraft/src/World.java
@@ -248,7 +248,8 @@
public boolean blockHasTileEntity(int par1, int par2, int par3)
{
int var4 = this.getBlockId(par1, par2, par3);
- return Block.blocksList[var4] != null && Block.blocksList[var4].hasTileEntity();
+ int meta = this.getBlockMetadata(par1, par2, par3);
+ return Block.blocksList[var4] != null && Block.blocksList[var4].hasTileEntity(meta);
}
/**