mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-27 15:33:18 +00:00
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:
1 parent
5672b783da
commit
1fb042621c
29 files changed
+1904
-170
No files matched your search
@@ -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;
|
||||
+ }
|
||||
}
|
||||
Reference in new issue
Block a user