mirror of
https://git.zelz.net/catfoolyou/Project164.git
synced 2025-12-14 15:37:41 +00:00
Upload source
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package net.minecraft.client;
|
||||
|
||||
public class ClientBrandRetriever
|
||||
{
|
||||
public static String getClientModName()
|
||||
{
|
||||
return "vanilla";
|
||||
}
|
||||
}
|
||||
99
src/main/java/net/minecraft/client/main/Main.java
Normal file
99
src/main/java/net/minecraft/client/main/Main.java
Normal file
@@ -0,0 +1,99 @@
|
||||
package net.minecraft.client.main;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.Authenticator;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.net.Proxy.Type;
|
||||
import java.util.List;
|
||||
import joptsimple.ArgumentAcceptingOptionSpec;
|
||||
import joptsimple.NonOptionArgumentSpec;
|
||||
import joptsimple.OptionParser;
|
||||
import joptsimple.OptionSet;
|
||||
import net.minecraft.src.MainProxyAuthenticator;
|
||||
import net.minecraft.src.MainShutdownHook;
|
||||
import net.minecraft.src.Minecraft;
|
||||
import net.minecraft.src.Session;
|
||||
|
||||
public class Main
|
||||
{
|
||||
public static void main(String[] par0ArrayOfStr)
|
||||
{
|
||||
System.setProperty("java.net.preferIPv4Stack", "true");
|
||||
OptionParser var1 = new OptionParser();
|
||||
var1.allowsUnrecognizedOptions();
|
||||
var1.accepts("demo");
|
||||
var1.accepts("fullscreen");
|
||||
ArgumentAcceptingOptionSpec var2 = var1.accepts("server").withRequiredArg();
|
||||
ArgumentAcceptingOptionSpec var3 = var1.accepts("port").withRequiredArg().ofType(Integer.class).defaultsTo(Integer.valueOf(25565), new Integer[0]);
|
||||
ArgumentAcceptingOptionSpec var4 = var1.accepts("gameDir").withRequiredArg().ofType(File.class).defaultsTo(new File("."), new File[0]);
|
||||
ArgumentAcceptingOptionSpec var5 = var1.accepts("assetsDir").withRequiredArg().ofType(File.class).defaultsTo(new File("lwjgl-rundir/resources/assets"), new File[0]);
|
||||
ArgumentAcceptingOptionSpec var6 = var1.accepts("resourcePackDir").withRequiredArg().ofType(File.class);
|
||||
ArgumentAcceptingOptionSpec var7 = var1.accepts("proxyHost").withRequiredArg();
|
||||
ArgumentAcceptingOptionSpec var8 = var1.accepts("proxyPort").withRequiredArg().defaultsTo("8080", new String[0]).ofType(Integer.class);
|
||||
ArgumentAcceptingOptionSpec var9 = var1.accepts("proxyUser").withRequiredArg();
|
||||
ArgumentAcceptingOptionSpec var10 = var1.accepts("proxyPass").withRequiredArg();
|
||||
ArgumentAcceptingOptionSpec var11 = var1.accepts("username").withRequiredArg().defaultsTo("DefaultClientTest");
|
||||
ArgumentAcceptingOptionSpec var12 = var1.accepts("session").withRequiredArg();
|
||||
ArgumentAcceptingOptionSpec var13 = var1.accepts("version").withRequiredArg().defaultsTo("1.6.4");
|
||||
ArgumentAcceptingOptionSpec var14 = var1.accepts("width").withRequiredArg().ofType(Integer.class).defaultsTo(Integer.valueOf(854), new Integer[0]);
|
||||
ArgumentAcceptingOptionSpec var15 = var1.accepts("height").withRequiredArg().ofType(Integer.class).defaultsTo(Integer.valueOf(480), new Integer[0]);
|
||||
NonOptionArgumentSpec var16 = var1.nonOptions();
|
||||
OptionSet var17 = var1.parse(par0ArrayOfStr);
|
||||
List var18 = var17.valuesOf(var16);
|
||||
String var19 = (String)var17.valueOf(var7);
|
||||
Proxy var20 = Proxy.NO_PROXY;
|
||||
|
||||
if (var19 != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var20 = new Proxy(Type.SOCKS, new InetSocketAddress(var19, ((Integer)var17.valueOf(var8)).intValue()));
|
||||
}
|
||||
catch (Exception var34)
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
String var21 = (String)var17.valueOf(var9);
|
||||
String var22 = (String)var17.valueOf(var10);
|
||||
|
||||
if (!var20.equals(Proxy.NO_PROXY) && func_110121_a(var21) && func_110121_a(var22))
|
||||
{
|
||||
Authenticator.setDefault(new MainProxyAuthenticator(var21, var22));
|
||||
}
|
||||
|
||||
int var23 = ((Integer)var17.valueOf(var14)).intValue();
|
||||
int var24 = ((Integer)var17.valueOf(var15)).intValue();
|
||||
boolean var25 = var17.has("fullscreen");
|
||||
boolean var26 = var17.has("demo");
|
||||
String var27 = (String)var17.valueOf(var13);
|
||||
File var28 = (File)var17.valueOf(var4);
|
||||
File var29 = var17.has(var5) ? (File)var17.valueOf(var5) : new File(var28, "assets/");
|
||||
File var30 = var17.has(var6) ? (File)var17.valueOf(var6) : new File(var28, "resourcepacks/");
|
||||
Session var31 = new Session((String)var11.value(var17), (String)var12.value(var17));
|
||||
Minecraft var32 = new Minecraft(var31, var23, var24, var25, var26, var28, var29, var30, var20, var27);
|
||||
String var33 = (String)var17.valueOf(var2);
|
||||
|
||||
if (var33 != null)
|
||||
{
|
||||
var32.setServer(var33, ((Integer)var17.valueOf(var3)).intValue());
|
||||
}
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new MainShutdownHook());
|
||||
|
||||
if (!var18.isEmpty())
|
||||
{
|
||||
System.out.println("Completely ignored arguments: " + var18);
|
||||
}
|
||||
|
||||
Thread.currentThread().setName("Minecraft main thread");
|
||||
var32.run();
|
||||
}
|
||||
|
||||
private static boolean func_110121_a(String par0Str)
|
||||
{
|
||||
return par0Str != null && !par0Str.isEmpty();
|
||||
}
|
||||
}
|
||||
1367
src/main/java/net/minecraft/server/MinecraftServer.java
Normal file
1367
src/main/java/net/minecraft/server/MinecraftServer.java
Normal file
File diff suppressed because it is too large
Load Diff
14
src/main/java/net/minecraft/src/AABBLocalPool.java
Normal file
14
src/main/java/net/minecraft/src/AABBLocalPool.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
final class AABBLocalPool extends ThreadLocal
|
||||
{
|
||||
protected AABBPool createNewDefaultPool()
|
||||
{
|
||||
return new AABBPool(300, 2000);
|
||||
}
|
||||
|
||||
protected Object initialValue()
|
||||
{
|
||||
return this.createNewDefaultPool();
|
||||
}
|
||||
}
|
||||
106
src/main/java/net/minecraft/src/AABBPool.java
Normal file
106
src/main/java/net/minecraft/src/AABBPool.java
Normal file
@@ -0,0 +1,106 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AABBPool
|
||||
{
|
||||
/**
|
||||
* Maximum number of times the pool can be "cleaned" before the list is shrunk
|
||||
*/
|
||||
private final int maxNumCleans;
|
||||
|
||||
/**
|
||||
* Number of Pool entries to remove when cleanPool is called maxNumCleans times.
|
||||
*/
|
||||
private final int numEntriesToRemove;
|
||||
|
||||
/** List of AABB stored in this Pool */
|
||||
private final List listAABB = new ArrayList();
|
||||
|
||||
/** Next index to use when adding a Pool Entry. */
|
||||
private int nextPoolIndex;
|
||||
|
||||
/**
|
||||
* Largest index reached by this Pool (can be reset to 0 upon calling cleanPool)
|
||||
*/
|
||||
private int maxPoolIndex;
|
||||
|
||||
/** Number of times this Pool has been cleaned */
|
||||
private int numCleans;
|
||||
|
||||
public AABBPool(int par1, int par2)
|
||||
{
|
||||
this.maxNumCleans = par1;
|
||||
this.numEntriesToRemove = par2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AABB, or reuses one that's no longer in use. Parameters: minX, minY, minZ, maxX, maxY, maxZ. AABBs
|
||||
* returned from this function should only be used for one frame or tick, as after that they will be reused.
|
||||
*/
|
||||
public AxisAlignedBB getAABB(double par1, double par3, double par5, double par7, double par9, double par11)
|
||||
{
|
||||
AxisAlignedBB var13;
|
||||
|
||||
if (this.nextPoolIndex >= this.listAABB.size())
|
||||
{
|
||||
var13 = new AxisAlignedBB(par1, par3, par5, par7, par9, par11);
|
||||
this.listAABB.add(var13);
|
||||
}
|
||||
else
|
||||
{
|
||||
var13 = (AxisAlignedBB)this.listAABB.get(this.nextPoolIndex);
|
||||
var13.setBounds(par1, par3, par5, par7, par9, par11);
|
||||
}
|
||||
|
||||
++this.nextPoolIndex;
|
||||
return var13;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the pool as "empty", starting over when adding new entries. If this is called maxNumCleans times, the list
|
||||
* size is reduced
|
||||
*/
|
||||
public void cleanPool()
|
||||
{
|
||||
if (this.nextPoolIndex > this.maxPoolIndex)
|
||||
{
|
||||
this.maxPoolIndex = this.nextPoolIndex;
|
||||
}
|
||||
|
||||
if (this.numCleans++ == this.maxNumCleans)
|
||||
{
|
||||
int var1 = Math.max(this.maxPoolIndex, this.listAABB.size() - this.numEntriesToRemove);
|
||||
|
||||
while (this.listAABB.size() > var1)
|
||||
{
|
||||
this.listAABB.remove(var1);
|
||||
}
|
||||
|
||||
this.maxPoolIndex = 0;
|
||||
this.numCleans = 0;
|
||||
}
|
||||
|
||||
this.nextPoolIndex = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the AABBPool
|
||||
*/
|
||||
public void clearPool()
|
||||
{
|
||||
this.nextPoolIndex = 0;
|
||||
this.listAABB.clear();
|
||||
}
|
||||
|
||||
public int getlistAABBsize()
|
||||
{
|
||||
return this.listAABB.size();
|
||||
}
|
||||
|
||||
public int getnextPoolIndex()
|
||||
{
|
||||
return this.nextPoolIndex;
|
||||
}
|
||||
}
|
||||
98
src/main/java/net/minecraft/src/AbstractClientPlayer.java
Normal file
98
src/main/java/net/minecraft/src/AbstractClientPlayer.java
Normal file
@@ -0,0 +1,98 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public abstract class AbstractClientPlayer extends EntityPlayer
|
||||
{
|
||||
public static final ResourceLocation locationStevePng = new ResourceLocation("textures/entity/steve.png");
|
||||
private ThreadDownloadImageData downloadImageSkin;
|
||||
private ThreadDownloadImageData downloadImageCape;
|
||||
private ResourceLocation locationSkin;
|
||||
private ResourceLocation locationCape;
|
||||
|
||||
public AbstractClientPlayer(World par1World, String par2Str)
|
||||
{
|
||||
super(par1World, par2Str);
|
||||
this.setupCustomSkin();
|
||||
}
|
||||
|
||||
protected void setupCustomSkin()
|
||||
{
|
||||
System.out.println("Setting up custom skins");
|
||||
|
||||
if (this.username != null && !this.username.isEmpty())
|
||||
{
|
||||
this.locationSkin = getLocationSkin(this.username);
|
||||
this.locationCape = getLocationCape(this.username);
|
||||
this.downloadImageSkin = getDownloadImageSkin(this.locationSkin, this.username);
|
||||
this.downloadImageCape = getDownloadImageCape(this.locationCape, this.username);
|
||||
}
|
||||
}
|
||||
|
||||
public ThreadDownloadImageData getTextureSkin()
|
||||
{
|
||||
return this.downloadImageSkin;
|
||||
}
|
||||
|
||||
public ThreadDownloadImageData getTextureCape()
|
||||
{
|
||||
return this.downloadImageCape;
|
||||
}
|
||||
|
||||
public ResourceLocation getLocationSkin()
|
||||
{
|
||||
return this.locationSkin;
|
||||
}
|
||||
|
||||
public ResourceLocation getLocationCape()
|
||||
{
|
||||
return this.locationCape;
|
||||
}
|
||||
|
||||
public static ThreadDownloadImageData getDownloadImageSkin(ResourceLocation par0ResourceLocation, String par1Str)
|
||||
{
|
||||
return getDownloadImage(par0ResourceLocation, getSkinUrl(par1Str), locationStevePng, new ImageBufferDownload());
|
||||
}
|
||||
|
||||
public static ThreadDownloadImageData getDownloadImageCape(ResourceLocation par0ResourceLocation, String par1Str)
|
||||
{
|
||||
return getDownloadImage(par0ResourceLocation, getCapeUrl(par1Str), (ResourceLocation)null, (IImageBuffer)null);
|
||||
}
|
||||
|
||||
private static ThreadDownloadImageData getDownloadImage(ResourceLocation par0ResourceLocation, String par1Str, ResourceLocation par2ResourceLocation, IImageBuffer par3IImageBuffer)
|
||||
{
|
||||
TextureManager var4 = Minecraft.getMinecraft().getTextureManager();
|
||||
Object var5 = var4.getTexture(par0ResourceLocation);
|
||||
|
||||
if (var5 == null)
|
||||
{
|
||||
var5 = new ThreadDownloadImageData(par1Str, par2ResourceLocation, par3IImageBuffer);
|
||||
var4.loadTexture(par0ResourceLocation, (TextureObject)var5);
|
||||
}
|
||||
|
||||
return (ThreadDownloadImageData)var5;
|
||||
}
|
||||
|
||||
public static String getSkinUrl(String par0Str)
|
||||
{
|
||||
return String.format("http://skins.minecraft.net/MinecraftSkins/%s.png", new Object[] {StringUtils.stripControlCodes(par0Str)});
|
||||
}
|
||||
|
||||
public static String getCapeUrl(String par0Str)
|
||||
{
|
||||
return String.format("http://skins.minecraft.net/MinecraftCloaks/%s.png", new Object[] {StringUtils.stripControlCodes(par0Str)});
|
||||
}
|
||||
|
||||
public static ResourceLocation getLocationSkin(String par0Str)
|
||||
{
|
||||
return new ResourceLocation("skins/" + StringUtils.stripControlCodes(par0Str));
|
||||
}
|
||||
|
||||
public static ResourceLocation getLocationCape(String par0Str)
|
||||
{
|
||||
return new ResourceLocation("cloaks/" + StringUtils.stripControlCodes(par0Str));
|
||||
}
|
||||
|
||||
public static ResourceLocation getLocationSkull(String par0Str)
|
||||
{
|
||||
return new ResourceLocation("skull/" + StringUtils.stripControlCodes(par0Str));
|
||||
}
|
||||
}
|
||||
85
src/main/java/net/minecraft/src/AbstractResourcePack.java
Normal file
85
src/main/java/net/minecraft/src/AbstractResourcePack.java
Normal file
@@ -0,0 +1,85 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import javax.imageio.ImageIO;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
public abstract class AbstractResourcePack implements ResourcePack
|
||||
{
|
||||
protected static final ILogAgent resourceLog = Minecraft.getMinecraft().getLogAgent();
|
||||
protected final File resourcePackFile;
|
||||
|
||||
public AbstractResourcePack(File par1File)
|
||||
{
|
||||
this.resourcePackFile = par1File;
|
||||
}
|
||||
|
||||
private static String locationToName(ResourceLocation par0ResourceLocation)
|
||||
{
|
||||
return String.format("%s/%s/%s", new Object[] {"assets", par0ResourceLocation.getResourceDomain(), par0ResourceLocation.getResourcePath()});
|
||||
}
|
||||
|
||||
protected static String getRelativeName(File par0File, File par1File)
|
||||
{
|
||||
return par0File.toURI().relativize(par1File.toURI()).getPath();
|
||||
}
|
||||
|
||||
public InputStream getInputStream(ResourceLocation par1ResourceLocation) throws IOException
|
||||
{
|
||||
return this.getInputStreamByName(locationToName(par1ResourceLocation));
|
||||
}
|
||||
|
||||
public boolean resourceExists(ResourceLocation par1ResourceLocation)
|
||||
{
|
||||
return this.hasResourceName(locationToName(par1ResourceLocation));
|
||||
}
|
||||
|
||||
protected abstract InputStream getInputStreamByName(String var1) throws IOException;
|
||||
|
||||
protected abstract boolean hasResourceName(String var1);
|
||||
|
||||
protected void logNameNotLowercase(String par1Str)
|
||||
{
|
||||
resourceLog.logWarningFormatted("ResourcePack: ignored non-lowercase namespace: %s in %s", new Object[] {par1Str, this.resourcePackFile});
|
||||
}
|
||||
|
||||
public MetadataSection getPackMetadata(MetadataSerializer par1MetadataSerializer, String par2Str) throws IOException
|
||||
{
|
||||
return readMetadata(par1MetadataSerializer, this.getInputStreamByName("pack.mcmeta"), par2Str);
|
||||
}
|
||||
|
||||
static MetadataSection readMetadata(MetadataSerializer par0MetadataSerializer, InputStream par1InputStream, String par2Str)
|
||||
{
|
||||
JsonObject var3 = null;
|
||||
BufferedReader var4 = null;
|
||||
|
||||
try
|
||||
{
|
||||
var4 = new BufferedReader(new InputStreamReader(par1InputStream));
|
||||
var3 = (new JsonParser()).parse(var4).getAsJsonObject();
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(var4);
|
||||
}
|
||||
|
||||
return par0MetadataSerializer.parseMetadataSection(par2Str, var3);
|
||||
}
|
||||
|
||||
public BufferedImage getPackImage() throws IOException
|
||||
{
|
||||
return ImageIO.read(this.getInputStreamByName("pack.png"));
|
||||
}
|
||||
|
||||
public String getPackName()
|
||||
{
|
||||
return this.resourcePackFile.getName();
|
||||
}
|
||||
}
|
||||
16
src/main/java/net/minecraft/src/AbstractTexture.java
Normal file
16
src/main/java/net/minecraft/src/AbstractTexture.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public abstract class AbstractTexture implements TextureObject
|
||||
{
|
||||
protected int glTextureId = -1;
|
||||
|
||||
public int getGlTextureId()
|
||||
{
|
||||
if (this.glTextureId == -1)
|
||||
{
|
||||
this.glTextureId = TextureUtil.glGenTextures();
|
||||
}
|
||||
|
||||
return this.glTextureId;
|
||||
}
|
||||
}
|
||||
163
src/main/java/net/minecraft/src/Achievement.java
Normal file
163
src/main/java/net/minecraft/src/Achievement.java
Normal file
@@ -0,0 +1,163 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class Achievement extends StatBase
|
||||
{
|
||||
/**
|
||||
* Is the column (related to center of achievement gui, in 24 pixels unit) that the achievement will be displayed.
|
||||
*/
|
||||
public final int displayColumn;
|
||||
|
||||
/**
|
||||
* Is the row (related to center of achievement gui, in 24 pixels unit) that the achievement will be displayed.
|
||||
*/
|
||||
public final int displayRow;
|
||||
|
||||
/**
|
||||
* Holds the parent achievement, that must be taken before this achievement is avaiable.
|
||||
*/
|
||||
public final Achievement parentAchievement;
|
||||
|
||||
/**
|
||||
* Holds the description of the achievement, ready to be formatted and/or displayed.
|
||||
*/
|
||||
private final String achievementDescription;
|
||||
|
||||
/**
|
||||
* Holds a string formatter for the achievement, some of then needs extra dynamic info - like the key used to open
|
||||
* the inventory.
|
||||
*/
|
||||
private IStatStringFormat statStringFormatter;
|
||||
|
||||
/**
|
||||
* Holds the ItemStack that will be used to draw the achievement into the GUI.
|
||||
*/
|
||||
public final ItemStack theItemStack;
|
||||
|
||||
/**
|
||||
* Special achievements have a 'spiked' (on normal texture pack) frame, special achievements are the hardest ones to
|
||||
* achieve.
|
||||
*/
|
||||
private boolean isSpecial;
|
||||
|
||||
public Achievement(int par1, String par2Str, int par3, int par4, Item par5Item, Achievement par6Achievement)
|
||||
{
|
||||
this(par1, par2Str, par3, par4, new ItemStack(par5Item), par6Achievement);
|
||||
}
|
||||
|
||||
public Achievement(int par1, String par2Str, int par3, int par4, Block par5Block, Achievement par6Achievement)
|
||||
{
|
||||
this(par1, par2Str, par3, par4, new ItemStack(par5Block), par6Achievement);
|
||||
}
|
||||
|
||||
public Achievement(int par1, String par2Str, int par3, int par4, ItemStack par5ItemStack, Achievement par6Achievement)
|
||||
{
|
||||
super(5242880 + par1, "achievement." + par2Str);
|
||||
this.theItemStack = par5ItemStack;
|
||||
this.achievementDescription = "achievement." + par2Str + ".desc";
|
||||
this.displayColumn = par3;
|
||||
this.displayRow = par4;
|
||||
|
||||
if (par3 < AchievementList.minDisplayColumn)
|
||||
{
|
||||
AchievementList.minDisplayColumn = par3;
|
||||
}
|
||||
|
||||
if (par4 < AchievementList.minDisplayRow)
|
||||
{
|
||||
AchievementList.minDisplayRow = par4;
|
||||
}
|
||||
|
||||
if (par3 > AchievementList.maxDisplayColumn)
|
||||
{
|
||||
AchievementList.maxDisplayColumn = par3;
|
||||
}
|
||||
|
||||
if (par4 > AchievementList.maxDisplayRow)
|
||||
{
|
||||
AchievementList.maxDisplayRow = par4;
|
||||
}
|
||||
|
||||
this.parentAchievement = par6Achievement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether or not the given achievement or statistic is independent (i.e., lacks prerequisites for being
|
||||
* update).
|
||||
*/
|
||||
public Achievement setIndependent()
|
||||
{
|
||||
this.isIndependent = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Special achievements have a 'spiked' (on normal texture pack) frame, special achievements are the hardest ones to
|
||||
* achieve.
|
||||
*/
|
||||
public Achievement setSpecial()
|
||||
{
|
||||
this.isSpecial = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the achievement on the internal list of registered achievements, also, it's check for duplicated id's.
|
||||
*/
|
||||
public Achievement registerAchievement()
|
||||
{
|
||||
super.registerStat();
|
||||
AchievementList.achievementList.add(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the StatBase-derived class is a statistic (running counter) or an achievement (one-shot).
|
||||
*/
|
||||
public boolean isAchievement()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the fully description of the achievement - ready to be displayed on screen.
|
||||
*/
|
||||
public String getDescription()
|
||||
{
|
||||
return this.statStringFormatter != null ? this.statStringFormatter.formatString(StatCollector.translateToLocal(this.achievementDescription)) : StatCollector.translateToLocal(this.achievementDescription);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a string formatter for the achievement.
|
||||
*/
|
||||
public Achievement setStatStringFormatter(IStatStringFormat par1IStatStringFormat)
|
||||
{
|
||||
this.statStringFormatter = par1IStatStringFormat;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Special achievements have a 'spiked' (on normal texture pack) frame, special achievements are the hardest ones to
|
||||
* achieve.
|
||||
*/
|
||||
public boolean getSpecial()
|
||||
{
|
||||
return this.isSpecial;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the stat into StatList.
|
||||
*/
|
||||
public StatBase registerStat()
|
||||
{
|
||||
return this.registerAchievement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the current stat as independent (i.e., lacking prerequisites for being updated) and returns the
|
||||
* current instance.
|
||||
*/
|
||||
public StatBase initIndependentStat()
|
||||
{
|
||||
return this.setIndependent();
|
||||
}
|
||||
}
|
||||
106
src/main/java/net/minecraft/src/AchievementList.java
Normal file
106
src/main/java/net/minecraft/src/AchievementList.java
Normal file
@@ -0,0 +1,106 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AchievementList
|
||||
{
|
||||
/** Is the smallest column used to display a achievement on the GUI. */
|
||||
public static int minDisplayColumn;
|
||||
|
||||
/** Is the smallest row used to display a achievement on the GUI. */
|
||||
public static int minDisplayRow;
|
||||
|
||||
/** Is the biggest column used to display a achievement on the GUI. */
|
||||
public static int maxDisplayColumn;
|
||||
|
||||
/** Is the biggest row used to display a achievement on the GUI. */
|
||||
public static int maxDisplayRow;
|
||||
|
||||
/** Holds a list of all registered achievements. */
|
||||
public static List achievementList = new ArrayList();
|
||||
|
||||
/** Is the 'open inventory' achievement. */
|
||||
public static Achievement openInventory = (new Achievement(0, "openInventory", 0, 0, Item.book, (Achievement)null)).setIndependent().registerAchievement();
|
||||
|
||||
/** Is the 'getting wood' achievement. */
|
||||
public static Achievement mineWood = (new Achievement(1, "mineWood", 2, 1, Block.wood, openInventory)).registerAchievement();
|
||||
|
||||
/** Is the 'benchmarking' achievement. */
|
||||
public static Achievement buildWorkBench = (new Achievement(2, "buildWorkBench", 4, -1, Block.workbench, mineWood)).registerAchievement();
|
||||
|
||||
/** Is the 'time to mine' achievement. */
|
||||
public static Achievement buildPickaxe = (new Achievement(3, "buildPickaxe", 4, 2, Item.pickaxeWood, buildWorkBench)).registerAchievement();
|
||||
|
||||
/** Is the 'hot topic' achievement. */
|
||||
public static Achievement buildFurnace = (new Achievement(4, "buildFurnace", 3, 4, Block.furnaceIdle, buildPickaxe)).registerAchievement();
|
||||
|
||||
/** Is the 'acquire hardware' achievement. */
|
||||
public static Achievement acquireIron = (new Achievement(5, "acquireIron", 1, 4, Item.ingotIron, buildFurnace)).registerAchievement();
|
||||
|
||||
/** Is the 'time to farm' achievement. */
|
||||
public static Achievement buildHoe = (new Achievement(6, "buildHoe", 2, -3, Item.hoeWood, buildWorkBench)).registerAchievement();
|
||||
|
||||
/** Is the 'bake bread' achievement. */
|
||||
public static Achievement makeBread = (new Achievement(7, "makeBread", -1, -3, Item.bread, buildHoe)).registerAchievement();
|
||||
|
||||
/** Is the 'the lie' achievement. */
|
||||
public static Achievement bakeCake = (new Achievement(8, "bakeCake", 0, -5, Item.cake, buildHoe)).registerAchievement();
|
||||
|
||||
/** Is the 'getting a upgrade' achievement. */
|
||||
public static Achievement buildBetterPickaxe = (new Achievement(9, "buildBetterPickaxe", 6, 2, Item.pickaxeStone, buildPickaxe)).registerAchievement();
|
||||
|
||||
/** Is the 'delicious fish' achievement. */
|
||||
public static Achievement cookFish = (new Achievement(10, "cookFish", 2, 6, Item.fishCooked, buildFurnace)).registerAchievement();
|
||||
|
||||
/** Is the 'on a rail' achievement */
|
||||
public static Achievement onARail = (new Achievement(11, "onARail", 2, 3, Block.rail, acquireIron)).setSpecial().registerAchievement();
|
||||
|
||||
/** Is the 'time to strike' achievement. */
|
||||
public static Achievement buildSword = (new Achievement(12, "buildSword", 6, -1, Item.swordWood, buildWorkBench)).registerAchievement();
|
||||
|
||||
/** Is the 'monster hunter' achievement. */
|
||||
public static Achievement killEnemy = (new Achievement(13, "killEnemy", 8, -1, Item.bone, buildSword)).registerAchievement();
|
||||
|
||||
/** is the 'cow tipper' achievement. */
|
||||
public static Achievement killCow = (new Achievement(14, "killCow", 7, -3, Item.leather, buildSword)).registerAchievement();
|
||||
|
||||
/** Is the 'when pig fly' achievement. */
|
||||
public static Achievement flyPig = (new Achievement(15, "flyPig", 8, -4, Item.saddle, killCow)).setSpecial().registerAchievement();
|
||||
|
||||
/** The achievement for killing a Skeleton from 50 meters aways. */
|
||||
public static Achievement snipeSkeleton = (new Achievement(16, "snipeSkeleton", 7, 0, Item.bow, killEnemy)).setSpecial().registerAchievement();
|
||||
|
||||
/** Is the 'DIAMONDS!' achievement */
|
||||
public static Achievement diamonds = (new Achievement(17, "diamonds", -1, 5, Item.diamond, acquireIron)).registerAchievement();
|
||||
|
||||
/** Is the 'We Need to Go Deeper' achievement */
|
||||
public static Achievement portal = (new Achievement(18, "portal", -1, 7, Block.obsidian, diamonds)).registerAchievement();
|
||||
|
||||
/** Is the 'Return to Sender' achievement */
|
||||
public static Achievement ghast = (new Achievement(19, "ghast", -4, 8, Item.ghastTear, portal)).setSpecial().registerAchievement();
|
||||
|
||||
/** Is the 'Into Fire' achievement */
|
||||
public static Achievement blazeRod = (new Achievement(20, "blazeRod", 0, 9, Item.blazeRod, portal)).registerAchievement();
|
||||
|
||||
/** Is the 'Local Brewery' achievement */
|
||||
public static Achievement potion = (new Achievement(21, "potion", 2, 8, Item.potion, blazeRod)).registerAchievement();
|
||||
|
||||
/** Is the 'The End?' achievement */
|
||||
public static Achievement theEnd = (new Achievement(22, "theEnd", 3, 10, Item.eyeOfEnder, blazeRod)).setSpecial().registerAchievement();
|
||||
|
||||
/** Is the 'The End.' achievement */
|
||||
public static Achievement theEnd2 = (new Achievement(23, "theEnd2", 4, 13, Block.dragonEgg, theEnd)).setSpecial().registerAchievement();
|
||||
|
||||
/** Is the 'Enchanter' achievement */
|
||||
public static Achievement enchantments = (new Achievement(24, "enchantments", -4, 4, Block.enchantmentTable, diamonds)).registerAchievement();
|
||||
public static Achievement overkill = (new Achievement(25, "overkill", -4, 1, Item.swordDiamond, enchantments)).setSpecial().registerAchievement();
|
||||
|
||||
/** Is the 'Librarian' achievement */
|
||||
public static Achievement bookcase = (new Achievement(26, "bookcase", -3, 6, Block.bookShelf, enchantments)).registerAchievement();
|
||||
|
||||
/**
|
||||
* A stub functions called to make the static initializer for this class run.
|
||||
*/
|
||||
public static void init() {}
|
||||
}
|
||||
45
src/main/java/net/minecraft/src/AchievementMap.java
Normal file
45
src/main/java/net/minecraft/src/AchievementMap.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class AchievementMap
|
||||
{
|
||||
/** Holds the singleton instance of AchievementMap. */
|
||||
public static AchievementMap instance = new AchievementMap();
|
||||
|
||||
/** Maps a achievement id with it's unique GUID. */
|
||||
private Map guidMap = new HashMap();
|
||||
|
||||
private AchievementMap()
|
||||
{
|
||||
try
|
||||
{
|
||||
BufferedReader var1 = new BufferedReader(new InputStreamReader(AchievementMap.class.getResourceAsStream("/achievement/map.txt")));
|
||||
String var2;
|
||||
|
||||
while ((var2 = var1.readLine()) != null)
|
||||
{
|
||||
String[] var3 = var2.split(",");
|
||||
int var4 = Integer.parseInt(var3[0]);
|
||||
this.guidMap.put(Integer.valueOf(var4), var3[1]);
|
||||
}
|
||||
|
||||
var1.close();
|
||||
}
|
||||
catch (Exception var5)
|
||||
{
|
||||
var5.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unique GUID of a achievement id.
|
||||
*/
|
||||
public static String getGuid(int par0)
|
||||
{
|
||||
return (String)instance.guidMap.get(Integer.valueOf(par0));
|
||||
}
|
||||
}
|
||||
111
src/main/java/net/minecraft/src/ActiveRenderInfo.java
Normal file
111
src/main/java/net/minecraft/src/ActiveRenderInfo.java
Normal file
@@ -0,0 +1,111 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.util.glu.GLU;
|
||||
|
||||
public class ActiveRenderInfo
|
||||
{
|
||||
/** The calculated view object X coordinate */
|
||||
public static float objectX;
|
||||
|
||||
/** The calculated view object Y coordinate */
|
||||
public static float objectY;
|
||||
|
||||
/** The calculated view object Z coordinate */
|
||||
public static float objectZ;
|
||||
|
||||
/** The current GL viewport */
|
||||
private static IntBuffer viewport = GLAllocation.createDirectIntBuffer(16);
|
||||
|
||||
/** The current GL modelview matrix */
|
||||
private static FloatBuffer modelview = GLAllocation.createDirectFloatBuffer(16);
|
||||
|
||||
/** The current GL projection matrix */
|
||||
private static FloatBuffer projection = GLAllocation.createDirectFloatBuffer(16);
|
||||
|
||||
/** The computed view object coordinates */
|
||||
private static FloatBuffer objectCoords = GLAllocation.createDirectFloatBuffer(3);
|
||||
|
||||
/** The X component of the entity's yaw rotation */
|
||||
public static float rotationX;
|
||||
|
||||
/** The combined X and Z components of the entity's pitch rotation */
|
||||
public static float rotationXZ;
|
||||
|
||||
/** The Z component of the entity's yaw rotation */
|
||||
public static float rotationZ;
|
||||
|
||||
/**
|
||||
* The Y component (scaled along the Z axis) of the entity's pitch rotation
|
||||
*/
|
||||
public static float rotationYZ;
|
||||
|
||||
/**
|
||||
* The Y component (scaled along the X axis) of the entity's pitch rotation
|
||||
*/
|
||||
public static float rotationXY;
|
||||
|
||||
/**
|
||||
* Updates the current render info and camera location based on entity look angles and 1st/3rd person view mode
|
||||
*/
|
||||
public static void updateRenderInfo(EntityPlayer par0EntityPlayer, boolean par1)
|
||||
{
|
||||
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelview);
|
||||
GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projection);
|
||||
GL11.glGetInteger(GL11.GL_VIEWPORT, viewport);
|
||||
float var2 = (float)((viewport.get(0) + viewport.get(2)) / 2);
|
||||
float var3 = (float)((viewport.get(1) + viewport.get(3)) / 2);
|
||||
GLU.gluUnProject(var2, var3, 0.0F, modelview, projection, viewport, objectCoords);
|
||||
objectX = objectCoords.get(0);
|
||||
objectY = objectCoords.get(1);
|
||||
objectZ = objectCoords.get(2);
|
||||
int var4 = par1 ? 1 : 0;
|
||||
float var5 = par0EntityPlayer.rotationPitch;
|
||||
float var6 = par0EntityPlayer.rotationYaw;
|
||||
rotationX = MathHelper.cos(var6 * (float)Math.PI / 180.0F) * (float)(1 - var4 * 2);
|
||||
rotationZ = MathHelper.sin(var6 * (float)Math.PI / 180.0F) * (float)(1 - var4 * 2);
|
||||
rotationYZ = -rotationZ * MathHelper.sin(var5 * (float)Math.PI / 180.0F) * (float)(1 - var4 * 2);
|
||||
rotationXY = rotationX * MathHelper.sin(var5 * (float)Math.PI / 180.0F) * (float)(1 - var4 * 2);
|
||||
rotationXZ = MathHelper.cos(var5 * (float)Math.PI / 180.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a vector representing the projection along the given entity's view for the given distance
|
||||
*/
|
||||
public static Vec3 projectViewFromEntity(EntityLivingBase par0EntityLivingBase, double par1)
|
||||
{
|
||||
double var3 = par0EntityLivingBase.prevPosX + (par0EntityLivingBase.posX - par0EntityLivingBase.prevPosX) * par1;
|
||||
double var5 = par0EntityLivingBase.prevPosY + (par0EntityLivingBase.posY - par0EntityLivingBase.prevPosY) * par1 + (double)par0EntityLivingBase.getEyeHeight();
|
||||
double var7 = par0EntityLivingBase.prevPosZ + (par0EntityLivingBase.posZ - par0EntityLivingBase.prevPosZ) * par1;
|
||||
double var9 = var3 + (double)(objectX * 1.0F);
|
||||
double var11 = var5 + (double)(objectY * 1.0F);
|
||||
double var13 = var7 + (double)(objectZ * 1.0F);
|
||||
return par0EntityLivingBase.worldObj.getWorldVec3Pool().getVecFromPool(var9, var11, var13);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the block ID at the current camera location (either air or fluid), taking into account the height of
|
||||
* fluid blocks
|
||||
*/
|
||||
public static int getBlockIdAtEntityViewpoint(World par0World, EntityLivingBase par1EntityLivingBase, float par2)
|
||||
{
|
||||
Vec3 var3 = projectViewFromEntity(par1EntityLivingBase, (double)par2);
|
||||
ChunkPosition var4 = new ChunkPosition(var3);
|
||||
int var5 = par0World.getBlockId(var4.x, var4.y, var4.z);
|
||||
|
||||
if (var5 != 0 && Block.blocksList[var5].blockMaterial.isLiquid())
|
||||
{
|
||||
float var6 = BlockFluid.getFluidHeightPercent(par0World.getBlockMetadata(var4.x, var4.y, var4.z)) - 0.11111111F;
|
||||
float var7 = (float)(var4.y + 1) - var6;
|
||||
|
||||
if (var3.yCoord >= (double)var7)
|
||||
{
|
||||
var5 = par0World.getBlockId(var4.x, var4.y + 1, var4.z);
|
||||
}
|
||||
}
|
||||
|
||||
return var5;
|
||||
}
|
||||
}
|
||||
14
src/main/java/net/minecraft/src/AnimalChest.java
Normal file
14
src/main/java/net/minecraft/src/AnimalChest.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class AnimalChest extends InventoryBasic
|
||||
{
|
||||
public AnimalChest(String par1Str, int par2)
|
||||
{
|
||||
super(par1Str, false, par2);
|
||||
}
|
||||
|
||||
public AnimalChest(String par1Str, boolean par2, int par3)
|
||||
{
|
||||
super(par1Str, par2, par3);
|
||||
}
|
||||
}
|
||||
33
src/main/java/net/minecraft/src/AnimationFrame.java
Normal file
33
src/main/java/net/minecraft/src/AnimationFrame.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class AnimationFrame
|
||||
{
|
||||
private final int frameIndex;
|
||||
private final int frameTime;
|
||||
|
||||
public AnimationFrame(int par1)
|
||||
{
|
||||
this(par1, -1);
|
||||
}
|
||||
|
||||
public AnimationFrame(int par1, int par2)
|
||||
{
|
||||
this.frameIndex = par1;
|
||||
this.frameTime = par2;
|
||||
}
|
||||
|
||||
public boolean hasNoTime()
|
||||
{
|
||||
return this.frameTime == -1;
|
||||
}
|
||||
|
||||
public int getFrameTime()
|
||||
{
|
||||
return this.frameTime;
|
||||
}
|
||||
|
||||
public int getFrameIndex()
|
||||
{
|
||||
return this.frameIndex;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class AnimationMetadataSection implements MetadataSection
|
||||
{
|
||||
private final List animationFrames;
|
||||
private final int frameWidth;
|
||||
private final int frameHeight;
|
||||
private final int frameTime;
|
||||
|
||||
public AnimationMetadataSection(List par1List, int par2, int par3, int par4)
|
||||
{
|
||||
this.animationFrames = par1List;
|
||||
this.frameWidth = par2;
|
||||
this.frameHeight = par3;
|
||||
this.frameTime = par4;
|
||||
}
|
||||
|
||||
public int getFrameHeight()
|
||||
{
|
||||
return this.frameHeight;
|
||||
}
|
||||
|
||||
public int getFrameWidth()
|
||||
{
|
||||
return this.frameWidth;
|
||||
}
|
||||
|
||||
public int getFrameCount()
|
||||
{
|
||||
return this.animationFrames.size();
|
||||
}
|
||||
|
||||
public int getFrameTime()
|
||||
{
|
||||
return this.frameTime;
|
||||
}
|
||||
|
||||
private AnimationFrame getAnimationFrame(int par1)
|
||||
{
|
||||
return (AnimationFrame)this.animationFrames.get(par1);
|
||||
}
|
||||
|
||||
public int getFrameTimeSingle(int par1)
|
||||
{
|
||||
AnimationFrame var2 = this.getAnimationFrame(par1);
|
||||
return var2.hasNoTime() ? this.frameTime : var2.getFrameTime();
|
||||
}
|
||||
|
||||
public boolean frameHasTime(int par1)
|
||||
{
|
||||
return !((AnimationFrame)this.animationFrames.get(par1)).hasNoTime();
|
||||
}
|
||||
|
||||
public int getFrameIndex(int par1)
|
||||
{
|
||||
return ((AnimationFrame)this.animationFrames.get(par1)).getFrameIndex();
|
||||
}
|
||||
|
||||
public Set getFrameIndexSet()
|
||||
{
|
||||
HashSet var1 = Sets.newHashSet();
|
||||
Iterator var2 = this.animationFrames.iterator();
|
||||
|
||||
while (var2.hasNext())
|
||||
{
|
||||
AnimationFrame var3 = (AnimationFrame)var2.next();
|
||||
var1.add(Integer.valueOf(var3.getFrameIndex()));
|
||||
}
|
||||
|
||||
return var1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class AnimationMetadataSectionSerializer extends BaseMetadataSectionSerializer implements JsonSerializer
|
||||
{
|
||||
public AnimationMetadataSection func_110493_a(JsonElement par1JsonElement, Type par2Type, JsonDeserializationContext par3JsonDeserializationContext)
|
||||
{
|
||||
ArrayList var4 = Lists.newArrayList();
|
||||
JsonObject var5 = (JsonObject)par1JsonElement;
|
||||
int var6 = this.func_110485_a(var5.get("frametime"), "frametime", Integer.valueOf(1), 1, Integer.MAX_VALUE);
|
||||
int var8;
|
||||
|
||||
if (var5.has("frames"))
|
||||
{
|
||||
try
|
||||
{
|
||||
JsonArray var7 = var5.getAsJsonArray("frames");
|
||||
|
||||
for (var8 = 0; var8 < var7.size(); ++var8)
|
||||
{
|
||||
JsonElement var9 = var7.get(var8);
|
||||
AnimationFrame var10 = this.parseAnimationFrame(var8, var9);
|
||||
|
||||
if (var10 != null)
|
||||
{
|
||||
var4.add(var10);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ClassCastException var11)
|
||||
{
|
||||
throw new JsonParseException("Invalid animation->frames: expected array, was " + var5.get("frames"), var11);
|
||||
}
|
||||
}
|
||||
|
||||
int var12 = this.func_110485_a(var5.get("width"), "width", Integer.valueOf(-1), 1, Integer.MAX_VALUE);
|
||||
var8 = this.func_110485_a(var5.get("height"), "height", Integer.valueOf(-1), 1, Integer.MAX_VALUE);
|
||||
return new AnimationMetadataSection(var4, var12, var8, var6);
|
||||
}
|
||||
|
||||
private AnimationFrame parseAnimationFrame(int par1, JsonElement par2JsonElement)
|
||||
{
|
||||
if (par2JsonElement.isJsonPrimitive())
|
||||
{
|
||||
try
|
||||
{
|
||||
return new AnimationFrame(par2JsonElement.getAsInt());
|
||||
}
|
||||
catch (NumberFormatException var6)
|
||||
{
|
||||
throw new JsonParseException("Invalid animation->frames->" + par1 + ": expected number, was " + par2JsonElement, var6);
|
||||
}
|
||||
}
|
||||
else if (par2JsonElement.isJsonObject())
|
||||
{
|
||||
JsonObject var3 = par2JsonElement.getAsJsonObject();
|
||||
int var4 = this.func_110485_a(var3.get("time"), "frames->" + par1 + "->time", Integer.valueOf(-1), 1, Integer.MAX_VALUE);
|
||||
int var5 = this.func_110485_a(var3.get("index"), "frames->" + par1 + "->index", (Integer)null, 0, Integer.MAX_VALUE);
|
||||
return new AnimationFrame(var5, var4);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public JsonElement func_110491_a(AnimationMetadataSection par1AnimationMetadataSection, Type par2Type, JsonSerializationContext par3JsonSerializationContext)
|
||||
{
|
||||
JsonObject var4 = new JsonObject();
|
||||
var4.addProperty("frametime", Integer.valueOf(par1AnimationMetadataSection.getFrameTime()));
|
||||
|
||||
if (par1AnimationMetadataSection.getFrameWidth() != -1)
|
||||
{
|
||||
var4.addProperty("width", Integer.valueOf(par1AnimationMetadataSection.getFrameWidth()));
|
||||
}
|
||||
|
||||
if (par1AnimationMetadataSection.getFrameHeight() != -1)
|
||||
{
|
||||
var4.addProperty("height", Integer.valueOf(par1AnimationMetadataSection.getFrameHeight()));
|
||||
}
|
||||
|
||||
if (par1AnimationMetadataSection.getFrameCount() > 0)
|
||||
{
|
||||
JsonArray var5 = new JsonArray();
|
||||
|
||||
for (int var6 = 0; var6 < par1AnimationMetadataSection.getFrameCount(); ++var6)
|
||||
{
|
||||
if (par1AnimationMetadataSection.frameHasTime(var6))
|
||||
{
|
||||
JsonObject var7 = new JsonObject();
|
||||
var7.addProperty("index", Integer.valueOf(par1AnimationMetadataSection.getFrameIndex(var6)));
|
||||
var7.addProperty("time", Integer.valueOf(par1AnimationMetadataSection.getFrameTimeSingle(var6)));
|
||||
var5.add(var7);
|
||||
}
|
||||
else
|
||||
{
|
||||
var5.add(new JsonPrimitive(Integer.valueOf(par1AnimationMetadataSection.getFrameIndex(var6))));
|
||||
}
|
||||
}
|
||||
|
||||
var4.add("frames", var5);
|
||||
}
|
||||
|
||||
return var4;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of this section type as it appears in JSON.
|
||||
*/
|
||||
public String getSectionName()
|
||||
{
|
||||
return "animation";
|
||||
}
|
||||
|
||||
public Object deserialize(JsonElement par1JsonElement, Type par2Type, JsonDeserializationContext par3JsonDeserializationContext)
|
||||
{
|
||||
return this.func_110493_a(par1JsonElement, par2Type, par3JsonDeserializationContext);
|
||||
}
|
||||
|
||||
public JsonElement serialize(Object par1Obj, Type par2Type, JsonSerializationContext par3JsonSerializationContext)
|
||||
{
|
||||
return this.func_110491_a((AnimationMetadataSection)par1Obj, par2Type, par3JsonSerializationContext);
|
||||
}
|
||||
}
|
||||
425
src/main/java/net/minecraft/src/AnvilChunkLoader.java
Normal file
425
src/main/java/net/minecraft/src/AnvilChunkLoader.java
Normal file
@@ -0,0 +1,425 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class AnvilChunkLoader implements IChunkLoader, IThreadedFileIO
|
||||
{
|
||||
private List chunksToRemove = new ArrayList();
|
||||
private Set pendingAnvilChunksCoordinates = new HashSet();
|
||||
private Object syncLockObject = new Object();
|
||||
|
||||
/** Save directory for chunks using the Anvil format */
|
||||
private final File chunkSaveLocation;
|
||||
|
||||
public AnvilChunkLoader(File par1File)
|
||||
{
|
||||
this.chunkSaveLocation = par1File;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the specified(XZ) chunk into the specified world.
|
||||
*/
|
||||
public Chunk loadChunk(World par1World, int par2, int par3) throws IOException
|
||||
{
|
||||
NBTTagCompound var4 = null;
|
||||
ChunkCoordIntPair var5 = new ChunkCoordIntPair(par2, par3);
|
||||
Object var6 = this.syncLockObject;
|
||||
|
||||
synchronized (this.syncLockObject)
|
||||
{
|
||||
if (this.pendingAnvilChunksCoordinates.contains(var5))
|
||||
{
|
||||
for (int var7 = 0; var7 < this.chunksToRemove.size(); ++var7)
|
||||
{
|
||||
if (((AnvilChunkLoaderPending)this.chunksToRemove.get(var7)).chunkCoordinate.equals(var5))
|
||||
{
|
||||
var4 = ((AnvilChunkLoaderPending)this.chunksToRemove.get(var7)).nbtTags;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (var4 == null)
|
||||
{
|
||||
DataInputStream var10 = RegionFileCache.getChunkInputStream(this.chunkSaveLocation, par2, par3);
|
||||
|
||||
if (var10 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var4 = CompressedStreamTools.read(var10);
|
||||
}
|
||||
|
||||
return this.checkedReadChunkFromNBT(par1World, par2, par3, var4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps readChunkFromNBT. Checks the coordinates and several NBT tags.
|
||||
*/
|
||||
protected Chunk checkedReadChunkFromNBT(World par1World, int par2, int par3, NBTTagCompound par4NBTTagCompound)
|
||||
{
|
||||
if (!par4NBTTagCompound.hasKey("Level"))
|
||||
{
|
||||
par1World.getWorldLogAgent().logSevere("Chunk file at " + par2 + "," + par3 + " is missing level data, skipping");
|
||||
return null;
|
||||
}
|
||||
else if (!par4NBTTagCompound.getCompoundTag("Level").hasKey("Sections"))
|
||||
{
|
||||
par1World.getWorldLogAgent().logSevere("Chunk file at " + par2 + "," + par3 + " is missing block data, skipping");
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
Chunk var5 = this.readChunkFromNBT(par1World, par4NBTTagCompound.getCompoundTag("Level"));
|
||||
|
||||
if (!var5.isAtLocation(par2, par3))
|
||||
{
|
||||
par1World.getWorldLogAgent().logSevere("Chunk file at " + par2 + "," + par3 + " is in the wrong location; relocating. (Expected " + par2 + ", " + par3 + ", got " + var5.xPosition + ", " + var5.zPosition + ")");
|
||||
par4NBTTagCompound.setInteger("xPos", par2);
|
||||
par4NBTTagCompound.setInteger("zPos", par3);
|
||||
var5 = this.readChunkFromNBT(par1World, par4NBTTagCompound.getCompoundTag("Level"));
|
||||
}
|
||||
|
||||
return var5;
|
||||
}
|
||||
}
|
||||
|
||||
public void saveChunk(World par1World, Chunk par2Chunk) throws MinecraftException, IOException
|
||||
{
|
||||
par1World.checkSessionLock();
|
||||
|
||||
try
|
||||
{
|
||||
NBTTagCompound var3 = new NBTTagCompound();
|
||||
NBTTagCompound var4 = new NBTTagCompound();
|
||||
var3.setTag("Level", var4);
|
||||
this.writeChunkToNBT(par2Chunk, par1World, var4);
|
||||
this.addChunkToPending(par2Chunk.getChunkCoordIntPair(), var3);
|
||||
}
|
||||
catch (Exception var5)
|
||||
{
|
||||
var5.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected void addChunkToPending(ChunkCoordIntPair par1ChunkCoordIntPair, NBTTagCompound par2NBTTagCompound)
|
||||
{
|
||||
Object var3 = this.syncLockObject;
|
||||
|
||||
synchronized (this.syncLockObject)
|
||||
{
|
||||
if (this.pendingAnvilChunksCoordinates.contains(par1ChunkCoordIntPair))
|
||||
{
|
||||
for (int var4 = 0; var4 < this.chunksToRemove.size(); ++var4)
|
||||
{
|
||||
if (((AnvilChunkLoaderPending)this.chunksToRemove.get(var4)).chunkCoordinate.equals(par1ChunkCoordIntPair))
|
||||
{
|
||||
this.chunksToRemove.set(var4, new AnvilChunkLoaderPending(par1ChunkCoordIntPair, par2NBTTagCompound));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.chunksToRemove.add(new AnvilChunkLoaderPending(par1ChunkCoordIntPair, par2NBTTagCompound));
|
||||
this.pendingAnvilChunksCoordinates.add(par1ChunkCoordIntPair);
|
||||
ThreadedFileIOBase.threadedIOInstance.queueIO(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a boolean stating if the write was unsuccessful.
|
||||
*/
|
||||
public boolean writeNextIO()
|
||||
{
|
||||
AnvilChunkLoaderPending var1 = null;
|
||||
Object var2 = this.syncLockObject;
|
||||
|
||||
synchronized (this.syncLockObject)
|
||||
{
|
||||
if (this.chunksToRemove.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var1 = (AnvilChunkLoaderPending)this.chunksToRemove.remove(0);
|
||||
this.pendingAnvilChunksCoordinates.remove(var1.chunkCoordinate);
|
||||
}
|
||||
|
||||
if (var1 != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.writeChunkNBTTags(var1);
|
||||
}
|
||||
catch (Exception var4)
|
||||
{
|
||||
var4.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void writeChunkNBTTags(AnvilChunkLoaderPending par1AnvilChunkLoaderPending) throws IOException
|
||||
{
|
||||
DataOutputStream var2 = RegionFileCache.getChunkOutputStream(this.chunkSaveLocation, par1AnvilChunkLoaderPending.chunkCoordinate.chunkXPos, par1AnvilChunkLoaderPending.chunkCoordinate.chunkZPos);
|
||||
CompressedStreamTools.write(par1AnvilChunkLoaderPending.nbtTags, var2);
|
||||
var2.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save extra data associated with this Chunk not normally saved during autosave, only during chunk unload.
|
||||
* Currently unused.
|
||||
*/
|
||||
public void saveExtraChunkData(World par1World, Chunk par2Chunk) {}
|
||||
|
||||
/**
|
||||
* Called every World.tick()
|
||||
*/
|
||||
public void chunkTick() {}
|
||||
|
||||
/**
|
||||
* Save extra data not associated with any Chunk. Not saved during autosave, only during world unload. Currently
|
||||
* unused.
|
||||
*/
|
||||
public void saveExtraData()
|
||||
{
|
||||
while (this.writeNextIO())
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the Chunk passed as an argument to the NBTTagCompound also passed, using the World argument to retrieve
|
||||
* the Chunk's last update time.
|
||||
*/
|
||||
private void writeChunkToNBT(Chunk par1Chunk, World par2World, NBTTagCompound par3NBTTagCompound)
|
||||
{
|
||||
par3NBTTagCompound.setInteger("xPos", par1Chunk.xPosition);
|
||||
par3NBTTagCompound.setInteger("zPos", par1Chunk.zPosition);
|
||||
par3NBTTagCompound.setLong("LastUpdate", par2World.getTotalWorldTime());
|
||||
par3NBTTagCompound.setIntArray("HeightMap", par1Chunk.heightMap);
|
||||
par3NBTTagCompound.setBoolean("TerrainPopulated", par1Chunk.isTerrainPopulated);
|
||||
par3NBTTagCompound.setLong("InhabitedTime", par1Chunk.inhabitedTime);
|
||||
ExtendedBlockStorage[] var4 = par1Chunk.getBlockStorageArray();
|
||||
NBTTagList var5 = new NBTTagList("Sections");
|
||||
boolean var6 = !par2World.provider.hasNoSky;
|
||||
ExtendedBlockStorage[] var7 = var4;
|
||||
int var8 = var4.length;
|
||||
NBTTagCompound var11;
|
||||
|
||||
for (int var9 = 0; var9 < var8; ++var9)
|
||||
{
|
||||
ExtendedBlockStorage var10 = var7[var9];
|
||||
|
||||
if (var10 != null)
|
||||
{
|
||||
var11 = new NBTTagCompound();
|
||||
var11.setByte("Y", (byte)(var10.getYLocation() >> 4 & 255));
|
||||
var11.setByteArray("Blocks", var10.getBlockLSBArray());
|
||||
|
||||
if (var10.getBlockMSBArray() != null)
|
||||
{
|
||||
var11.setByteArray("Add", var10.getBlockMSBArray().data);
|
||||
}
|
||||
|
||||
var11.setByteArray("Data", var10.getMetadataArray().data);
|
||||
var11.setByteArray("BlockLight", var10.getBlocklightArray().data);
|
||||
|
||||
if (var6)
|
||||
{
|
||||
var11.setByteArray("SkyLight", var10.getSkylightArray().data);
|
||||
}
|
||||
else
|
||||
{
|
||||
var11.setByteArray("SkyLight", new byte[var10.getBlocklightArray().data.length]);
|
||||
}
|
||||
|
||||
var5.appendTag(var11);
|
||||
}
|
||||
}
|
||||
|
||||
par3NBTTagCompound.setTag("Sections", var5);
|
||||
par3NBTTagCompound.setByteArray("Biomes", par1Chunk.getBiomeArray());
|
||||
par1Chunk.hasEntities = false;
|
||||
NBTTagList var16 = new NBTTagList();
|
||||
Iterator var18;
|
||||
|
||||
for (var8 = 0; var8 < par1Chunk.entityLists.length; ++var8)
|
||||
{
|
||||
var18 = par1Chunk.entityLists[var8].iterator();
|
||||
|
||||
while (var18.hasNext())
|
||||
{
|
||||
Entity var20 = (Entity)var18.next();
|
||||
var11 = new NBTTagCompound();
|
||||
|
||||
if (var20.writeToNBTOptional(var11))
|
||||
{
|
||||
par1Chunk.hasEntities = true;
|
||||
var16.appendTag(var11);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
par3NBTTagCompound.setTag("Entities", var16);
|
||||
NBTTagList var17 = new NBTTagList();
|
||||
var18 = par1Chunk.chunkTileEntityMap.values().iterator();
|
||||
|
||||
while (var18.hasNext())
|
||||
{
|
||||
TileEntity var21 = (TileEntity)var18.next();
|
||||
var11 = new NBTTagCompound();
|
||||
var21.writeToNBT(var11);
|
||||
var17.appendTag(var11);
|
||||
}
|
||||
|
||||
par3NBTTagCompound.setTag("TileEntities", var17);
|
||||
List var19 = par2World.getPendingBlockUpdates(par1Chunk, false);
|
||||
|
||||
if (var19 != null)
|
||||
{
|
||||
long var22 = par2World.getTotalWorldTime();
|
||||
NBTTagList var12 = new NBTTagList();
|
||||
Iterator var13 = var19.iterator();
|
||||
|
||||
while (var13.hasNext())
|
||||
{
|
||||
NextTickListEntry var14 = (NextTickListEntry)var13.next();
|
||||
NBTTagCompound var15 = new NBTTagCompound();
|
||||
var15.setInteger("i", var14.blockID);
|
||||
var15.setInteger("x", var14.xCoord);
|
||||
var15.setInteger("y", var14.yCoord);
|
||||
var15.setInteger("z", var14.zCoord);
|
||||
var15.setInteger("t", (int)(var14.scheduledTime - var22));
|
||||
var15.setInteger("p", var14.priority);
|
||||
var12.appendTag(var15);
|
||||
}
|
||||
|
||||
par3NBTTagCompound.setTag("TileTicks", var12);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the data stored in the passed NBTTagCompound and creates a Chunk with that data in the passed World.
|
||||
* Returns the created Chunk.
|
||||
*/
|
||||
private Chunk readChunkFromNBT(World par1World, NBTTagCompound par2NBTTagCompound)
|
||||
{
|
||||
int var3 = par2NBTTagCompound.getInteger("xPos");
|
||||
int var4 = par2NBTTagCompound.getInteger("zPos");
|
||||
Chunk var5 = new Chunk(par1World, var3, var4);
|
||||
var5.heightMap = par2NBTTagCompound.getIntArray("HeightMap");
|
||||
var5.isTerrainPopulated = par2NBTTagCompound.getBoolean("TerrainPopulated");
|
||||
var5.inhabitedTime = par2NBTTagCompound.getLong("InhabitedTime");
|
||||
NBTTagList var6 = par2NBTTagCompound.getTagList("Sections");
|
||||
byte var7 = 16;
|
||||
ExtendedBlockStorage[] var8 = new ExtendedBlockStorage[var7];
|
||||
boolean var9 = !par1World.provider.hasNoSky;
|
||||
|
||||
for (int var10 = 0; var10 < var6.tagCount(); ++var10)
|
||||
{
|
||||
NBTTagCompound var11 = (NBTTagCompound)var6.tagAt(var10);
|
||||
byte var12 = var11.getByte("Y");
|
||||
ExtendedBlockStorage var13 = new ExtendedBlockStorage(var12 << 4, var9);
|
||||
var13.setBlockLSBArray(var11.getByteArray("Blocks"));
|
||||
|
||||
if (var11.hasKey("Add"))
|
||||
{
|
||||
var13.setBlockMSBArray(new NibbleArray(var11.getByteArray("Add"), 4));
|
||||
}
|
||||
|
||||
var13.setBlockMetadataArray(new NibbleArray(var11.getByteArray("Data"), 4));
|
||||
var13.setBlocklightArray(new NibbleArray(var11.getByteArray("BlockLight"), 4));
|
||||
|
||||
if (var9)
|
||||
{
|
||||
var13.setSkylightArray(new NibbleArray(var11.getByteArray("SkyLight"), 4));
|
||||
}
|
||||
|
||||
var13.removeInvalidBlocks();
|
||||
var8[var12] = var13;
|
||||
}
|
||||
|
||||
var5.setStorageArrays(var8);
|
||||
|
||||
if (par2NBTTagCompound.hasKey("Biomes"))
|
||||
{
|
||||
var5.setBiomeArray(par2NBTTagCompound.getByteArray("Biomes"));
|
||||
}
|
||||
|
||||
NBTTagList var17 = par2NBTTagCompound.getTagList("Entities");
|
||||
|
||||
if (var17 != null)
|
||||
{
|
||||
for (int var18 = 0; var18 < var17.tagCount(); ++var18)
|
||||
{
|
||||
NBTTagCompound var20 = (NBTTagCompound)var17.tagAt(var18);
|
||||
Entity var22 = EntityList.createEntityFromNBT(var20, par1World);
|
||||
var5.hasEntities = true;
|
||||
|
||||
if (var22 != null)
|
||||
{
|
||||
var5.addEntity(var22);
|
||||
Entity var14 = var22;
|
||||
|
||||
for (NBTTagCompound var15 = var20; var15.hasKey("Riding"); var15 = var15.getCompoundTag("Riding"))
|
||||
{
|
||||
Entity var16 = EntityList.createEntityFromNBT(var15.getCompoundTag("Riding"), par1World);
|
||||
|
||||
if (var16 != null)
|
||||
{
|
||||
var5.addEntity(var16);
|
||||
var14.mountEntity(var16);
|
||||
}
|
||||
|
||||
var14 = var16;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NBTTagList var19 = par2NBTTagCompound.getTagList("TileEntities");
|
||||
|
||||
if (var19 != null)
|
||||
{
|
||||
for (int var21 = 0; var21 < var19.tagCount(); ++var21)
|
||||
{
|
||||
NBTTagCompound var24 = (NBTTagCompound)var19.tagAt(var21);
|
||||
TileEntity var26 = TileEntity.createAndLoadEntity(var24);
|
||||
|
||||
if (var26 != null)
|
||||
{
|
||||
var5.addTileEntity(var26);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (par2NBTTagCompound.hasKey("TileTicks"))
|
||||
{
|
||||
NBTTagList var23 = par2NBTTagCompound.getTagList("TileTicks");
|
||||
|
||||
if (var23 != null)
|
||||
{
|
||||
for (int var25 = 0; var25 < var23.tagCount(); ++var25)
|
||||
{
|
||||
NBTTagCompound var27 = (NBTTagCompound)var23.tagAt(var25);
|
||||
par1World.scheduleBlockUpdateFromLoad(var27.getInteger("x"), var27.getInteger("y"), var27.getInteger("z"), var27.getInteger("i"), var27.getInteger("t"), var27.getInteger("p"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return var5;
|
||||
}
|
||||
}
|
||||
13
src/main/java/net/minecraft/src/AnvilChunkLoaderPending.java
Normal file
13
src/main/java/net/minecraft/src/AnvilChunkLoaderPending.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
class AnvilChunkLoaderPending
|
||||
{
|
||||
public final ChunkCoordIntPair chunkCoordinate;
|
||||
public final NBTTagCompound nbtTags;
|
||||
|
||||
public AnvilChunkLoaderPending(ChunkCoordIntPair par1ChunkCoordIntPair, NBTTagCompound par2NBTTagCompound)
|
||||
{
|
||||
this.chunkCoordinate = par1ChunkCoordIntPair;
|
||||
this.nbtTags = par2NBTTagCompound;
|
||||
}
|
||||
}
|
||||
23
src/main/java/net/minecraft/src/AnvilConverterData.java
Normal file
23
src/main/java/net/minecraft/src/AnvilConverterData.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class AnvilConverterData
|
||||
{
|
||||
public long lastUpdated;
|
||||
public boolean terrainPopulated;
|
||||
public byte[] heightmap;
|
||||
public NibbleArrayReader blockLight;
|
||||
public NibbleArrayReader skyLight;
|
||||
public NibbleArrayReader data;
|
||||
public byte[] blocks;
|
||||
public NBTTagList entities;
|
||||
public NBTTagList tileEntities;
|
||||
public NBTTagList tileTicks;
|
||||
public final int x;
|
||||
public final int z;
|
||||
|
||||
public AnvilConverterData(int par1, int par2)
|
||||
{
|
||||
this.x = par1;
|
||||
this.z = par2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class AnvilConverterException extends Exception
|
||||
{
|
||||
public AnvilConverterException(String par1Str)
|
||||
{
|
||||
super(par1Str);
|
||||
}
|
||||
}
|
||||
263
src/main/java/net/minecraft/src/AnvilSaveConverter.java
Normal file
263
src/main/java/net/minecraft/src/AnvilSaveConverter.java
Normal file
@@ -0,0 +1,263 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
public class AnvilSaveConverter extends SaveFormatOld
|
||||
{
|
||||
public AnvilSaveConverter(File par1File)
|
||||
{
|
||||
super(par1File);
|
||||
}
|
||||
|
||||
public List getSaveList() throws AnvilConverterException
|
||||
{
|
||||
if (this.savesDirectory != null && this.savesDirectory.exists() && this.savesDirectory.isDirectory())
|
||||
{
|
||||
ArrayList var1 = new ArrayList();
|
||||
File[] var2 = this.savesDirectory.listFiles();
|
||||
File[] var3 = var2;
|
||||
int var4 = var2.length;
|
||||
|
||||
for (int var5 = 0; var5 < var4; ++var5)
|
||||
{
|
||||
File var6 = var3[var5];
|
||||
|
||||
if (var6.isDirectory())
|
||||
{
|
||||
String var7 = var6.getName();
|
||||
WorldInfo var8 = this.getWorldInfo(var7);
|
||||
|
||||
if (var8 != null && (var8.getSaveVersion() == 19132 || var8.getSaveVersion() == 19133))
|
||||
{
|
||||
boolean var9 = var8.getSaveVersion() != this.getSaveVersion();
|
||||
String var10 = var8.getWorldName();
|
||||
|
||||
if (var10 == null || MathHelper.stringNullOrLengthZero(var10))
|
||||
{
|
||||
var10 = var7;
|
||||
}
|
||||
|
||||
long var11 = 0L;
|
||||
var1.add(new SaveFormatComparator(var7, var10, var8.getLastTimePlayed(), var11, var8.getGameType(), var9, var8.isHardcoreModeEnabled(), var8.areCommandsAllowed()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return var1;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AnvilConverterException("Unable to read or access folder where game worlds are saved!");
|
||||
}
|
||||
}
|
||||
|
||||
protected int getSaveVersion()
|
||||
{
|
||||
return 19133;
|
||||
}
|
||||
|
||||
public void flushCache()
|
||||
{
|
||||
RegionFileCache.clearRegionFileReferences();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns back a loader for the specified save directory
|
||||
*/
|
||||
public ISaveHandler getSaveLoader(String par1Str, boolean par2)
|
||||
{
|
||||
return new AnvilSaveHandler(this.savesDirectory, par1Str, par2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the save directory uses the old map format
|
||||
*/
|
||||
public boolean isOldMapFormat(String par1Str)
|
||||
{
|
||||
WorldInfo var2 = this.getWorldInfo(par1Str);
|
||||
return var2 != null && var2.getSaveVersion() != this.getSaveVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the specified map to the new map format. Args: worldName, loadingScreen
|
||||
*/
|
||||
public boolean convertMapFormat(String par1Str, IProgressUpdate par2IProgressUpdate)
|
||||
{
|
||||
par2IProgressUpdate.setLoadingProgress(0);
|
||||
ArrayList var3 = new ArrayList();
|
||||
ArrayList var4 = new ArrayList();
|
||||
ArrayList var5 = new ArrayList();
|
||||
File var6 = new File(this.savesDirectory, par1Str);
|
||||
File var7 = new File(var6, "DIM-1");
|
||||
File var8 = new File(var6, "DIM1");
|
||||
MinecraftServer.getServer().getLogAgent().logInfo("Scanning folders...");
|
||||
this.addRegionFilesToCollection(var6, var3);
|
||||
|
||||
if (var7.exists())
|
||||
{
|
||||
this.addRegionFilesToCollection(var7, var4);
|
||||
}
|
||||
|
||||
if (var8.exists())
|
||||
{
|
||||
this.addRegionFilesToCollection(var8, var5);
|
||||
}
|
||||
|
||||
int var9 = var3.size() + var4.size() + var5.size();
|
||||
MinecraftServer.getServer().getLogAgent().logInfo("Total conversion count is " + var9);
|
||||
WorldInfo var10 = this.getWorldInfo(par1Str);
|
||||
Object var11 = null;
|
||||
|
||||
if (var10.getTerrainType() == WorldType.FLAT)
|
||||
{
|
||||
var11 = new WorldChunkManagerHell(BiomeGenBase.plains, 0.5F, 0.5F);
|
||||
}
|
||||
else
|
||||
{
|
||||
var11 = new WorldChunkManager(var10.getSeed(), var10.getTerrainType());
|
||||
}
|
||||
|
||||
this.convertFile(new File(var6, "region"), var3, (WorldChunkManager)var11, 0, var9, par2IProgressUpdate);
|
||||
this.convertFile(new File(var7, "region"), var4, new WorldChunkManagerHell(BiomeGenBase.hell, 1.0F, 0.0F), var3.size(), var9, par2IProgressUpdate);
|
||||
this.convertFile(new File(var8, "region"), var5, new WorldChunkManagerHell(BiomeGenBase.sky, 0.5F, 0.0F), var3.size() + var4.size(), var9, par2IProgressUpdate);
|
||||
var10.setSaveVersion(19133);
|
||||
|
||||
if (var10.getTerrainType() == WorldType.DEFAULT_1_1)
|
||||
{
|
||||
var10.setTerrainType(WorldType.DEFAULT);
|
||||
}
|
||||
|
||||
this.createFile(par1Str);
|
||||
ISaveHandler var12 = this.getSaveLoader(par1Str, false);
|
||||
var12.saveWorldInfo(var10);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* par: filename for the level.dat_mcr backup
|
||||
*/
|
||||
private void createFile(String par1Str)
|
||||
{
|
||||
File var2 = new File(this.savesDirectory, par1Str);
|
||||
|
||||
if (!var2.exists())
|
||||
{
|
||||
System.out.println("Warning: Unable to create level.dat_mcr backup");
|
||||
}
|
||||
else
|
||||
{
|
||||
File var3 = new File(var2, "level.dat");
|
||||
|
||||
if (!var3.exists())
|
||||
{
|
||||
System.out.println("Warning: Unable to create level.dat_mcr backup");
|
||||
}
|
||||
else
|
||||
{
|
||||
File var4 = new File(var2, "level.dat_mcr");
|
||||
|
||||
if (!var3.renameTo(var4))
|
||||
{
|
||||
System.out.println("Warning: Unable to create level.dat_mcr backup");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void convertFile(File par1File, Iterable par2Iterable, WorldChunkManager par3WorldChunkManager, int par4, int par5, IProgressUpdate par6IProgressUpdate)
|
||||
{
|
||||
Iterator var7 = par2Iterable.iterator();
|
||||
|
||||
while (var7.hasNext())
|
||||
{
|
||||
File var8 = (File)var7.next();
|
||||
this.convertChunks(par1File, var8, par3WorldChunkManager, par4, par5, par6IProgressUpdate);
|
||||
++par4;
|
||||
int var9 = (int)Math.round(100.0D * (double)par4 / (double)par5);
|
||||
par6IProgressUpdate.setLoadingProgress(var9);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* copies a 32x32 chunk set from par2File to par1File, via AnvilConverterData
|
||||
*/
|
||||
private void convertChunks(File par1File, File par2File, WorldChunkManager par3WorldChunkManager, int par4, int par5, IProgressUpdate par6IProgressUpdate)
|
||||
{
|
||||
try
|
||||
{
|
||||
String var7 = par2File.getName();
|
||||
RegionFile var8 = new RegionFile(par2File);
|
||||
RegionFile var9 = new RegionFile(new File(par1File, var7.substring(0, var7.length() - ".mcr".length()) + ".mca"));
|
||||
|
||||
for (int var10 = 0; var10 < 32; ++var10)
|
||||
{
|
||||
int var11;
|
||||
|
||||
for (var11 = 0; var11 < 32; ++var11)
|
||||
{
|
||||
if (var8.isChunkSaved(var10, var11) && !var9.isChunkSaved(var10, var11))
|
||||
{
|
||||
DataInputStream var12 = var8.getChunkDataInputStream(var10, var11);
|
||||
|
||||
if (var12 == null)
|
||||
{
|
||||
MinecraftServer.getServer().getLogAgent().logWarning("Failed to fetch input stream");
|
||||
}
|
||||
else
|
||||
{
|
||||
NBTTagCompound var13 = CompressedStreamTools.read(var12);
|
||||
var12.close();
|
||||
NBTTagCompound var14 = var13.getCompoundTag("Level");
|
||||
AnvilConverterData var15 = ChunkLoader.load(var14);
|
||||
NBTTagCompound var16 = new NBTTagCompound();
|
||||
NBTTagCompound var17 = new NBTTagCompound();
|
||||
var16.setTag("Level", var17);
|
||||
ChunkLoader.convertToAnvilFormat(var15, var17, par3WorldChunkManager);
|
||||
DataOutputStream var18 = var9.getChunkDataOutputStream(var10, var11);
|
||||
CompressedStreamTools.write(var16, var18);
|
||||
var18.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var11 = (int)Math.round(100.0D * (double)(par4 * 1024) / (double)(par5 * 1024));
|
||||
int var20 = (int)Math.round(100.0D * (double)((var10 + 1) * 32 + par4 * 1024) / (double)(par5 * 1024));
|
||||
|
||||
if (var20 > var11)
|
||||
{
|
||||
par6IProgressUpdate.setLoadingProgress(var20);
|
||||
}
|
||||
}
|
||||
|
||||
var8.close();
|
||||
var9.close();
|
||||
}
|
||||
catch (IOException var19)
|
||||
{
|
||||
var19.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* filters the files in the par1 directory, and adds them to the par2 collections
|
||||
*/
|
||||
private void addRegionFilesToCollection(File par1File, Collection par2Collection)
|
||||
{
|
||||
File var3 = new File(par1File, "region");
|
||||
File[] var4 = var3.listFiles(new AnvilSaveConverterFileFilter(this));
|
||||
|
||||
if (var4 != null)
|
||||
{
|
||||
Collections.addAll(par2Collection, var4);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
|
||||
class AnvilSaveConverterFileFilter implements FilenameFilter
|
||||
{
|
||||
final AnvilSaveConverter parent;
|
||||
|
||||
AnvilSaveConverterFileFilter(AnvilSaveConverter par1AnvilSaveConverter)
|
||||
{
|
||||
this.parent = par1AnvilSaveConverter;
|
||||
}
|
||||
|
||||
public boolean accept(File par1File, String par2Str)
|
||||
{
|
||||
return par2Str.endsWith(".mcr");
|
||||
}
|
||||
}
|
||||
63
src/main/java/net/minecraft/src/AnvilSaveHandler.java
Normal file
63
src/main/java/net/minecraft/src/AnvilSaveHandler.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class AnvilSaveHandler extends SaveHandler
|
||||
{
|
||||
public AnvilSaveHandler(File par1File, String par2Str, boolean par3)
|
||||
{
|
||||
super(par1File, par2Str, par3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chunk loader with the provided world provider
|
||||
*/
|
||||
public IChunkLoader getChunkLoader(WorldProvider par1WorldProvider)
|
||||
{
|
||||
File var2 = this.getWorldDirectory();
|
||||
File var3;
|
||||
|
||||
if (par1WorldProvider instanceof WorldProviderHell)
|
||||
{
|
||||
var3 = new File(var2, "DIM-1");
|
||||
var3.mkdirs();
|
||||
return new AnvilChunkLoader(var3);
|
||||
}
|
||||
else if (par1WorldProvider instanceof WorldProviderEnd)
|
||||
{
|
||||
var3 = new File(var2, "DIM1");
|
||||
var3.mkdirs();
|
||||
return new AnvilChunkLoader(var3);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new AnvilChunkLoader(var2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the given World Info with the given NBTTagCompound as the Player.
|
||||
*/
|
||||
public void saveWorldInfoWithPlayer(WorldInfo par1WorldInfo, NBTTagCompound par2NBTTagCompound)
|
||||
{
|
||||
par1WorldInfo.setSaveVersion(19133);
|
||||
super.saveWorldInfoWithPlayer(par1WorldInfo, par2NBTTagCompound);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to flush all changes to disk, waiting for them to complete.
|
||||
*/
|
||||
public void flush()
|
||||
{
|
||||
try
|
||||
{
|
||||
ThreadedFileIOBase.threadedIOInstance.waitForFinish();
|
||||
}
|
||||
catch (InterruptedException var2)
|
||||
{
|
||||
var2.printStackTrace();
|
||||
}
|
||||
|
||||
RegionFileCache.clearRegionFileReferences();
|
||||
}
|
||||
}
|
||||
12
src/main/java/net/minecraft/src/Attribute.java
Normal file
12
src/main/java/net/minecraft/src/Attribute.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public interface Attribute
|
||||
{
|
||||
String getAttributeUnlocalizedName();
|
||||
|
||||
double clampValue(double var1);
|
||||
|
||||
double getDefaultValue();
|
||||
|
||||
boolean getShouldWatch();
|
||||
}
|
||||
28
src/main/java/net/minecraft/src/AttributeInstance.java
Normal file
28
src/main/java/net/minecraft/src/AttributeInstance.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface AttributeInstance
|
||||
{
|
||||
Attribute func_111123_a();
|
||||
|
||||
double getBaseValue();
|
||||
|
||||
void setAttribute(double var1);
|
||||
|
||||
Collection func_111122_c();
|
||||
|
||||
/**
|
||||
* Returns attribute modifier, if any, by the given UUID
|
||||
*/
|
||||
AttributeModifier getModifier(UUID var1);
|
||||
|
||||
void applyModifier(AttributeModifier var1);
|
||||
|
||||
void removeModifier(AttributeModifier var1);
|
||||
|
||||
void func_142049_d();
|
||||
|
||||
double getAttributeValue();
|
||||
}
|
||||
110
src/main/java/net/minecraft/src/AttributeModifier.java
Normal file
110
src/main/java/net/minecraft/src/AttributeModifier.java
Normal file
@@ -0,0 +1,110 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
public class AttributeModifier
|
||||
{
|
||||
private final double amount;
|
||||
private final int operation;
|
||||
private final String name;
|
||||
private final UUID id;
|
||||
|
||||
/**
|
||||
* If false, this modifier is not saved in NBT. Used for "natural" modifiers like speed boost from sprinting
|
||||
*/
|
||||
private boolean isSaved;
|
||||
|
||||
public AttributeModifier(String par1Str, double par2, int par4)
|
||||
{
|
||||
this(UUID.randomUUID(), par1Str, par2, par4);
|
||||
}
|
||||
|
||||
public AttributeModifier(UUID par1UUID, String par2Str, double par3, int par5)
|
||||
{
|
||||
this.isSaved = true;
|
||||
this.id = par1UUID;
|
||||
this.name = par2Str;
|
||||
this.amount = par3;
|
||||
this.operation = par5;
|
||||
Validate.notEmpty(par2Str, "Modifier name cannot be empty", new Object[0]);
|
||||
Validate.inclusiveBetween(Integer.valueOf(0), Integer.valueOf(2), Integer.valueOf(par5), "Invalid operation", new Object[0]);
|
||||
}
|
||||
|
||||
public UUID getID()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public int getOperation()
|
||||
{
|
||||
return this.operation;
|
||||
}
|
||||
|
||||
public double getAmount()
|
||||
{
|
||||
return this.amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #isSaved
|
||||
*/
|
||||
public boolean isSaved()
|
||||
{
|
||||
return this.isSaved;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #isSaved
|
||||
*/
|
||||
public AttributeModifier setSaved(boolean par1)
|
||||
{
|
||||
this.isSaved = par1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean equals(Object par1Obj)
|
||||
{
|
||||
if (this == par1Obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (par1Obj != null && this.getClass() == par1Obj.getClass())
|
||||
{
|
||||
AttributeModifier var2 = (AttributeModifier)par1Obj;
|
||||
|
||||
if (this.id != null)
|
||||
{
|
||||
if (!this.id.equals(var2.id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (var2.id != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return this.id != null ? this.id.hashCode() : 0;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "AttributeModifier{amount=" + this.amount + ", operation=" + this.operation + ", name=\'" + this.name + '\'' + ", id=" + this.id + ", serialize=" + this.isSaved + '}';
|
||||
}
|
||||
}
|
||||
489
src/main/java/net/minecraft/src/AxisAlignedBB.java
Normal file
489
src/main/java/net/minecraft/src/AxisAlignedBB.java
Normal file
@@ -0,0 +1,489 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class AxisAlignedBB
|
||||
{
|
||||
/** ThreadLocal AABBPool */
|
||||
private static final ThreadLocal theAABBLocalPool = new AABBLocalPool();
|
||||
public double minX;
|
||||
public double minY;
|
||||
public double minZ;
|
||||
public double maxX;
|
||||
public double maxY;
|
||||
public double maxZ;
|
||||
|
||||
/**
|
||||
* Returns a bounding box with the specified bounds. Args: minX, minY, minZ, maxX, maxY, maxZ
|
||||
*/
|
||||
public static AxisAlignedBB getBoundingBox(double par0, double par2, double par4, double par6, double par8, double par10)
|
||||
{
|
||||
return new AxisAlignedBB(par0, par2, par4, par6, par8, par10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ThreadLocal AABBPool
|
||||
*/
|
||||
public static AABBPool getAABBPool()
|
||||
{
|
||||
return (AABBPool)theAABBLocalPool.get();
|
||||
}
|
||||
|
||||
protected AxisAlignedBB(double par1, double par3, double par5, double par7, double par9, double par11)
|
||||
{
|
||||
this.minX = par1;
|
||||
this.minY = par3;
|
||||
this.minZ = par5;
|
||||
this.maxX = par7;
|
||||
this.maxY = par9;
|
||||
this.maxZ = par11;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bounds of the bounding box. Args: minX, minY, minZ, maxX, maxY, maxZ
|
||||
*/
|
||||
public AxisAlignedBB setBounds(double par1, double par3, double par5, double par7, double par9, double par11)
|
||||
{
|
||||
this.minX = par1;
|
||||
this.minY = par3;
|
||||
this.minZ = par5;
|
||||
this.maxX = par7;
|
||||
this.maxY = par9;
|
||||
this.maxZ = par11;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the coordinates to the bounding box extending it if the point lies outside the current ranges. Args: x, y, z
|
||||
*/
|
||||
public AxisAlignedBB addCoord(double par1, double par3, double par5)
|
||||
{
|
||||
double var7 = this.minX;
|
||||
double var9 = this.minY;
|
||||
double var11 = this.minZ;
|
||||
double var13 = this.maxX;
|
||||
double var15 = this.maxY;
|
||||
double var17 = this.maxZ;
|
||||
|
||||
if (par1 < 0.0D)
|
||||
{
|
||||
var7 += par1;
|
||||
}
|
||||
|
||||
if (par1 > 0.0D)
|
||||
{
|
||||
var13 += par1;
|
||||
}
|
||||
|
||||
if (par3 < 0.0D)
|
||||
{
|
||||
var9 += par3;
|
||||
}
|
||||
|
||||
if (par3 > 0.0D)
|
||||
{
|
||||
var15 += par3;
|
||||
}
|
||||
|
||||
if (par5 < 0.0D)
|
||||
{
|
||||
var11 += par5;
|
||||
}
|
||||
|
||||
if (par5 > 0.0D)
|
||||
{
|
||||
var17 += par5;
|
||||
}
|
||||
|
||||
return getAABBPool().getAABB(var7, var9, var11, var13, var15, var17);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bounding box expanded by the specified vector (if negative numbers are given it will shrink). Args: x,
|
||||
* y, z
|
||||
*/
|
||||
public AxisAlignedBB expand(double par1, double par3, double par5)
|
||||
{
|
||||
double var7 = this.minX - par1;
|
||||
double var9 = this.minY - par3;
|
||||
double var11 = this.minZ - par5;
|
||||
double var13 = this.maxX + par1;
|
||||
double var15 = this.maxY + par3;
|
||||
double var17 = this.maxZ + par5;
|
||||
return getAABBPool().getAABB(var7, var9, var11, var13, var15, var17);
|
||||
}
|
||||
|
||||
public AxisAlignedBB func_111270_a(AxisAlignedBB par1AxisAlignedBB)
|
||||
{
|
||||
double var2 = Math.min(this.minX, par1AxisAlignedBB.minX);
|
||||
double var4 = Math.min(this.minY, par1AxisAlignedBB.minY);
|
||||
double var6 = Math.min(this.minZ, par1AxisAlignedBB.minZ);
|
||||
double var8 = Math.max(this.maxX, par1AxisAlignedBB.maxX);
|
||||
double var10 = Math.max(this.maxY, par1AxisAlignedBB.maxY);
|
||||
double var12 = Math.max(this.maxZ, par1AxisAlignedBB.maxZ);
|
||||
return getAABBPool().getAABB(var2, var4, var6, var8, var10, var12);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bounding box offseted by the specified vector (if negative numbers are given it will shrink). Args: x,
|
||||
* y, z
|
||||
*/
|
||||
public AxisAlignedBB getOffsetBoundingBox(double par1, double par3, double par5)
|
||||
{
|
||||
return getAABBPool().getAABB(this.minX + par1, this.minY + par3, this.minZ + par5, this.maxX + par1, this.maxY + par3, this.maxZ + par5);
|
||||
}
|
||||
|
||||
/**
|
||||
* if instance and the argument bounding boxes overlap in the Y and Z dimensions, calculate the offset between them
|
||||
* in the X dimension. return var2 if the bounding boxes do not overlap or if var2 is closer to 0 then the
|
||||
* calculated offset. Otherwise return the calculated offset.
|
||||
*/
|
||||
public double calculateXOffset(AxisAlignedBB par1AxisAlignedBB, double par2)
|
||||
{
|
||||
if (par1AxisAlignedBB.maxY > this.minY && par1AxisAlignedBB.minY < this.maxY)
|
||||
{
|
||||
if (par1AxisAlignedBB.maxZ > this.minZ && par1AxisAlignedBB.minZ < this.maxZ)
|
||||
{
|
||||
double var4;
|
||||
|
||||
if (par2 > 0.0D && par1AxisAlignedBB.maxX <= this.minX)
|
||||
{
|
||||
var4 = this.minX - par1AxisAlignedBB.maxX;
|
||||
|
||||
if (var4 < par2)
|
||||
{
|
||||
par2 = var4;
|
||||
}
|
||||
}
|
||||
|
||||
if (par2 < 0.0D && par1AxisAlignedBB.minX >= this.maxX)
|
||||
{
|
||||
var4 = this.maxX - par1AxisAlignedBB.minX;
|
||||
|
||||
if (var4 > par2)
|
||||
{
|
||||
par2 = var4;
|
||||
}
|
||||
}
|
||||
|
||||
return par2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return par2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return par2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* if instance and the argument bounding boxes overlap in the X and Z dimensions, calculate the offset between them
|
||||
* in the Y dimension. return var2 if the bounding boxes do not overlap or if var2 is closer to 0 then the
|
||||
* calculated offset. Otherwise return the calculated offset.
|
||||
*/
|
||||
public double calculateYOffset(AxisAlignedBB par1AxisAlignedBB, double par2)
|
||||
{
|
||||
if (par1AxisAlignedBB.maxX > this.minX && par1AxisAlignedBB.minX < this.maxX)
|
||||
{
|
||||
if (par1AxisAlignedBB.maxZ > this.minZ && par1AxisAlignedBB.minZ < this.maxZ)
|
||||
{
|
||||
double var4;
|
||||
|
||||
if (par2 > 0.0D && par1AxisAlignedBB.maxY <= this.minY)
|
||||
{
|
||||
var4 = this.minY - par1AxisAlignedBB.maxY;
|
||||
|
||||
if (var4 < par2)
|
||||
{
|
||||
par2 = var4;
|
||||
}
|
||||
}
|
||||
|
||||
if (par2 < 0.0D && par1AxisAlignedBB.minY >= this.maxY)
|
||||
{
|
||||
var4 = this.maxY - par1AxisAlignedBB.minY;
|
||||
|
||||
if (var4 > par2)
|
||||
{
|
||||
par2 = var4;
|
||||
}
|
||||
}
|
||||
|
||||
return par2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return par2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return par2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* if instance and the argument bounding boxes overlap in the Y and X dimensions, calculate the offset between them
|
||||
* in the Z dimension. return var2 if the bounding boxes do not overlap or if var2 is closer to 0 then the
|
||||
* calculated offset. Otherwise return the calculated offset.
|
||||
*/
|
||||
public double calculateZOffset(AxisAlignedBB par1AxisAlignedBB, double par2)
|
||||
{
|
||||
if (par1AxisAlignedBB.maxX > this.minX && par1AxisAlignedBB.minX < this.maxX)
|
||||
{
|
||||
if (par1AxisAlignedBB.maxY > this.minY && par1AxisAlignedBB.minY < this.maxY)
|
||||
{
|
||||
double var4;
|
||||
|
||||
if (par2 > 0.0D && par1AxisAlignedBB.maxZ <= this.minZ)
|
||||
{
|
||||
var4 = this.minZ - par1AxisAlignedBB.maxZ;
|
||||
|
||||
if (var4 < par2)
|
||||
{
|
||||
par2 = var4;
|
||||
}
|
||||
}
|
||||
|
||||
if (par2 < 0.0D && par1AxisAlignedBB.minZ >= this.maxZ)
|
||||
{
|
||||
var4 = this.maxZ - par1AxisAlignedBB.minZ;
|
||||
|
||||
if (var4 > par2)
|
||||
{
|
||||
par2 = var4;
|
||||
}
|
||||
}
|
||||
|
||||
return par2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return par2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return par2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given bounding box intersects with this one. Args: axisAlignedBB
|
||||
*/
|
||||
public boolean intersectsWith(AxisAlignedBB par1AxisAlignedBB)
|
||||
{
|
||||
return par1AxisAlignedBB.maxX > this.minX && par1AxisAlignedBB.minX < this.maxX ? (par1AxisAlignedBB.maxY > this.minY && par1AxisAlignedBB.minY < this.maxY ? par1AxisAlignedBB.maxZ > this.minZ && par1AxisAlignedBB.minZ < this.maxZ : false) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Offsets the current bounding box by the specified coordinates. Args: x, y, z
|
||||
*/
|
||||
public AxisAlignedBB offset(double par1, double par3, double par5)
|
||||
{
|
||||
this.minX += par1;
|
||||
this.minY += par3;
|
||||
this.minZ += par5;
|
||||
this.maxX += par1;
|
||||
this.maxY += par3;
|
||||
this.maxZ += par5;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the supplied Vec3D is completely inside the bounding box
|
||||
*/
|
||||
public boolean isVecInside(Vec3 par1Vec3)
|
||||
{
|
||||
return par1Vec3.xCoord > this.minX && par1Vec3.xCoord < this.maxX ? (par1Vec3.yCoord > this.minY && par1Vec3.yCoord < this.maxY ? par1Vec3.zCoord > this.minZ && par1Vec3.zCoord < this.maxZ : false) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the average length of the edges of the bounding box.
|
||||
*/
|
||||
public double getAverageEdgeLength()
|
||||
{
|
||||
double var1 = this.maxX - this.minX;
|
||||
double var3 = this.maxY - this.minY;
|
||||
double var5 = this.maxZ - this.minZ;
|
||||
return (var1 + var3 + var5) / 3.0D;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bounding box that is inset by the specified amounts
|
||||
*/
|
||||
public AxisAlignedBB contract(double par1, double par3, double par5)
|
||||
{
|
||||
double var7 = this.minX + par1;
|
||||
double var9 = this.minY + par3;
|
||||
double var11 = this.minZ + par5;
|
||||
double var13 = this.maxX - par1;
|
||||
double var15 = this.maxY - par3;
|
||||
double var17 = this.maxZ - par5;
|
||||
return getAABBPool().getAABB(var7, var9, var11, var13, var15, var17);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy of the bounding box.
|
||||
*/
|
||||
public AxisAlignedBB copy()
|
||||
{
|
||||
return getAABBPool().getAABB(this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ);
|
||||
}
|
||||
|
||||
public MovingObjectPosition calculateIntercept(Vec3 par1Vec3, Vec3 par2Vec3)
|
||||
{
|
||||
Vec3 var3 = par1Vec3.getIntermediateWithXValue(par2Vec3, this.minX);
|
||||
Vec3 var4 = par1Vec3.getIntermediateWithXValue(par2Vec3, this.maxX);
|
||||
Vec3 var5 = par1Vec3.getIntermediateWithYValue(par2Vec3, this.minY);
|
||||
Vec3 var6 = par1Vec3.getIntermediateWithYValue(par2Vec3, this.maxY);
|
||||
Vec3 var7 = par1Vec3.getIntermediateWithZValue(par2Vec3, this.minZ);
|
||||
Vec3 var8 = par1Vec3.getIntermediateWithZValue(par2Vec3, this.maxZ);
|
||||
|
||||
if (!this.isVecInYZ(var3))
|
||||
{
|
||||
var3 = null;
|
||||
}
|
||||
|
||||
if (!this.isVecInYZ(var4))
|
||||
{
|
||||
var4 = null;
|
||||
}
|
||||
|
||||
if (!this.isVecInXZ(var5))
|
||||
{
|
||||
var5 = null;
|
||||
}
|
||||
|
||||
if (!this.isVecInXZ(var6))
|
||||
{
|
||||
var6 = null;
|
||||
}
|
||||
|
||||
if (!this.isVecInXY(var7))
|
||||
{
|
||||
var7 = null;
|
||||
}
|
||||
|
||||
if (!this.isVecInXY(var8))
|
||||
{
|
||||
var8 = null;
|
||||
}
|
||||
|
||||
Vec3 var9 = null;
|
||||
|
||||
if (var3 != null && (var9 == null || par1Vec3.squareDistanceTo(var3) < par1Vec3.squareDistanceTo(var9)))
|
||||
{
|
||||
var9 = var3;
|
||||
}
|
||||
|
||||
if (var4 != null && (var9 == null || par1Vec3.squareDistanceTo(var4) < par1Vec3.squareDistanceTo(var9)))
|
||||
{
|
||||
var9 = var4;
|
||||
}
|
||||
|
||||
if (var5 != null && (var9 == null || par1Vec3.squareDistanceTo(var5) < par1Vec3.squareDistanceTo(var9)))
|
||||
{
|
||||
var9 = var5;
|
||||
}
|
||||
|
||||
if (var6 != null && (var9 == null || par1Vec3.squareDistanceTo(var6) < par1Vec3.squareDistanceTo(var9)))
|
||||
{
|
||||
var9 = var6;
|
||||
}
|
||||
|
||||
if (var7 != null && (var9 == null || par1Vec3.squareDistanceTo(var7) < par1Vec3.squareDistanceTo(var9)))
|
||||
{
|
||||
var9 = var7;
|
||||
}
|
||||
|
||||
if (var8 != null && (var9 == null || par1Vec3.squareDistanceTo(var8) < par1Vec3.squareDistanceTo(var9)))
|
||||
{
|
||||
var9 = var8;
|
||||
}
|
||||
|
||||
if (var9 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte var10 = -1;
|
||||
|
||||
if (var9 == var3)
|
||||
{
|
||||
var10 = 4;
|
||||
}
|
||||
|
||||
if (var9 == var4)
|
||||
{
|
||||
var10 = 5;
|
||||
}
|
||||
|
||||
if (var9 == var5)
|
||||
{
|
||||
var10 = 0;
|
||||
}
|
||||
|
||||
if (var9 == var6)
|
||||
{
|
||||
var10 = 1;
|
||||
}
|
||||
|
||||
if (var9 == var7)
|
||||
{
|
||||
var10 = 2;
|
||||
}
|
||||
|
||||
if (var9 == var8)
|
||||
{
|
||||
var10 = 3;
|
||||
}
|
||||
|
||||
return new MovingObjectPosition(0, 0, 0, var10, var9);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified vector is within the YZ dimensions of the bounding box. Args: Vec3D
|
||||
*/
|
||||
private boolean isVecInYZ(Vec3 par1Vec3)
|
||||
{
|
||||
return par1Vec3 == null ? false : par1Vec3.yCoord >= this.minY && par1Vec3.yCoord <= this.maxY && par1Vec3.zCoord >= this.minZ && par1Vec3.zCoord <= this.maxZ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified vector is within the XZ dimensions of the bounding box. Args: Vec3D
|
||||
*/
|
||||
private boolean isVecInXZ(Vec3 par1Vec3)
|
||||
{
|
||||
return par1Vec3 == null ? false : par1Vec3.xCoord >= this.minX && par1Vec3.xCoord <= this.maxX && par1Vec3.zCoord >= this.minZ && par1Vec3.zCoord <= this.maxZ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified vector is within the XY dimensions of the bounding box. Args: Vec3D
|
||||
*/
|
||||
private boolean isVecInXY(Vec3 par1Vec3)
|
||||
{
|
||||
return par1Vec3 == null ? false : par1Vec3.xCoord >= this.minX && par1Vec3.xCoord <= this.maxX && par1Vec3.yCoord >= this.minY && par1Vec3.yCoord <= this.maxY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bounding box to the same bounds as the bounding box passed in. Args: axisAlignedBB
|
||||
*/
|
||||
public void setBB(AxisAlignedBB par1AxisAlignedBB)
|
||||
{
|
||||
this.minX = par1AxisAlignedBB.minX;
|
||||
this.minY = par1AxisAlignedBB.minY;
|
||||
this.minZ = par1AxisAlignedBB.minZ;
|
||||
this.maxX = par1AxisAlignedBB.maxX;
|
||||
this.maxY = par1AxisAlignedBB.maxY;
|
||||
this.maxZ = par1AxisAlignedBB.maxZ;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "box[" + this.minX + ", " + this.minY + ", " + this.minZ + " -> " + this.maxX + ", " + this.maxY + ", " + this.maxZ + "]";
|
||||
}
|
||||
}
|
||||
29
src/main/java/net/minecraft/src/Backup.java
Normal file
29
src/main/java/net/minecraft/src/Backup.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import argo.jdom.JsonNode;
|
||||
import java.util.Date;
|
||||
|
||||
public class Backup extends ValueObject
|
||||
{
|
||||
public String field_110727_a;
|
||||
public Date field_110725_b;
|
||||
public long field_110726_c;
|
||||
|
||||
public static Backup func_110724_a(JsonNode par0JsonNode)
|
||||
{
|
||||
Backup var1 = new Backup();
|
||||
|
||||
try
|
||||
{
|
||||
var1.field_110727_a = par0JsonNode.getStringValue(new Object[] {"backupId"});
|
||||
var1.field_110725_b = new Date(Long.parseLong(par0JsonNode.getNumberValue(new Object[] {"lastModifiedDate"})));
|
||||
var1.field_110726_c = Long.parseLong(par0JsonNode.getNumberValue(new Object[] {"size"}));
|
||||
}
|
||||
catch (IllegalArgumentException var3)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
return var1;
|
||||
}
|
||||
}
|
||||
46
src/main/java/net/minecraft/src/BackupList.java
Normal file
46
src/main/java/net/minecraft/src/BackupList.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import argo.jdom.JdomParser;
|
||||
import argo.jdom.JsonNode;
|
||||
import argo.jdom.JsonRootNode;
|
||||
import argo.saj.InvalidSyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class BackupList
|
||||
{
|
||||
public List field_111223_a;
|
||||
|
||||
public static BackupList func_111222_a(String par0Str)
|
||||
{
|
||||
BackupList var1 = new BackupList();
|
||||
var1.field_111223_a = new ArrayList();
|
||||
|
||||
try
|
||||
{
|
||||
JsonRootNode var2 = (new JdomParser()).parse(par0Str);
|
||||
|
||||
if (var2.isArrayNode(new Object[] {"backups"}))
|
||||
{
|
||||
Iterator var3 = var2.getArrayNode(new Object[] {"backups"}).iterator();
|
||||
|
||||
while (var3.hasNext())
|
||||
{
|
||||
JsonNode var4 = (JsonNode)var3.next();
|
||||
var1.field_111223_a.add(Backup.func_110724_a(var4));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (InvalidSyntaxException var5)
|
||||
{
|
||||
;
|
||||
}
|
||||
catch (IllegalArgumentException var6)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
return var1;
|
||||
}
|
||||
}
|
||||
170
src/main/java/net/minecraft/src/BanEntry.java
Normal file
170
src/main/java/net/minecraft/src/BanEntry.java
Normal file
@@ -0,0 +1,170 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.regex.Pattern;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
public class BanEntry
|
||||
{
|
||||
public static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
|
||||
private final String username;
|
||||
private Date banStartDate = new Date();
|
||||
private String bannedBy = "(Unknown)";
|
||||
private Date banEndDate;
|
||||
private String reason = "Banned by an operator.";
|
||||
|
||||
public BanEntry(String par1Str)
|
||||
{
|
||||
this.username = par1Str;
|
||||
}
|
||||
|
||||
public String getBannedUsername()
|
||||
{
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public Date getBanStartDate()
|
||||
{
|
||||
return this.banStartDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* null == start ban now
|
||||
*/
|
||||
public void setBanStartDate(Date par1Date)
|
||||
{
|
||||
this.banStartDate = par1Date != null ? par1Date : new Date();
|
||||
}
|
||||
|
||||
public String getBannedBy()
|
||||
{
|
||||
return this.bannedBy;
|
||||
}
|
||||
|
||||
public void setBannedBy(String par1Str)
|
||||
{
|
||||
this.bannedBy = par1Str;
|
||||
}
|
||||
|
||||
public Date getBanEndDate()
|
||||
{
|
||||
return this.banEndDate;
|
||||
}
|
||||
|
||||
public void setBanEndDate(Date par1Date)
|
||||
{
|
||||
this.banEndDate = par1Date;
|
||||
}
|
||||
|
||||
public boolean hasBanExpired()
|
||||
{
|
||||
return this.banEndDate == null ? false : this.banEndDate.before(new Date());
|
||||
}
|
||||
|
||||
public String getBanReason()
|
||||
{
|
||||
return this.reason;
|
||||
}
|
||||
|
||||
public void setBanReason(String par1Str)
|
||||
{
|
||||
this.reason = par1Str;
|
||||
}
|
||||
|
||||
public String buildBanString()
|
||||
{
|
||||
StringBuilder var1 = new StringBuilder();
|
||||
var1.append(this.getBannedUsername());
|
||||
var1.append("|");
|
||||
var1.append(dateFormat.format(this.getBanStartDate()));
|
||||
var1.append("|");
|
||||
var1.append(this.getBannedBy());
|
||||
var1.append("|");
|
||||
var1.append(this.getBanEndDate() == null ? "Forever" : dateFormat.format(this.getBanEndDate()));
|
||||
var1.append("|");
|
||||
var1.append(this.getBanReason());
|
||||
return var1.toString();
|
||||
}
|
||||
|
||||
public static BanEntry parse(String par0Str)
|
||||
{
|
||||
if (par0Str.trim().length() < 2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
String[] var1 = par0Str.trim().split(Pattern.quote("|"), 5);
|
||||
BanEntry var2 = new BanEntry(var1[0].trim());
|
||||
byte var3 = 0;
|
||||
int var10000 = var1.length;
|
||||
int var7 = var3 + 1;
|
||||
|
||||
if (var10000 <= var7)
|
||||
{
|
||||
return var2;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
var2.setBanStartDate(dateFormat.parse(var1[var7].trim()));
|
||||
}
|
||||
catch (ParseException var6)
|
||||
{
|
||||
MinecraftServer.getServer().getLogAgent().logWarningException("Could not read creation date format for ban entry \'" + var2.getBannedUsername() + "\' (was: \'" + var1[var7] + "\')", var6);
|
||||
}
|
||||
|
||||
var10000 = var1.length;
|
||||
++var7;
|
||||
|
||||
if (var10000 <= var7)
|
||||
{
|
||||
return var2;
|
||||
}
|
||||
else
|
||||
{
|
||||
var2.setBannedBy(var1[var7].trim());
|
||||
var10000 = var1.length;
|
||||
++var7;
|
||||
|
||||
if (var10000 <= var7)
|
||||
{
|
||||
return var2;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
String var4 = var1[var7].trim();
|
||||
|
||||
if (!var4.equalsIgnoreCase("Forever") && var4.length() > 0)
|
||||
{
|
||||
var2.setBanEndDate(dateFormat.parse(var4));
|
||||
}
|
||||
}
|
||||
catch (ParseException var5)
|
||||
{
|
||||
MinecraftServer.getServer().getLogAgent().logWarningException("Could not read expiry date format for ban entry \'" + var2.getBannedUsername() + "\' (was: \'" + var1[var7] + "\')", var5);
|
||||
}
|
||||
|
||||
var10000 = var1.length;
|
||||
++var7;
|
||||
|
||||
if (var10000 <= var7)
|
||||
{
|
||||
return var2;
|
||||
}
|
||||
else
|
||||
{
|
||||
var2.setBanReason(var1[var7].trim());
|
||||
return var2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
168
src/main/java/net/minecraft/src/BanList.java
Normal file
168
src/main/java/net/minecraft/src/BanList.java
Normal file
@@ -0,0 +1,168 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
public class BanList
|
||||
{
|
||||
private final LowerStringMap theBanList = new LowerStringMap();
|
||||
private final File fileName;
|
||||
|
||||
/** set to true if not singlePlayer */
|
||||
private boolean listActive = true;
|
||||
|
||||
public BanList(File par1File)
|
||||
{
|
||||
this.fileName = par1File;
|
||||
}
|
||||
|
||||
public boolean isListActive()
|
||||
{
|
||||
return this.listActive;
|
||||
}
|
||||
|
||||
public void setListActive(boolean par1)
|
||||
{
|
||||
this.listActive = par1;
|
||||
}
|
||||
|
||||
/**
|
||||
* removes expired Bans before returning
|
||||
*/
|
||||
public Map getBannedList()
|
||||
{
|
||||
this.removeExpiredBans();
|
||||
return this.theBanList;
|
||||
}
|
||||
|
||||
public boolean isBanned(String par1Str)
|
||||
{
|
||||
if (!this.isListActive())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.removeExpiredBans();
|
||||
return this.theBanList.containsKey(par1Str);
|
||||
}
|
||||
}
|
||||
|
||||
public void put(BanEntry par1BanEntry)
|
||||
{
|
||||
this.theBanList.putLower(par1BanEntry.getBannedUsername(), par1BanEntry);
|
||||
this.saveToFileWithHeader();
|
||||
}
|
||||
|
||||
public void remove(String par1Str)
|
||||
{
|
||||
this.theBanList.remove(par1Str);
|
||||
this.saveToFileWithHeader();
|
||||
}
|
||||
|
||||
public void removeExpiredBans()
|
||||
{
|
||||
Iterator var1 = this.theBanList.values().iterator();
|
||||
|
||||
while (var1.hasNext())
|
||||
{
|
||||
BanEntry var2 = (BanEntry)var1.next();
|
||||
|
||||
if (var2.hasBanExpired())
|
||||
{
|
||||
var1.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the ban list from the file (adds every entry, does not clear the current list).
|
||||
*/
|
||||
public void loadBanList()
|
||||
{
|
||||
if (this.fileName.isFile())
|
||||
{
|
||||
BufferedReader var1;
|
||||
|
||||
try
|
||||
{
|
||||
var1 = new BufferedReader(new FileReader(this.fileName));
|
||||
}
|
||||
catch (FileNotFoundException var4)
|
||||
{
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
String var2;
|
||||
|
||||
try
|
||||
{
|
||||
while ((var2 = var1.readLine()) != null)
|
||||
{
|
||||
if (!var2.startsWith("#"))
|
||||
{
|
||||
BanEntry var3 = BanEntry.parse(var2);
|
||||
|
||||
if (var3 != null)
|
||||
{
|
||||
this.theBanList.putLower(var3.getBannedUsername(), var3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException var5)
|
||||
{
|
||||
MinecraftServer.getServer().getLogAgent().logSevereException("Could not load ban list", var5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void saveToFileWithHeader()
|
||||
{
|
||||
this.saveToFile(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* par1: include header
|
||||
*/
|
||||
public void saveToFile(boolean par1)
|
||||
{
|
||||
this.removeExpiredBans();
|
||||
|
||||
try
|
||||
{
|
||||
PrintWriter var2 = new PrintWriter(new FileWriter(this.fileName, false));
|
||||
|
||||
if (par1)
|
||||
{
|
||||
var2.println("# Updated " + (new SimpleDateFormat()).format(new Date()) + " by Minecraft " + "1.6.4");
|
||||
var2.println("# victim name | ban date | banned by | banned until | reason");
|
||||
var2.println();
|
||||
}
|
||||
|
||||
Iterator var3 = this.theBanList.values().iterator();
|
||||
|
||||
while (var3.hasNext())
|
||||
{
|
||||
BanEntry var4 = (BanEntry)var3.next();
|
||||
var2.println(var4.buildBanString());
|
||||
}
|
||||
|
||||
var2.close();
|
||||
}
|
||||
catch (IOException var5)
|
||||
{
|
||||
MinecraftServer.getServer().getLogAgent().logSevereException("Could not save ban list", var5);
|
||||
}
|
||||
}
|
||||
}
|
||||
45
src/main/java/net/minecraft/src/BaseAttribute.java
Normal file
45
src/main/java/net/minecraft/src/BaseAttribute.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public abstract class BaseAttribute implements Attribute
|
||||
{
|
||||
private final String field_111115_a;
|
||||
private final double defaultValue;
|
||||
private boolean shouldWatch;
|
||||
|
||||
protected BaseAttribute(String par1Str, double par2)
|
||||
{
|
||||
this.field_111115_a = par1Str;
|
||||
this.defaultValue = par2;
|
||||
|
||||
if (par1Str == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Name cannot be null!");
|
||||
}
|
||||
}
|
||||
|
||||
public String getAttributeUnlocalizedName()
|
||||
{
|
||||
return this.field_111115_a;
|
||||
}
|
||||
|
||||
public double getDefaultValue()
|
||||
{
|
||||
return this.defaultValue;
|
||||
}
|
||||
|
||||
public boolean getShouldWatch()
|
||||
{
|
||||
return this.shouldWatch;
|
||||
}
|
||||
|
||||
public BaseAttribute setShouldWatch(boolean par1)
|
||||
{
|
||||
this.shouldWatch = par1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return this.field_111115_a.hashCode();
|
||||
}
|
||||
}
|
||||
66
src/main/java/net/minecraft/src/BaseAttributeMap.java
Normal file
66
src/main/java/net/minecraft/src/BaseAttributeMap.java
Normal file
@@ -0,0 +1,66 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public abstract class BaseAttributeMap
|
||||
{
|
||||
protected final Map attributes = new HashMap();
|
||||
protected final Map attributesByName = new LowerStringMap();
|
||||
|
||||
public AttributeInstance getAttributeInstance(Attribute par1Attribute)
|
||||
{
|
||||
return (AttributeInstance)this.attributes.get(par1Attribute);
|
||||
}
|
||||
|
||||
public AttributeInstance getAttributeInstanceByName(String par1Str)
|
||||
{
|
||||
return (AttributeInstance)this.attributesByName.get(par1Str);
|
||||
}
|
||||
|
||||
public abstract AttributeInstance func_111150_b(Attribute var1);
|
||||
|
||||
public Collection getAllAttributes()
|
||||
{
|
||||
return this.attributesByName.values();
|
||||
}
|
||||
|
||||
public void func_111149_a(ModifiableAttributeInstance par1ModifiableAttributeInstance) {}
|
||||
|
||||
public void removeAttributeModifiers(Multimap par1Multimap)
|
||||
{
|
||||
Iterator var2 = par1Multimap.entries().iterator();
|
||||
|
||||
while (var2.hasNext())
|
||||
{
|
||||
Entry var3 = (Entry)var2.next();
|
||||
AttributeInstance var4 = this.getAttributeInstanceByName((String)var3.getKey());
|
||||
|
||||
if (var4 != null)
|
||||
{
|
||||
var4.removeModifier((AttributeModifier)var3.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void applyAttributeModifiers(Multimap par1Multimap)
|
||||
{
|
||||
Iterator var2 = par1Multimap.entries().iterator();
|
||||
|
||||
while (var2.hasNext())
|
||||
{
|
||||
Entry var3 = (Entry)var2.next();
|
||||
AttributeInstance var4 = this.getAttributeInstanceByName((String)var3.getKey());
|
||||
|
||||
if (var4 != null)
|
||||
{
|
||||
var4.removeModifier((AttributeModifier)var3.getValue());
|
||||
var4.applyModifier((AttributeModifier)var3.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
|
||||
public abstract class BaseMetadataSectionSerializer implements MetadataSectionSerializer
|
||||
{
|
||||
protected float func_110487_a(JsonElement par1JsonElement, String par2Str, Float par3, float par4, float par5)
|
||||
{
|
||||
par2Str = this.getSectionName() + "->" + par2Str;
|
||||
|
||||
if (par1JsonElement == null)
|
||||
{
|
||||
if (par3 == null)
|
||||
{
|
||||
throw new JsonParseException("Missing " + par2Str + ": expected float");
|
||||
}
|
||||
else
|
||||
{
|
||||
return par3.floatValue();
|
||||
}
|
||||
}
|
||||
else if (!par1JsonElement.isJsonPrimitive())
|
||||
{
|
||||
throw new JsonParseException("Invalid " + par2Str + ": expected float, was " + par1JsonElement);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
float var6 = par1JsonElement.getAsFloat();
|
||||
|
||||
if (var6 < par4)
|
||||
{
|
||||
throw new JsonParseException("Invalid " + par2Str + ": expected float >= " + par4 + ", was " + var6);
|
||||
}
|
||||
else if (var6 > par5)
|
||||
{
|
||||
throw new JsonParseException("Invalid " + par2Str + ": expected float <= " + par5 + ", was " + var6);
|
||||
}
|
||||
else
|
||||
{
|
||||
return var6;
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException var7)
|
||||
{
|
||||
throw new JsonParseException("Invalid " + par2Str + ": expected float, was " + par1JsonElement, var7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected int func_110485_a(JsonElement par1JsonElement, String par2Str, Integer par3, int par4, int par5)
|
||||
{
|
||||
par2Str = this.getSectionName() + "->" + par2Str;
|
||||
|
||||
if (par1JsonElement == null)
|
||||
{
|
||||
if (par3 == null)
|
||||
{
|
||||
throw new JsonParseException("Missing " + par2Str + ": expected int");
|
||||
}
|
||||
else
|
||||
{
|
||||
return par3.intValue();
|
||||
}
|
||||
}
|
||||
else if (!par1JsonElement.isJsonPrimitive())
|
||||
{
|
||||
throw new JsonParseException("Invalid " + par2Str + ": expected int, was " + par1JsonElement);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
int var6 = par1JsonElement.getAsInt();
|
||||
|
||||
if (var6 < par4)
|
||||
{
|
||||
throw new JsonParseException("Invalid " + par2Str + ": expected int >= " + par4 + ", was " + var6);
|
||||
}
|
||||
else if (var6 > par5)
|
||||
{
|
||||
throw new JsonParseException("Invalid " + par2Str + ": expected int <= " + par5 + ", was " + var6);
|
||||
}
|
||||
else
|
||||
{
|
||||
return var6;
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException var7)
|
||||
{
|
||||
throw new JsonParseException("Invalid " + par2Str + ": expected int, was " + par1JsonElement, var7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String func_110486_a(JsonElement par1JsonElement, String par2Str, String par3Str, int par4, int par5)
|
||||
{
|
||||
par2Str = this.getSectionName() + "->" + par2Str;
|
||||
|
||||
if (par1JsonElement == null)
|
||||
{
|
||||
if (par3Str == null)
|
||||
{
|
||||
throw new JsonParseException("Missing " + par2Str + ": expected string");
|
||||
}
|
||||
else
|
||||
{
|
||||
return par3Str;
|
||||
}
|
||||
}
|
||||
else if (!par1JsonElement.isJsonPrimitive())
|
||||
{
|
||||
throw new JsonParseException("Invalid " + par2Str + ": expected string, was " + par1JsonElement);
|
||||
}
|
||||
else
|
||||
{
|
||||
String var6 = par1JsonElement.getAsString();
|
||||
|
||||
if (var6.length() < par4)
|
||||
{
|
||||
throw new JsonParseException("Invalid " + par2Str + ": expected string length >= " + par4 + ", was " + var6);
|
||||
}
|
||||
else if (var6.length() > par5)
|
||||
{
|
||||
throw new JsonParseException("Invalid " + par2Str + ": expected string length <= " + par5 + ", was " + var6);
|
||||
}
|
||||
else
|
||||
{
|
||||
return var6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean func_110484_a(JsonElement par1JsonElement, String par2Str, Boolean par3)
|
||||
{
|
||||
par2Str = this.getSectionName() + "->" + par2Str;
|
||||
|
||||
if (par1JsonElement == null)
|
||||
{
|
||||
if (par3 == null)
|
||||
{
|
||||
throw new JsonParseException("Missing " + par2Str + ": expected boolean");
|
||||
}
|
||||
else
|
||||
{
|
||||
return par3.booleanValue();
|
||||
}
|
||||
}
|
||||
else if (!par1JsonElement.isJsonPrimitive())
|
||||
{
|
||||
throw new JsonParseException("Invalid " + par2Str + ": expected boolean, was " + par1JsonElement);
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean var4 = par1JsonElement.getAsBoolean();
|
||||
return var4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class BehaviorDefaultDispenseItem implements IBehaviorDispenseItem
|
||||
{
|
||||
/**
|
||||
* Dispenses the specified ItemStack from a dispenser.
|
||||
*/
|
||||
public final ItemStack dispense(IBlockSource par1IBlockSource, ItemStack par2ItemStack)
|
||||
{
|
||||
ItemStack var3 = this.dispenseStack(par1IBlockSource, par2ItemStack);
|
||||
this.playDispenseSound(par1IBlockSource);
|
||||
this.spawnDispenseParticles(par1IBlockSource, BlockDispenser.getFacing(par1IBlockSource.getBlockMetadata()));
|
||||
return var3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispense the specified stack, play the dispense sound and spawn particles.
|
||||
*/
|
||||
protected ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack)
|
||||
{
|
||||
EnumFacing var3 = BlockDispenser.getFacing(par1IBlockSource.getBlockMetadata());
|
||||
IPosition var4 = BlockDispenser.getIPositionFromBlockSource(par1IBlockSource);
|
||||
ItemStack var5 = par2ItemStack.splitStack(1);
|
||||
doDispense(par1IBlockSource.getWorld(), var5, 6, var3, var4);
|
||||
return par2ItemStack;
|
||||
}
|
||||
|
||||
public static void doDispense(World par0World, ItemStack par1ItemStack, int par2, EnumFacing par3EnumFacing, IPosition par4IPosition)
|
||||
{
|
||||
double var5 = par4IPosition.getX();
|
||||
double var7 = par4IPosition.getY();
|
||||
double var9 = par4IPosition.getZ();
|
||||
EntityItem var11 = new EntityItem(par0World, var5, var7 - 0.3D, var9, par1ItemStack);
|
||||
double var12 = par0World.rand.nextDouble() * 0.1D + 0.2D;
|
||||
var11.motionX = (double)par3EnumFacing.getFrontOffsetX() * var12;
|
||||
var11.motionY = 0.20000000298023224D;
|
||||
var11.motionZ = (double)par3EnumFacing.getFrontOffsetZ() * var12;
|
||||
var11.motionX += par0World.rand.nextGaussian() * 0.007499999832361937D * (double)par2;
|
||||
var11.motionY += par0World.rand.nextGaussian() * 0.007499999832361937D * (double)par2;
|
||||
var11.motionZ += par0World.rand.nextGaussian() * 0.007499999832361937D * (double)par2;
|
||||
par0World.spawnEntityInWorld(var11);
|
||||
}
|
||||
|
||||
/**
|
||||
* Play the dispense sound from the specified block.
|
||||
*/
|
||||
protected void playDispenseSound(IBlockSource par1IBlockSource)
|
||||
{
|
||||
par1IBlockSource.getWorld().playAuxSFX(1000, par1IBlockSource.getXInt(), par1IBlockSource.getYInt(), par1IBlockSource.getZInt(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Order clients to display dispense particles from the specified block and facing.
|
||||
*/
|
||||
protected void spawnDispenseParticles(IBlockSource par1IBlockSource, EnumFacing par2EnumFacing)
|
||||
{
|
||||
par1IBlockSource.getWorld().playAuxSFX(2000, par1IBlockSource.getXInt(), par1IBlockSource.getYInt(), par1IBlockSource.getZInt(), this.func_82488_a(par2EnumFacing));
|
||||
}
|
||||
|
||||
private int func_82488_a(EnumFacing par1EnumFacing)
|
||||
{
|
||||
return par1EnumFacing.getFrontOffsetX() + 1 + (par1EnumFacing.getFrontOffsetZ() + 1) * 3;
|
||||
}
|
||||
}
|
||||
41
src/main/java/net/minecraft/src/BehaviorDispenseArmor.java
Normal file
41
src/main/java/net/minecraft/src/BehaviorDispenseArmor.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
final class BehaviorDispenseArmor extends BehaviorDefaultDispenseItem
|
||||
{
|
||||
/**
|
||||
* Dispense the specified stack, play the dispense sound and spawn particles.
|
||||
*/
|
||||
protected ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack)
|
||||
{
|
||||
EnumFacing var3 = BlockDispenser.getFacing(par1IBlockSource.getBlockMetadata());
|
||||
int var4 = par1IBlockSource.getXInt() + var3.getFrontOffsetX();
|
||||
int var5 = par1IBlockSource.getYInt() + var3.getFrontOffsetY();
|
||||
int var6 = par1IBlockSource.getZInt() + var3.getFrontOffsetZ();
|
||||
AxisAlignedBB var7 = AxisAlignedBB.getAABBPool().getAABB((double)var4, (double)var5, (double)var6, (double)(var4 + 1), (double)(var5 + 1), (double)(var6 + 1));
|
||||
List var8 = par1IBlockSource.getWorld().selectEntitiesWithinAABB(EntityLivingBase.class, var7, new EntitySelectorArmoredMob(par2ItemStack));
|
||||
|
||||
if (var8.size() > 0)
|
||||
{
|
||||
EntityLivingBase var9 = (EntityLivingBase)var8.get(0);
|
||||
int var10 = var9 instanceof EntityPlayer ? 1 : 0;
|
||||
int var11 = EntityLiving.getArmorPosition(par2ItemStack);
|
||||
ItemStack var12 = par2ItemStack.copy();
|
||||
var12.stackSize = 1;
|
||||
var9.setCurrentItemOrArmor(var11 - var10, var12);
|
||||
|
||||
if (var9 instanceof EntityLiving)
|
||||
{
|
||||
((EntityLiving)var9).setEquipmentDropChance(var11, 2.0F);
|
||||
}
|
||||
|
||||
--par2ItemStack.stackSize;
|
||||
return par2ItemStack;
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.dispenseStack(par1IBlockSource, par2ItemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
final class BehaviorDispenseItemProvider implements IBehaviorDispenseItem
|
||||
{
|
||||
/**
|
||||
* Dispenses the specified ItemStack from a dispenser.
|
||||
*/
|
||||
public ItemStack dispense(IBlockSource par1IBlockSource, ItemStack par2ItemStack)
|
||||
{
|
||||
return par2ItemStack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
final class BehaviorDispenseMinecart extends BehaviorDefaultDispenseItem
|
||||
{
|
||||
private final BehaviorDefaultDispenseItem behaviourDefaultDispenseItem = new BehaviorDefaultDispenseItem();
|
||||
|
||||
/**
|
||||
* Dispense the specified stack, play the dispense sound and spawn particles.
|
||||
*/
|
||||
public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack)
|
||||
{
|
||||
EnumFacing var3 = BlockDispenser.getFacing(par1IBlockSource.getBlockMetadata());
|
||||
World var4 = par1IBlockSource.getWorld();
|
||||
double var5 = par1IBlockSource.getX() + (double)((float)var3.getFrontOffsetX() * 1.125F);
|
||||
double var7 = par1IBlockSource.getY() + (double)((float)var3.getFrontOffsetY() * 1.125F);
|
||||
double var9 = par1IBlockSource.getZ() + (double)((float)var3.getFrontOffsetZ() * 1.125F);
|
||||
int var11 = par1IBlockSource.getXInt() + var3.getFrontOffsetX();
|
||||
int var12 = par1IBlockSource.getYInt() + var3.getFrontOffsetY();
|
||||
int var13 = par1IBlockSource.getZInt() + var3.getFrontOffsetZ();
|
||||
int var14 = var4.getBlockId(var11, var12, var13);
|
||||
double var15;
|
||||
|
||||
if (BlockRailBase.isRailBlock(var14))
|
||||
{
|
||||
var15 = 0.0D;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (var14 != 0 || !BlockRailBase.isRailBlock(var4.getBlockId(var11, var12 - 1, var13)))
|
||||
{
|
||||
return this.behaviourDefaultDispenseItem.dispense(par1IBlockSource, par2ItemStack);
|
||||
}
|
||||
|
||||
var15 = -1.0D;
|
||||
}
|
||||
|
||||
EntityMinecart var17 = EntityMinecart.createMinecart(var4, var5, var7 + var15, var9, ((ItemMinecart)par2ItemStack.getItem()).minecartType);
|
||||
|
||||
if (par2ItemStack.hasDisplayName())
|
||||
{
|
||||
var17.setMinecartName(par2ItemStack.getDisplayName());
|
||||
}
|
||||
|
||||
var4.spawnEntityInWorld(var17);
|
||||
par2ItemStack.splitStack(1);
|
||||
return par2ItemStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Play the dispense sound from the specified block.
|
||||
*/
|
||||
protected void playDispenseSound(IBlockSource par1IBlockSource)
|
||||
{
|
||||
par1IBlockSource.getWorld().playAuxSFX(1000, par1IBlockSource.getXInt(), par1IBlockSource.getYInt(), par1IBlockSource.getZInt(), 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public abstract class BehaviorProjectileDispense extends BehaviorDefaultDispenseItem
|
||||
{
|
||||
/**
|
||||
* Dispense the specified stack, play the dispense sound and spawn particles.
|
||||
*/
|
||||
public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack)
|
||||
{
|
||||
World var3 = par1IBlockSource.getWorld();
|
||||
IPosition var4 = BlockDispenser.getIPositionFromBlockSource(par1IBlockSource);
|
||||
EnumFacing var5 = BlockDispenser.getFacing(par1IBlockSource.getBlockMetadata());
|
||||
IProjectile var6 = this.getProjectileEntity(var3, var4);
|
||||
var6.setThrowableHeading((double)var5.getFrontOffsetX(), (double)((float)var5.getFrontOffsetY() + 0.1F), (double)var5.getFrontOffsetZ(), this.func_82500_b(), this.func_82498_a());
|
||||
var3.spawnEntityInWorld((Entity)var6);
|
||||
par2ItemStack.splitStack(1);
|
||||
return par2ItemStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Play the dispense sound from the specified block.
|
||||
*/
|
||||
protected void playDispenseSound(IBlockSource par1IBlockSource)
|
||||
{
|
||||
par1IBlockSource.getWorld().playAuxSFX(1002, par1IBlockSource.getXInt(), par1IBlockSource.getYInt(), par1IBlockSource.getZInt(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the projectile entity spawned by this dispense behavior.
|
||||
*/
|
||||
protected abstract IProjectile getProjectileEntity(World var1, IPosition var2);
|
||||
|
||||
protected float func_82498_a()
|
||||
{
|
||||
return 6.0F;
|
||||
}
|
||||
|
||||
protected float func_82500_b()
|
||||
{
|
||||
return 1.1F;
|
||||
}
|
||||
}
|
||||
99
src/main/java/net/minecraft/src/BiomeCache.java
Normal file
99
src/main/java/net/minecraft/src/BiomeCache.java
Normal file
@@ -0,0 +1,99 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
public class BiomeCache
|
||||
{
|
||||
/** Reference to the WorldChunkManager */
|
||||
private final WorldChunkManager chunkManager;
|
||||
|
||||
/** The last time this BiomeCache was cleaned, in milliseconds. */
|
||||
private long lastCleanupTime;
|
||||
|
||||
/**
|
||||
* The map of keys to BiomeCacheBlocks. Keys are based on the chunk x, z coordinates as (x | z << 32).
|
||||
*/
|
||||
private LongHashMap cacheMap = new LongHashMap();
|
||||
|
||||
/** The list of cached BiomeCacheBlocks */
|
||||
private List cache = new ArrayList();
|
||||
|
||||
public BiomeCache(WorldChunkManager par1WorldChunkManager)
|
||||
{
|
||||
this.chunkManager = par1WorldChunkManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a biome cache block at location specified.
|
||||
*/
|
||||
public BiomeCacheBlock getBiomeCacheBlock(int par1, int par2)
|
||||
{
|
||||
par1 >>= 4;
|
||||
par2 >>= 4;
|
||||
long var3 = (long)par1 & 4294967295L | ((long)par2 & 4294967295L) << 32;
|
||||
BiomeCacheBlock var5 = (BiomeCacheBlock)this.cacheMap.getValueByKey(var3);
|
||||
|
||||
if (var5 == null)
|
||||
{
|
||||
var5 = new BiomeCacheBlock(this, par1, par2);
|
||||
this.cacheMap.add(var3, var5);
|
||||
this.cache.add(var5);
|
||||
}
|
||||
|
||||
var5.lastAccessTime = MinecraftServer.getSystemTimeMillis();
|
||||
return var5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the BiomeGenBase related to the x, z position from the cache.
|
||||
*/
|
||||
public BiomeGenBase getBiomeGenAt(int par1, int par2)
|
||||
{
|
||||
return this.getBiomeCacheBlock(par1, par2).getBiomeGenAt(par1, par2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes BiomeCacheBlocks from this cache that haven't been accessed in at least 30 seconds.
|
||||
*/
|
||||
public void cleanupCache()
|
||||
{
|
||||
long var1 = MinecraftServer.getSystemTimeMillis();
|
||||
long var3 = var1 - this.lastCleanupTime;
|
||||
|
||||
if (var3 > 7500L || var3 < 0L)
|
||||
{
|
||||
this.lastCleanupTime = var1;
|
||||
|
||||
for (int var5 = 0; var5 < this.cache.size(); ++var5)
|
||||
{
|
||||
BiomeCacheBlock var6 = (BiomeCacheBlock)this.cache.get(var5);
|
||||
long var7 = var1 - var6.lastAccessTime;
|
||||
|
||||
if (var7 > 30000L || var7 < 0L)
|
||||
{
|
||||
this.cache.remove(var5--);
|
||||
long var9 = (long)var6.xPosition & 4294967295L | ((long)var6.zPosition & 4294967295L) << 32;
|
||||
this.cacheMap.remove(var9);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the array of cached biome types in the BiomeCacheBlock at the given location.
|
||||
*/
|
||||
public BiomeGenBase[] getCachedBiomes(int par1, int par2)
|
||||
{
|
||||
return this.getBiomeCacheBlock(par1, par2).biomes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the world chunk manager object for a biome list.
|
||||
*/
|
||||
static WorldChunkManager getChunkManager(BiomeCache par0BiomeCache)
|
||||
{
|
||||
return par0BiomeCache.chunkManager;
|
||||
}
|
||||
}
|
||||
46
src/main/java/net/minecraft/src/BiomeCacheBlock.java
Normal file
46
src/main/java/net/minecraft/src/BiomeCacheBlock.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class BiomeCacheBlock
|
||||
{
|
||||
/** An array of chunk temperatures saved by this cache. */
|
||||
public float[] temperatureValues;
|
||||
|
||||
/** An array of chunk rainfall values saved by this cache. */
|
||||
public float[] rainfallValues;
|
||||
|
||||
/** The array of biome types stored in this BiomeCacheBlock. */
|
||||
public BiomeGenBase[] biomes;
|
||||
|
||||
/** The x coordinate of the BiomeCacheBlock. */
|
||||
public int xPosition;
|
||||
|
||||
/** The z coordinate of the BiomeCacheBlock. */
|
||||
public int zPosition;
|
||||
|
||||
/** The last time this BiomeCacheBlock was accessed, in milliseconds. */
|
||||
public long lastAccessTime;
|
||||
|
||||
/** The BiomeCache object that contains this BiomeCacheBlock */
|
||||
final BiomeCache theBiomeCache;
|
||||
|
||||
public BiomeCacheBlock(BiomeCache par1BiomeCache, int par2, int par3)
|
||||
{
|
||||
this.theBiomeCache = par1BiomeCache;
|
||||
this.temperatureValues = new float[256];
|
||||
this.rainfallValues = new float[256];
|
||||
this.biomes = new BiomeGenBase[256];
|
||||
this.xPosition = par2;
|
||||
this.zPosition = par3;
|
||||
BiomeCache.getChunkManager(par1BiomeCache).getTemperatures(this.temperatureValues, par2 << 4, par3 << 4, 16, 16);
|
||||
BiomeCache.getChunkManager(par1BiomeCache).getRainfall(this.rainfallValues, par2 << 4, par3 << 4, 16, 16);
|
||||
BiomeCache.getChunkManager(par1BiomeCache).getBiomeGenAt(this.biomes, par2 << 4, par3 << 4, 16, 16, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the BiomeGenBase related to the x, z position from the cache block.
|
||||
*/
|
||||
public BiomeGenBase getBiomeGenAt(int par1, int par2)
|
||||
{
|
||||
return this.biomes[par1 & 15 | (par2 & 15) << 4];
|
||||
}
|
||||
}
|
||||
416
src/main/java/net/minecraft/src/BiomeDecorator.java
Normal file
416
src/main/java/net/minecraft/src/BiomeDecorator.java
Normal file
@@ -0,0 +1,416 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BiomeDecorator
|
||||
{
|
||||
/** The world the BiomeDecorator is currently decorating */
|
||||
protected World currentWorld;
|
||||
|
||||
/** The Biome Decorator's random number generator. */
|
||||
protected Random randomGenerator;
|
||||
|
||||
/** The X-coordinate of the chunk currently being decorated */
|
||||
protected int chunk_X;
|
||||
|
||||
/** The Z-coordinate of the chunk currently being decorated */
|
||||
protected int chunk_Z;
|
||||
|
||||
/** The biome generator object. */
|
||||
protected BiomeGenBase biome;
|
||||
|
||||
/** The clay generator. */
|
||||
protected WorldGenerator clayGen = new WorldGenClay(4);
|
||||
|
||||
/** The sand generator. */
|
||||
protected WorldGenerator sandGen;
|
||||
|
||||
/** The gravel generator. */
|
||||
protected WorldGenerator gravelAsSandGen;
|
||||
|
||||
/** The dirt generator. */
|
||||
protected WorldGenerator dirtGen;
|
||||
protected WorldGenerator gravelGen;
|
||||
protected WorldGenerator coalGen;
|
||||
protected WorldGenerator ironGen;
|
||||
|
||||
/** Field that holds gold WorldGenMinable */
|
||||
protected WorldGenerator goldGen;
|
||||
|
||||
/** Field that holds redstone WorldGenMinable */
|
||||
protected WorldGenerator redstoneGen;
|
||||
|
||||
/** Field that holds diamond WorldGenMinable */
|
||||
protected WorldGenerator diamondGen;
|
||||
|
||||
/** Field that holds Lapis WorldGenMinable */
|
||||
protected WorldGenerator lapisGen;
|
||||
|
||||
/** Field that holds one of the plantYellow WorldGenFlowers */
|
||||
protected WorldGenerator plantYellowGen;
|
||||
|
||||
/** Field that holds one of the plantRed WorldGenFlowers */
|
||||
protected WorldGenerator plantRedGen;
|
||||
|
||||
/** Field that holds mushroomBrown WorldGenFlowers */
|
||||
protected WorldGenerator mushroomBrownGen;
|
||||
|
||||
/** Field that holds mushroomRed WorldGenFlowers */
|
||||
protected WorldGenerator mushroomRedGen;
|
||||
|
||||
/** Field that holds big mushroom generator */
|
||||
protected WorldGenerator bigMushroomGen;
|
||||
|
||||
/** Field that holds WorldGenReed */
|
||||
protected WorldGenerator reedGen;
|
||||
|
||||
/** Field that holds WorldGenCactus */
|
||||
protected WorldGenerator cactusGen;
|
||||
|
||||
/** The water lily generation! */
|
||||
protected WorldGenerator waterlilyGen;
|
||||
|
||||
/** Amount of waterlilys per chunk. */
|
||||
protected int waterlilyPerChunk;
|
||||
|
||||
/**
|
||||
* The number of trees to attempt to generate per chunk. Up to 10 in forests, none in deserts.
|
||||
*/
|
||||
protected int treesPerChunk;
|
||||
|
||||
/**
|
||||
* The number of yellow flower patches to generate per chunk. The game generates much less than this number, since
|
||||
* it attempts to generate them at a random altitude.
|
||||
*/
|
||||
protected int flowersPerChunk;
|
||||
|
||||
/** The amount of tall grass to generate per chunk. */
|
||||
protected int grassPerChunk;
|
||||
|
||||
/**
|
||||
* The number of dead bushes to generate per chunk. Used in deserts and swamps.
|
||||
*/
|
||||
protected int deadBushPerChunk;
|
||||
|
||||
/**
|
||||
* The number of extra mushroom patches per chunk. It generates 1/4 this number in brown mushroom patches, and 1/8
|
||||
* this number in red mushroom patches. These mushrooms go beyond the default base number of mushrooms.
|
||||
*/
|
||||
protected int mushroomsPerChunk;
|
||||
|
||||
/**
|
||||
* The number of reeds to generate per chunk. Reeds won't generate if the randomly selected placement is unsuitable.
|
||||
*/
|
||||
protected int reedsPerChunk;
|
||||
|
||||
/**
|
||||
* The number of cactus plants to generate per chunk. Cacti only work on sand.
|
||||
*/
|
||||
protected int cactiPerChunk;
|
||||
|
||||
/**
|
||||
* The number of sand patches to generate per chunk. Sand patches only generate when part of it is underwater.
|
||||
*/
|
||||
protected int sandPerChunk;
|
||||
|
||||
/**
|
||||
* The number of sand patches to generate per chunk. Sand patches only generate when part of it is underwater. There
|
||||
* appear to be two separate fields for this.
|
||||
*/
|
||||
protected int sandPerChunk2;
|
||||
|
||||
/**
|
||||
* The number of clay patches to generate per chunk. Only generates when part of it is underwater.
|
||||
*/
|
||||
protected int clayPerChunk;
|
||||
|
||||
/** Amount of big mushrooms per chunk */
|
||||
protected int bigMushroomsPerChunk;
|
||||
|
||||
/** True if decorator should generate surface lava & water */
|
||||
public boolean generateLakes;
|
||||
|
||||
public BiomeDecorator(BiomeGenBase par1BiomeGenBase)
|
||||
{
|
||||
this.sandGen = new WorldGenSand(7, Block.sand.blockID);
|
||||
this.gravelAsSandGen = new WorldGenSand(6, Block.gravel.blockID);
|
||||
this.dirtGen = new WorldGenMinable(Block.dirt.blockID, 32);
|
||||
this.gravelGen = new WorldGenMinable(Block.gravel.blockID, 32);
|
||||
this.coalGen = new WorldGenMinable(Block.oreCoal.blockID, 16);
|
||||
this.ironGen = new WorldGenMinable(Block.oreIron.blockID, 8);
|
||||
this.goldGen = new WorldGenMinable(Block.oreGold.blockID, 8);
|
||||
this.redstoneGen = new WorldGenMinable(Block.oreRedstone.blockID, 7);
|
||||
this.diamondGen = new WorldGenMinable(Block.oreDiamond.blockID, 7);
|
||||
this.lapisGen = new WorldGenMinable(Block.oreLapis.blockID, 6);
|
||||
this.plantYellowGen = new WorldGenFlowers(Block.plantYellow.blockID);
|
||||
this.plantRedGen = new WorldGenFlowers(Block.plantRed.blockID);
|
||||
this.mushroomBrownGen = new WorldGenFlowers(Block.mushroomBrown.blockID);
|
||||
this.mushroomRedGen = new WorldGenFlowers(Block.mushroomRed.blockID);
|
||||
this.bigMushroomGen = new WorldGenBigMushroom();
|
||||
this.reedGen = new WorldGenReed();
|
||||
this.cactusGen = new WorldGenCactus();
|
||||
this.waterlilyGen = new WorldGenWaterlily();
|
||||
this.flowersPerChunk = 2;
|
||||
this.grassPerChunk = 1;
|
||||
this.sandPerChunk = 1;
|
||||
this.sandPerChunk2 = 3;
|
||||
this.clayPerChunk = 1;
|
||||
this.generateLakes = true;
|
||||
this.biome = par1BiomeGenBase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorates the world. Calls code that was formerly (pre-1.8) in ChunkProviderGenerate.populate
|
||||
*/
|
||||
public void decorate(World par1World, Random par2Random, int par3, int par4)
|
||||
{
|
||||
if (this.currentWorld != null)
|
||||
{
|
||||
throw new RuntimeException("Already decorating!!");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.currentWorld = par1World;
|
||||
this.randomGenerator = par2Random;
|
||||
this.chunk_X = par3;
|
||||
this.chunk_Z = par4;
|
||||
this.decorate();
|
||||
this.currentWorld = null;
|
||||
this.randomGenerator = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The method that does the work of actually decorating chunks
|
||||
*/
|
||||
protected void decorate()
|
||||
{
|
||||
this.generateOres();
|
||||
int var1;
|
||||
int var2;
|
||||
int var3;
|
||||
|
||||
for (var1 = 0; var1 < this.sandPerChunk2; ++var1)
|
||||
{
|
||||
var2 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
|
||||
var3 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
|
||||
this.sandGen.generate(this.currentWorld, this.randomGenerator, var2, this.currentWorld.getTopSolidOrLiquidBlock(var2, var3), var3);
|
||||
}
|
||||
|
||||
for (var1 = 0; var1 < this.clayPerChunk; ++var1)
|
||||
{
|
||||
var2 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
|
||||
var3 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
|
||||
this.clayGen.generate(this.currentWorld, this.randomGenerator, var2, this.currentWorld.getTopSolidOrLiquidBlock(var2, var3), var3);
|
||||
}
|
||||
|
||||
for (var1 = 0; var1 < this.sandPerChunk; ++var1)
|
||||
{
|
||||
var2 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
|
||||
var3 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
|
||||
this.sandGen.generate(this.currentWorld, this.randomGenerator, var2, this.currentWorld.getTopSolidOrLiquidBlock(var2, var3), var3);
|
||||
}
|
||||
|
||||
var1 = this.treesPerChunk;
|
||||
|
||||
if (this.randomGenerator.nextInt(10) == 0)
|
||||
{
|
||||
++var1;
|
||||
}
|
||||
|
||||
int var4;
|
||||
|
||||
for (var2 = 0; var2 < var1; ++var2)
|
||||
{
|
||||
var3 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
|
||||
var4 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
|
||||
WorldGenerator var5 = this.biome.getRandomWorldGenForTrees(this.randomGenerator);
|
||||
var5.setScale(1.0D, 1.0D, 1.0D);
|
||||
var5.generate(this.currentWorld, this.randomGenerator, var3, this.currentWorld.getHeightValue(var3, var4), var4);
|
||||
}
|
||||
|
||||
for (var2 = 0; var2 < this.bigMushroomsPerChunk; ++var2)
|
||||
{
|
||||
var3 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
|
||||
var4 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
|
||||
this.bigMushroomGen.generate(this.currentWorld, this.randomGenerator, var3, this.currentWorld.getHeightValue(var3, var4), var4);
|
||||
}
|
||||
|
||||
int var7;
|
||||
|
||||
for (var2 = 0; var2 < this.flowersPerChunk; ++var2)
|
||||
{
|
||||
var3 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
|
||||
var4 = this.randomGenerator.nextInt(128);
|
||||
var7 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
|
||||
this.plantYellowGen.generate(this.currentWorld, this.randomGenerator, var3, var4, var7);
|
||||
|
||||
if (this.randomGenerator.nextInt(4) == 0)
|
||||
{
|
||||
var3 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
|
||||
var4 = this.randomGenerator.nextInt(128);
|
||||
var7 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
|
||||
this.plantRedGen.generate(this.currentWorld, this.randomGenerator, var3, var4, var7);
|
||||
}
|
||||
}
|
||||
|
||||
for (var2 = 0; var2 < this.grassPerChunk; ++var2)
|
||||
{
|
||||
var3 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
|
||||
var4 = this.randomGenerator.nextInt(128);
|
||||
var7 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
|
||||
WorldGenerator var6 = this.biome.getRandomWorldGenForGrass(this.randomGenerator);
|
||||
var6.generate(this.currentWorld, this.randomGenerator, var3, var4, var7);
|
||||
}
|
||||
|
||||
for (var2 = 0; var2 < this.deadBushPerChunk; ++var2)
|
||||
{
|
||||
var3 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
|
||||
var4 = this.randomGenerator.nextInt(128);
|
||||
var7 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
|
||||
(new WorldGenDeadBush(Block.deadBush.blockID)).generate(this.currentWorld, this.randomGenerator, var3, var4, var7);
|
||||
}
|
||||
|
||||
for (var2 = 0; var2 < this.waterlilyPerChunk; ++var2)
|
||||
{
|
||||
var3 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
|
||||
var4 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
|
||||
|
||||
for (var7 = this.randomGenerator.nextInt(128); var7 > 0 && this.currentWorld.getBlockId(var3, var7 - 1, var4) == 0; --var7)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
this.waterlilyGen.generate(this.currentWorld, this.randomGenerator, var3, var7, var4);
|
||||
}
|
||||
|
||||
for (var2 = 0; var2 < this.mushroomsPerChunk; ++var2)
|
||||
{
|
||||
if (this.randomGenerator.nextInt(4) == 0)
|
||||
{
|
||||
var3 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
|
||||
var4 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
|
||||
var7 = this.currentWorld.getHeightValue(var3, var4);
|
||||
this.mushroomBrownGen.generate(this.currentWorld, this.randomGenerator, var3, var7, var4);
|
||||
}
|
||||
|
||||
if (this.randomGenerator.nextInt(8) == 0)
|
||||
{
|
||||
var3 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
|
||||
var4 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
|
||||
var7 = this.randomGenerator.nextInt(128);
|
||||
this.mushroomRedGen.generate(this.currentWorld, this.randomGenerator, var3, var7, var4);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.randomGenerator.nextInt(4) == 0)
|
||||
{
|
||||
var2 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
|
||||
var3 = this.randomGenerator.nextInt(128);
|
||||
var4 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
|
||||
this.mushroomBrownGen.generate(this.currentWorld, this.randomGenerator, var2, var3, var4);
|
||||
}
|
||||
|
||||
if (this.randomGenerator.nextInt(8) == 0)
|
||||
{
|
||||
var2 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
|
||||
var3 = this.randomGenerator.nextInt(128);
|
||||
var4 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
|
||||
this.mushroomRedGen.generate(this.currentWorld, this.randomGenerator, var2, var3, var4);
|
||||
}
|
||||
|
||||
for (var2 = 0; var2 < this.reedsPerChunk; ++var2)
|
||||
{
|
||||
var3 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
|
||||
var4 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
|
||||
var7 = this.randomGenerator.nextInt(128);
|
||||
this.reedGen.generate(this.currentWorld, this.randomGenerator, var3, var7, var4);
|
||||
}
|
||||
|
||||
for (var2 = 0; var2 < 10; ++var2)
|
||||
{
|
||||
var3 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
|
||||
var4 = this.randomGenerator.nextInt(128);
|
||||
var7 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
|
||||
this.reedGen.generate(this.currentWorld, this.randomGenerator, var3, var4, var7);
|
||||
}
|
||||
|
||||
if (this.randomGenerator.nextInt(32) == 0)
|
||||
{
|
||||
var2 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
|
||||
var3 = this.randomGenerator.nextInt(128);
|
||||
var4 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
|
||||
(new WorldGenPumpkin()).generate(this.currentWorld, this.randomGenerator, var2, var3, var4);
|
||||
}
|
||||
|
||||
for (var2 = 0; var2 < this.cactiPerChunk; ++var2)
|
||||
{
|
||||
var3 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
|
||||
var4 = this.randomGenerator.nextInt(128);
|
||||
var7 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
|
||||
this.cactusGen.generate(this.currentWorld, this.randomGenerator, var3, var4, var7);
|
||||
}
|
||||
|
||||
if (this.generateLakes)
|
||||
{
|
||||
for (var2 = 0; var2 < 50; ++var2)
|
||||
{
|
||||
var3 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
|
||||
var4 = this.randomGenerator.nextInt(this.randomGenerator.nextInt(120) + 8);
|
||||
var7 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
|
||||
(new WorldGenLiquids(Block.waterMoving.blockID)).generate(this.currentWorld, this.randomGenerator, var3, var4, var7);
|
||||
}
|
||||
|
||||
for (var2 = 0; var2 < 20; ++var2)
|
||||
{
|
||||
var3 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
|
||||
var4 = this.randomGenerator.nextInt(this.randomGenerator.nextInt(this.randomGenerator.nextInt(112) + 8) + 8);
|
||||
var7 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
|
||||
(new WorldGenLiquids(Block.lavaMoving.blockID)).generate(this.currentWorld, this.randomGenerator, var3, var4, var7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard ore generation helper. Generates most ores.
|
||||
*/
|
||||
protected void genStandardOre1(int par1, WorldGenerator par2WorldGenerator, int par3, int par4)
|
||||
{
|
||||
for (int var5 = 0; var5 < par1; ++var5)
|
||||
{
|
||||
int var6 = this.chunk_X + this.randomGenerator.nextInt(16);
|
||||
int var7 = this.randomGenerator.nextInt(par4 - par3) + par3;
|
||||
int var8 = this.chunk_Z + this.randomGenerator.nextInt(16);
|
||||
par2WorldGenerator.generate(this.currentWorld, this.randomGenerator, var6, var7, var8);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard ore generation helper. Generates Lapis Lazuli.
|
||||
*/
|
||||
protected void genStandardOre2(int par1, WorldGenerator par2WorldGenerator, int par3, int par4)
|
||||
{
|
||||
for (int var5 = 0; var5 < par1; ++var5)
|
||||
{
|
||||
int var6 = this.chunk_X + this.randomGenerator.nextInt(16);
|
||||
int var7 = this.randomGenerator.nextInt(par4) + this.randomGenerator.nextInt(par4) + (par3 - par4);
|
||||
int var8 = this.chunk_Z + this.randomGenerator.nextInt(16);
|
||||
par2WorldGenerator.generate(this.currentWorld, this.randomGenerator, var6, var7, var8);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates ores in the current chunk
|
||||
*/
|
||||
protected void generateOres()
|
||||
{
|
||||
this.genStandardOre1(20, this.dirtGen, 0, 128);
|
||||
this.genStandardOre1(10, this.gravelGen, 0, 128);
|
||||
this.genStandardOre1(20, this.coalGen, 0, 128);
|
||||
this.genStandardOre1(20, this.ironGen, 0, 64);
|
||||
this.genStandardOre1(2, this.goldGen, 0, 32);
|
||||
this.genStandardOre1(8, this.redstoneGen, 0, 16);
|
||||
this.genStandardOre1(1, this.diamondGen, 0, 16);
|
||||
this.genStandardOre2(1, this.lapisGen, 16, 16);
|
||||
}
|
||||
}
|
||||
35
src/main/java/net/minecraft/src/BiomeEndDecorator.java
Normal file
35
src/main/java/net/minecraft/src/BiomeEndDecorator.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class BiomeEndDecorator extends BiomeDecorator
|
||||
{
|
||||
protected WorldGenerator spikeGen;
|
||||
|
||||
public BiomeEndDecorator(BiomeGenBase par1BiomeGenBase)
|
||||
{
|
||||
super(par1BiomeGenBase);
|
||||
this.spikeGen = new WorldGenSpikes(Block.whiteStone.blockID);
|
||||
}
|
||||
|
||||
/**
|
||||
* The method that does the work of actually decorating chunks
|
||||
*/
|
||||
protected void decorate()
|
||||
{
|
||||
this.generateOres();
|
||||
|
||||
if (this.randomGenerator.nextInt(5) == 0)
|
||||
{
|
||||
int var1 = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
|
||||
int var2 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
|
||||
int var3 = this.currentWorld.getTopSolidOrLiquidBlock(var1, var2);
|
||||
this.spikeGen.generate(this.currentWorld, this.randomGenerator, var1, var3, var2);
|
||||
}
|
||||
|
||||
if (this.chunk_X == 0 && this.chunk_Z == 0)
|
||||
{
|
||||
EntityDragon var4 = new EntityDragon(this.currentWorld);
|
||||
var4.setLocationAndAngles(0.0D, 128.0D, 0.0D, this.randomGenerator.nextFloat() * 360.0F, 0.0F);
|
||||
this.currentWorld.spawnEntityInWorld(var4);
|
||||
}
|
||||
}
|
||||
}
|
||||
355
src/main/java/net/minecraft/src/BiomeGenBase.java
Normal file
355
src/main/java/net/minecraft/src/BiomeGenBase.java
Normal file
@@ -0,0 +1,355 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class BiomeGenBase
|
||||
{
|
||||
/** An array of all the biomes, indexed by biome id. */
|
||||
public static final BiomeGenBase[] biomeList = new BiomeGenBase[256];
|
||||
public static final BiomeGenBase ocean = (new BiomeGenOcean(0)).setColor(112).setBiomeName("Ocean").setMinMaxHeight(-1.0F, 0.4F);
|
||||
public static final BiomeGenBase plains = (new BiomeGenPlains(1)).setColor(9286496).setBiomeName("Plains").setTemperatureRainfall(0.8F, 0.4F);
|
||||
public static final BiomeGenBase desert = (new BiomeGenDesert(2)).setColor(16421912).setBiomeName("Desert").setDisableRain().setTemperatureRainfall(2.0F, 0.0F).setMinMaxHeight(0.1F, 0.2F);
|
||||
public static final BiomeGenBase extremeHills = (new BiomeGenHills(3)).setColor(6316128).setBiomeName("Extreme Hills").setMinMaxHeight(0.3F, 1.5F).setTemperatureRainfall(0.2F, 0.3F);
|
||||
public static final BiomeGenBase forest = (new BiomeGenForest(4)).setColor(353825).setBiomeName("Forest").func_76733_a(5159473).setTemperatureRainfall(0.7F, 0.8F);
|
||||
public static final BiomeGenBase taiga = (new BiomeGenTaiga(5)).setColor(747097).setBiomeName("Taiga").func_76733_a(5159473).setEnableSnow().setTemperatureRainfall(0.05F, 0.8F).setMinMaxHeight(0.1F, 0.4F);
|
||||
public static final BiomeGenBase swampland = (new BiomeGenSwamp(6)).setColor(522674).setBiomeName("Swampland").func_76733_a(9154376).setMinMaxHeight(-0.2F, 0.1F).setTemperatureRainfall(0.8F, 0.9F);
|
||||
public static final BiomeGenBase river = (new BiomeGenRiver(7)).setColor(255).setBiomeName("River").setMinMaxHeight(-0.5F, 0.0F);
|
||||
public static final BiomeGenBase hell = (new BiomeGenHell(8)).setColor(16711680).setBiomeName("Hell").setDisableRain().setTemperatureRainfall(2.0F, 0.0F);
|
||||
|
||||
/** Is the biome used for sky world. */
|
||||
public static final BiomeGenBase sky = (new BiomeGenEnd(9)).setColor(8421631).setBiomeName("Sky").setDisableRain();
|
||||
public static final BiomeGenBase frozenOcean = (new BiomeGenOcean(10)).setColor(9474208).setBiomeName("FrozenOcean").setEnableSnow().setMinMaxHeight(-1.0F, 0.5F).setTemperatureRainfall(0.0F, 0.5F);
|
||||
public static final BiomeGenBase frozenRiver = (new BiomeGenRiver(11)).setColor(10526975).setBiomeName("FrozenRiver").setEnableSnow().setMinMaxHeight(-0.5F, 0.0F).setTemperatureRainfall(0.0F, 0.5F);
|
||||
public static final BiomeGenBase icePlains = (new BiomeGenSnow(12)).setColor(16777215).setBiomeName("Ice Plains").setEnableSnow().setTemperatureRainfall(0.0F, 0.5F);
|
||||
public static final BiomeGenBase iceMountains = (new BiomeGenSnow(13)).setColor(10526880).setBiomeName("Ice Mountains").setEnableSnow().setMinMaxHeight(0.3F, 1.3F).setTemperatureRainfall(0.0F, 0.5F);
|
||||
public static final BiomeGenBase mushroomIsland = (new BiomeGenMushroomIsland(14)).setColor(16711935).setBiomeName("MushroomIsland").setTemperatureRainfall(0.9F, 1.0F).setMinMaxHeight(0.2F, 1.0F);
|
||||
public static final BiomeGenBase mushroomIslandShore = (new BiomeGenMushroomIsland(15)).setColor(10486015).setBiomeName("MushroomIslandShore").setTemperatureRainfall(0.9F, 1.0F).setMinMaxHeight(-1.0F, 0.1F);
|
||||
|
||||
/** Beach biome. */
|
||||
public static final BiomeGenBase beach = (new BiomeGenBeach(16)).setColor(16440917).setBiomeName("Beach").setTemperatureRainfall(0.8F, 0.4F).setMinMaxHeight(0.0F, 0.1F);
|
||||
|
||||
/** Desert Hills biome. */
|
||||
public static final BiomeGenBase desertHills = (new BiomeGenDesert(17)).setColor(13786898).setBiomeName("DesertHills").setDisableRain().setTemperatureRainfall(2.0F, 0.0F).setMinMaxHeight(0.3F, 0.8F);
|
||||
|
||||
/** Forest Hills biome. */
|
||||
public static final BiomeGenBase forestHills = (new BiomeGenForest(18)).setColor(2250012).setBiomeName("ForestHills").func_76733_a(5159473).setTemperatureRainfall(0.7F, 0.8F).setMinMaxHeight(0.3F, 0.7F);
|
||||
|
||||
/** Taiga Hills biome. */
|
||||
public static final BiomeGenBase taigaHills = (new BiomeGenTaiga(19)).setColor(1456435).setBiomeName("TaigaHills").setEnableSnow().func_76733_a(5159473).setTemperatureRainfall(0.05F, 0.8F).setMinMaxHeight(0.3F, 0.8F);
|
||||
|
||||
/** Extreme Hills Edge biome. */
|
||||
public static final BiomeGenBase extremeHillsEdge = (new BiomeGenHills(20)).setColor(7501978).setBiomeName("Extreme Hills Edge").setMinMaxHeight(0.2F, 0.8F).setTemperatureRainfall(0.2F, 0.3F);
|
||||
|
||||
/** Jungle biome identifier */
|
||||
public static final BiomeGenBase jungle = (new BiomeGenJungle(21)).setColor(5470985).setBiomeName("Jungle").func_76733_a(5470985).setTemperatureRainfall(1.2F, 0.9F).setMinMaxHeight(0.2F, 0.4F);
|
||||
public static final BiomeGenBase jungleHills = (new BiomeGenJungle(22)).setColor(2900485).setBiomeName("JungleHills").func_76733_a(5470985).setTemperatureRainfall(1.2F, 0.9F).setMinMaxHeight(1.8F, 0.5F);
|
||||
public String biomeName;
|
||||
public int color;
|
||||
|
||||
/** The block expected to be on the top of this biome */
|
||||
public byte topBlock;
|
||||
|
||||
/** The block to fill spots in when not on the top */
|
||||
public byte fillerBlock;
|
||||
public int field_76754_C;
|
||||
|
||||
/** The minimum height of this biome. Default 0.1. */
|
||||
public float minHeight;
|
||||
|
||||
/** The maximum height of this biome. Default 0.3. */
|
||||
public float maxHeight;
|
||||
|
||||
/** The temperature of this biome. */
|
||||
public float temperature;
|
||||
|
||||
/** The rainfall in this biome. */
|
||||
public float rainfall;
|
||||
|
||||
/** Color tint applied to water depending on biome */
|
||||
public int waterColorMultiplier;
|
||||
|
||||
/** The biome decorator. */
|
||||
public BiomeDecorator theBiomeDecorator;
|
||||
|
||||
/**
|
||||
* Holds the classes of IMobs (hostile mobs) that can be spawned in the biome.
|
||||
*/
|
||||
protected List spawnableMonsterList;
|
||||
|
||||
/**
|
||||
* Holds the classes of any creature that can be spawned in the biome as friendly creature.
|
||||
*/
|
||||
protected List spawnableCreatureList;
|
||||
|
||||
/**
|
||||
* Holds the classes of any aquatic creature that can be spawned in the water of the biome.
|
||||
*/
|
||||
protected List spawnableWaterCreatureList;
|
||||
protected List spawnableCaveCreatureList;
|
||||
|
||||
/** Set to true if snow is enabled for this biome. */
|
||||
private boolean enableSnow;
|
||||
|
||||
/**
|
||||
* Is true (default) if the biome support rain (desert and nether can't have rain)
|
||||
*/
|
||||
private boolean enableRain;
|
||||
|
||||
/** The id number to this biome, and its index in the biomeList array. */
|
||||
public final int biomeID;
|
||||
|
||||
/** The tree generator. */
|
||||
protected WorldGenTrees worldGeneratorTrees;
|
||||
|
||||
/** The big tree generator. */
|
||||
protected WorldGenBigTree worldGeneratorBigTree;
|
||||
|
||||
/** The forest generator. */
|
||||
protected WorldGenForest worldGeneratorForest;
|
||||
|
||||
/** The swamp tree generator. */
|
||||
protected WorldGenSwamp worldGeneratorSwamp;
|
||||
|
||||
protected BiomeGenBase(int par1)
|
||||
{
|
||||
this.topBlock = (byte)Block.grass.blockID;
|
||||
this.fillerBlock = (byte)Block.dirt.blockID;
|
||||
this.field_76754_C = 5169201;
|
||||
this.minHeight = 0.1F;
|
||||
this.maxHeight = 0.3F;
|
||||
this.temperature = 0.5F;
|
||||
this.rainfall = 0.5F;
|
||||
this.waterColorMultiplier = 16777215;
|
||||
this.spawnableMonsterList = new ArrayList();
|
||||
this.spawnableCreatureList = new ArrayList();
|
||||
this.spawnableWaterCreatureList = new ArrayList();
|
||||
this.spawnableCaveCreatureList = new ArrayList();
|
||||
this.enableRain = true;
|
||||
this.worldGeneratorTrees = new WorldGenTrees(false);
|
||||
this.worldGeneratorBigTree = new WorldGenBigTree(false);
|
||||
this.worldGeneratorForest = new WorldGenForest(false);
|
||||
this.worldGeneratorSwamp = new WorldGenSwamp();
|
||||
this.biomeID = par1;
|
||||
biomeList[par1] = this;
|
||||
this.theBiomeDecorator = this.createBiomeDecorator();
|
||||
this.spawnableCreatureList.add(new SpawnListEntry(EntitySheep.class, 12, 4, 4));
|
||||
this.spawnableCreatureList.add(new SpawnListEntry(EntityPig.class, 10, 4, 4));
|
||||
this.spawnableCreatureList.add(new SpawnListEntry(EntityChicken.class, 10, 4, 4));
|
||||
this.spawnableCreatureList.add(new SpawnListEntry(EntityCow.class, 8, 4, 4));
|
||||
this.spawnableMonsterList.add(new SpawnListEntry(EntitySpider.class, 10, 4, 4));
|
||||
this.spawnableMonsterList.add(new SpawnListEntry(EntityZombie.class, 10, 4, 4));
|
||||
this.spawnableMonsterList.add(new SpawnListEntry(EntitySkeleton.class, 10, 4, 4));
|
||||
this.spawnableMonsterList.add(new SpawnListEntry(EntityCreeper.class, 10, 4, 4));
|
||||
this.spawnableMonsterList.add(new SpawnListEntry(EntitySlime.class, 10, 4, 4));
|
||||
this.spawnableMonsterList.add(new SpawnListEntry(EntityEnderman.class, 1, 1, 4));
|
||||
this.spawnableWaterCreatureList.add(new SpawnListEntry(EntitySquid.class, 10, 4, 4));
|
||||
this.spawnableCaveCreatureList.add(new SpawnListEntry(EntityBat.class, 10, 8, 8));
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate a new BiomeDecorator for this BiomeGenBase
|
||||
*/
|
||||
protected BiomeDecorator createBiomeDecorator()
|
||||
{
|
||||
return new BiomeDecorator(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the temperature and rainfall of this biome.
|
||||
*/
|
||||
private BiomeGenBase setTemperatureRainfall(float par1, float par2)
|
||||
{
|
||||
if (par1 > 0.1F && par1 < 0.2F)
|
||||
{
|
||||
throw new IllegalArgumentException("Please avoid temperatures in the range 0.1 - 0.2 because of snow");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.temperature = par1;
|
||||
this.rainfall = par2;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the minimum and maximum height of this biome. Seems to go from -2.0 to 2.0.
|
||||
*/
|
||||
private BiomeGenBase setMinMaxHeight(float par1, float par2)
|
||||
{
|
||||
this.minHeight = par1;
|
||||
this.maxHeight = par2;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the rain for the biome.
|
||||
*/
|
||||
private BiomeGenBase setDisableRain()
|
||||
{
|
||||
this.enableRain = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a WorldGen appropriate for this biome.
|
||||
*/
|
||||
public WorldGenerator getRandomWorldGenForTrees(Random par1Random)
|
||||
{
|
||||
return (WorldGenerator)(par1Random.nextInt(10) == 0 ? this.worldGeneratorBigTree : this.worldGeneratorTrees);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a WorldGen appropriate for this biome.
|
||||
*/
|
||||
public WorldGenerator getRandomWorldGenForGrass(Random par1Random)
|
||||
{
|
||||
return new WorldGenTallGrass(Block.tallGrass.blockID, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* sets enableSnow to true during biome initialization. returns BiomeGenBase.
|
||||
*/
|
||||
protected BiomeGenBase setEnableSnow()
|
||||
{
|
||||
this.enableSnow = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected BiomeGenBase setBiomeName(String par1Str)
|
||||
{
|
||||
this.biomeName = par1Str;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected BiomeGenBase func_76733_a(int par1)
|
||||
{
|
||||
this.field_76754_C = par1;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected BiomeGenBase setColor(int par1)
|
||||
{
|
||||
this.color = par1;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* takes temperature, returns color
|
||||
*/
|
||||
public int getSkyColorByTemp(float par1)
|
||||
{
|
||||
par1 /= 3.0F;
|
||||
|
||||
if (par1 < -1.0F)
|
||||
{
|
||||
par1 = -1.0F;
|
||||
}
|
||||
|
||||
if (par1 > 1.0F)
|
||||
{
|
||||
par1 = 1.0F;
|
||||
}
|
||||
|
||||
return Color.getHSBColor(0.62222224F - par1 * 0.05F, 0.5F + par1 * 0.1F, 1.0F).getRGB();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the correspondent list of the EnumCreatureType informed.
|
||||
*/
|
||||
public List getSpawnableList(EnumCreatureType par1EnumCreatureType)
|
||||
{
|
||||
return par1EnumCreatureType == EnumCreatureType.monster ? this.spawnableMonsterList : (par1EnumCreatureType == EnumCreatureType.creature ? this.spawnableCreatureList : (par1EnumCreatureType == EnumCreatureType.waterCreature ? this.spawnableWaterCreatureList : (par1EnumCreatureType == EnumCreatureType.ambient ? this.spawnableCaveCreatureList : null)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the biome have snowfall instead a normal rain.
|
||||
*/
|
||||
public boolean getEnableSnow()
|
||||
{
|
||||
return this.enableSnow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the biome supports lightning bolt spawn, either by have the bolts enabled and have rain enabled.
|
||||
*/
|
||||
public boolean canSpawnLightningBolt()
|
||||
{
|
||||
return this.enableSnow ? false : this.enableRain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the rainfall level of the biome is extremely high
|
||||
*/
|
||||
public boolean isHighHumidity()
|
||||
{
|
||||
return this.rainfall > 0.85F;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the chance a creature has to spawn.
|
||||
*/
|
||||
public float getSpawningChance()
|
||||
{
|
||||
return 0.1F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an integer representation of this biome's rainfall
|
||||
*/
|
||||
public final int getIntRainfall()
|
||||
{
|
||||
return (int)(this.rainfall * 65536.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an integer representation of this biome's temperature
|
||||
*/
|
||||
public final int getIntTemperature()
|
||||
{
|
||||
return (int)(this.temperature * 65536.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a floating point representation of this biome's rainfall
|
||||
*/
|
||||
public final float getFloatRainfall()
|
||||
{
|
||||
return this.rainfall;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a floating point representation of this biome's temperature
|
||||
*/
|
||||
public final float getFloatTemperature()
|
||||
{
|
||||
return this.temperature;
|
||||
}
|
||||
|
||||
public void decorate(World par1World, Random par2Random, int par3, int par4)
|
||||
{
|
||||
this.theBiomeDecorator.decorate(par1World, par2Random, par3, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the basic grass color based on the biome temperature and rainfall
|
||||
*/
|
||||
public int getBiomeGrassColor()
|
||||
{
|
||||
double var1 = (double)MathHelper.clamp_float(this.getFloatTemperature(), 0.0F, 1.0F);
|
||||
double var3 = (double)MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F);
|
||||
return ColorizerGrass.getGrassColor(var1, var3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the basic foliage color based on the biome temperature and rainfall
|
||||
*/
|
||||
public int getBiomeFoliageColor()
|
||||
{
|
||||
double var1 = (double)MathHelper.clamp_float(this.getFloatTemperature(), 0.0F, 1.0F);
|
||||
double var3 = (double)MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F);
|
||||
return ColorizerFoliage.getFoliageColor(var1, var3);
|
||||
}
|
||||
}
|
||||
16
src/main/java/net/minecraft/src/BiomeGenBeach.java
Normal file
16
src/main/java/net/minecraft/src/BiomeGenBeach.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class BiomeGenBeach extends BiomeGenBase
|
||||
{
|
||||
public BiomeGenBeach(int par1)
|
||||
{
|
||||
super(par1);
|
||||
this.spawnableCreatureList.clear();
|
||||
this.topBlock = (byte)Block.sand.blockID;
|
||||
this.fillerBlock = (byte)Block.sand.blockID;
|
||||
this.theBiomeDecorator.treesPerChunk = -999;
|
||||
this.theBiomeDecorator.deadBushPerChunk = 0;
|
||||
this.theBiomeDecorator.reedsPerChunk = 0;
|
||||
this.theBiomeDecorator.cactiPerChunk = 0;
|
||||
}
|
||||
}
|
||||
31
src/main/java/net/minecraft/src/BiomeGenDesert.java
Normal file
31
src/main/java/net/minecraft/src/BiomeGenDesert.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BiomeGenDesert extends BiomeGenBase
|
||||
{
|
||||
public BiomeGenDesert(int par1)
|
||||
{
|
||||
super(par1);
|
||||
this.spawnableCreatureList.clear();
|
||||
this.topBlock = (byte)Block.sand.blockID;
|
||||
this.fillerBlock = (byte)Block.sand.blockID;
|
||||
this.theBiomeDecorator.treesPerChunk = -999;
|
||||
this.theBiomeDecorator.deadBushPerChunk = 2;
|
||||
this.theBiomeDecorator.reedsPerChunk = 50;
|
||||
this.theBiomeDecorator.cactiPerChunk = 10;
|
||||
}
|
||||
|
||||
public void decorate(World par1World, Random par2Random, int par3, int par4)
|
||||
{
|
||||
super.decorate(par1World, par2Random, par3, par4);
|
||||
|
||||
if (par2Random.nextInt(1000) == 0)
|
||||
{
|
||||
int var5 = par3 + par2Random.nextInt(16) + 8;
|
||||
int var6 = par4 + par2Random.nextInt(16) + 8;
|
||||
WorldGenDesertWells var7 = new WorldGenDesertWells();
|
||||
var7.generate(par1World, par2Random, var5, par1World.getHeightValue(var5, var6) + 1, var6);
|
||||
}
|
||||
}
|
||||
}
|
||||
25
src/main/java/net/minecraft/src/BiomeGenEnd.java
Normal file
25
src/main/java/net/minecraft/src/BiomeGenEnd.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class BiomeGenEnd extends BiomeGenBase
|
||||
{
|
||||
public BiomeGenEnd(int par1)
|
||||
{
|
||||
super(par1);
|
||||
this.spawnableMonsterList.clear();
|
||||
this.spawnableCreatureList.clear();
|
||||
this.spawnableWaterCreatureList.clear();
|
||||
this.spawnableCaveCreatureList.clear();
|
||||
this.spawnableMonsterList.add(new SpawnListEntry(EntityEnderman.class, 10, 4, 4));
|
||||
this.topBlock = (byte)Block.dirt.blockID;
|
||||
this.fillerBlock = (byte)Block.dirt.blockID;
|
||||
this.theBiomeDecorator = new BiomeEndDecorator(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* takes temperature, returns color
|
||||
*/
|
||||
public int getSkyColorByTemp(float par1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
22
src/main/java/net/minecraft/src/BiomeGenForest.java
Normal file
22
src/main/java/net/minecraft/src/BiomeGenForest.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BiomeGenForest extends BiomeGenBase
|
||||
{
|
||||
public BiomeGenForest(int par1)
|
||||
{
|
||||
super(par1);
|
||||
this.spawnableCreatureList.add(new SpawnListEntry(EntityWolf.class, 5, 4, 4));
|
||||
this.theBiomeDecorator.treesPerChunk = 10;
|
||||
this.theBiomeDecorator.grassPerChunk = 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a WorldGen appropriate for this biome.
|
||||
*/
|
||||
public WorldGenerator getRandomWorldGenForTrees(Random par1Random)
|
||||
{
|
||||
return (WorldGenerator)(par1Random.nextInt(5) == 0 ? this.worldGeneratorForest : (par1Random.nextInt(10) == 0 ? this.worldGeneratorBigTree : this.worldGeneratorTrees));
|
||||
}
|
||||
}
|
||||
16
src/main/java/net/minecraft/src/BiomeGenHell.java
Normal file
16
src/main/java/net/minecraft/src/BiomeGenHell.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class BiomeGenHell extends BiomeGenBase
|
||||
{
|
||||
public BiomeGenHell(int par1)
|
||||
{
|
||||
super(par1);
|
||||
this.spawnableMonsterList.clear();
|
||||
this.spawnableCreatureList.clear();
|
||||
this.spawnableWaterCreatureList.clear();
|
||||
this.spawnableCaveCreatureList.clear();
|
||||
this.spawnableMonsterList.add(new SpawnListEntry(EntityGhast.class, 50, 4, 4));
|
||||
this.spawnableMonsterList.add(new SpawnListEntry(EntityPigZombie.class, 100, 4, 4));
|
||||
this.spawnableMonsterList.add(new SpawnListEntry(EntityMagmaCube.class, 1, 4, 4));
|
||||
}
|
||||
}
|
||||
44
src/main/java/net/minecraft/src/BiomeGenHills.java
Normal file
44
src/main/java/net/minecraft/src/BiomeGenHills.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BiomeGenHills extends BiomeGenBase
|
||||
{
|
||||
private WorldGenerator theWorldGenerator;
|
||||
|
||||
protected BiomeGenHills(int par1)
|
||||
{
|
||||
super(par1);
|
||||
this.theWorldGenerator = new WorldGenMinable(Block.silverfish.blockID, 8);
|
||||
}
|
||||
|
||||
public void decorate(World par1World, Random par2Random, int par3, int par4)
|
||||
{
|
||||
super.decorate(par1World, par2Random, par3, par4);
|
||||
int var5 = 3 + par2Random.nextInt(6);
|
||||
int var6;
|
||||
int var7;
|
||||
int var8;
|
||||
|
||||
for (var6 = 0; var6 < var5; ++var6)
|
||||
{
|
||||
var7 = par3 + par2Random.nextInt(16);
|
||||
var8 = par2Random.nextInt(28) + 4;
|
||||
int var9 = par4 + par2Random.nextInt(16);
|
||||
int var10 = par1World.getBlockId(var7, var8, var9);
|
||||
|
||||
if (var10 == Block.stone.blockID)
|
||||
{
|
||||
par1World.setBlock(var7, var8, var9, Block.oreEmerald.blockID, 0, 2);
|
||||
}
|
||||
}
|
||||
|
||||
for (var5 = 0; var5 < 7; ++var5)
|
||||
{
|
||||
var6 = par3 + par2Random.nextInt(16);
|
||||
var7 = par2Random.nextInt(64);
|
||||
var8 = par4 + par2Random.nextInt(16);
|
||||
this.theWorldGenerator.generate(par1World, par2Random, var6, var7, var8);
|
||||
}
|
||||
}
|
||||
}
|
||||
46
src/main/java/net/minecraft/src/BiomeGenJungle.java
Normal file
46
src/main/java/net/minecraft/src/BiomeGenJungle.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BiomeGenJungle extends BiomeGenBase
|
||||
{
|
||||
public BiomeGenJungle(int par1)
|
||||
{
|
||||
super(par1);
|
||||
this.theBiomeDecorator.treesPerChunk = 50;
|
||||
this.theBiomeDecorator.grassPerChunk = 25;
|
||||
this.theBiomeDecorator.flowersPerChunk = 4;
|
||||
this.spawnableMonsterList.add(new SpawnListEntry(EntityOcelot.class, 2, 1, 1));
|
||||
this.spawnableCreatureList.add(new SpawnListEntry(EntityChicken.class, 10, 4, 4));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a WorldGen appropriate for this biome.
|
||||
*/
|
||||
public WorldGenerator getRandomWorldGenForTrees(Random par1Random)
|
||||
{
|
||||
return (WorldGenerator)(par1Random.nextInt(10) == 0 ? this.worldGeneratorBigTree : (par1Random.nextInt(2) == 0 ? new WorldGenShrub(3, 0) : (par1Random.nextInt(3) == 0 ? new WorldGenHugeTrees(false, 10 + par1Random.nextInt(20), 3, 3) : new WorldGenTrees(false, 4 + par1Random.nextInt(7), 3, 3, true))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a WorldGen appropriate for this biome.
|
||||
*/
|
||||
public WorldGenerator getRandomWorldGenForGrass(Random par1Random)
|
||||
{
|
||||
return par1Random.nextInt(4) == 0 ? new WorldGenTallGrass(Block.tallGrass.blockID, 2) : new WorldGenTallGrass(Block.tallGrass.blockID, 1);
|
||||
}
|
||||
|
||||
public void decorate(World par1World, Random par2Random, int par3, int par4)
|
||||
{
|
||||
super.decorate(par1World, par2Random, par3, par4);
|
||||
WorldGenVines var5 = new WorldGenVines();
|
||||
|
||||
for (int var6 = 0; var6 < 50; ++var6)
|
||||
{
|
||||
int var7 = par3 + par2Random.nextInt(16) + 8;
|
||||
byte var8 = 64;
|
||||
int var9 = par4 + par2Random.nextInt(16) + 8;
|
||||
var5.generate(par1World, par2Random, var7, var8, var9);
|
||||
}
|
||||
}
|
||||
}
|
||||
19
src/main/java/net/minecraft/src/BiomeGenMushroomIsland.java
Normal file
19
src/main/java/net/minecraft/src/BiomeGenMushroomIsland.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class BiomeGenMushroomIsland extends BiomeGenBase
|
||||
{
|
||||
public BiomeGenMushroomIsland(int par1)
|
||||
{
|
||||
super(par1);
|
||||
this.theBiomeDecorator.treesPerChunk = -100;
|
||||
this.theBiomeDecorator.flowersPerChunk = -100;
|
||||
this.theBiomeDecorator.grassPerChunk = -100;
|
||||
this.theBiomeDecorator.mushroomsPerChunk = 1;
|
||||
this.theBiomeDecorator.bigMushroomsPerChunk = 1;
|
||||
this.topBlock = (byte)Block.mycelium.blockID;
|
||||
this.spawnableMonsterList.clear();
|
||||
this.spawnableCreatureList.clear();
|
||||
this.spawnableWaterCreatureList.clear();
|
||||
this.spawnableCreatureList.add(new SpawnListEntry(EntityMooshroom.class, 8, 4, 8));
|
||||
}
|
||||
}
|
||||
10
src/main/java/net/minecraft/src/BiomeGenOcean.java
Normal file
10
src/main/java/net/minecraft/src/BiomeGenOcean.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class BiomeGenOcean extends BiomeGenBase
|
||||
{
|
||||
public BiomeGenOcean(int par1)
|
||||
{
|
||||
super(par1);
|
||||
this.spawnableCreatureList.clear();
|
||||
}
|
||||
}
|
||||
13
src/main/java/net/minecraft/src/BiomeGenPlains.java
Normal file
13
src/main/java/net/minecraft/src/BiomeGenPlains.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class BiomeGenPlains extends BiomeGenBase
|
||||
{
|
||||
protected BiomeGenPlains(int par1)
|
||||
{
|
||||
super(par1);
|
||||
this.spawnableCreatureList.add(new SpawnListEntry(EntityHorse.class, 5, 2, 6));
|
||||
this.theBiomeDecorator.treesPerChunk = -999;
|
||||
this.theBiomeDecorator.flowersPerChunk = 4;
|
||||
this.theBiomeDecorator.grassPerChunk = 10;
|
||||
}
|
||||
}
|
||||
10
src/main/java/net/minecraft/src/BiomeGenRiver.java
Normal file
10
src/main/java/net/minecraft/src/BiomeGenRiver.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class BiomeGenRiver extends BiomeGenBase
|
||||
{
|
||||
public BiomeGenRiver(int par1)
|
||||
{
|
||||
super(par1);
|
||||
this.spawnableCreatureList.clear();
|
||||
}
|
||||
}
|
||||
9
src/main/java/net/minecraft/src/BiomeGenSnow.java
Normal file
9
src/main/java/net/minecraft/src/BiomeGenSnow.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class BiomeGenSnow extends BiomeGenBase
|
||||
{
|
||||
public BiomeGenSnow(int par1)
|
||||
{
|
||||
super(par1);
|
||||
}
|
||||
}
|
||||
48
src/main/java/net/minecraft/src/BiomeGenSwamp.java
Normal file
48
src/main/java/net/minecraft/src/BiomeGenSwamp.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BiomeGenSwamp extends BiomeGenBase
|
||||
{
|
||||
protected BiomeGenSwamp(int par1)
|
||||
{
|
||||
super(par1);
|
||||
this.theBiomeDecorator.treesPerChunk = 2;
|
||||
this.theBiomeDecorator.flowersPerChunk = -999;
|
||||
this.theBiomeDecorator.deadBushPerChunk = 1;
|
||||
this.theBiomeDecorator.mushroomsPerChunk = 8;
|
||||
this.theBiomeDecorator.reedsPerChunk = 10;
|
||||
this.theBiomeDecorator.clayPerChunk = 1;
|
||||
this.theBiomeDecorator.waterlilyPerChunk = 4;
|
||||
this.waterColorMultiplier = 14745518;
|
||||
this.spawnableMonsterList.add(new SpawnListEntry(EntitySlime.class, 1, 1, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a WorldGen appropriate for this biome.
|
||||
*/
|
||||
public WorldGenerator getRandomWorldGenForTrees(Random par1Random)
|
||||
{
|
||||
return this.worldGeneratorSwamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the basic grass color based on the biome temperature and rainfall
|
||||
*/
|
||||
public int getBiomeGrassColor()
|
||||
{
|
||||
double var1 = (double)this.getFloatTemperature();
|
||||
double var3 = (double)this.getFloatRainfall();
|
||||
return ((ColorizerGrass.getGrassColor(var1, var3) & 16711422) + 5115470) / 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the basic foliage color based on the biome temperature and rainfall
|
||||
*/
|
||||
public int getBiomeFoliageColor()
|
||||
{
|
||||
double var1 = (double)this.getFloatTemperature();
|
||||
double var3 = (double)this.getFloatRainfall();
|
||||
return ((ColorizerFoliage.getFoliageColor(var1, var3) & 16711422) + 5115470) / 2;
|
||||
}
|
||||
}
|
||||
22
src/main/java/net/minecraft/src/BiomeGenTaiga.java
Normal file
22
src/main/java/net/minecraft/src/BiomeGenTaiga.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BiomeGenTaiga extends BiomeGenBase
|
||||
{
|
||||
public BiomeGenTaiga(int par1)
|
||||
{
|
||||
super(par1);
|
||||
this.spawnableCreatureList.add(new SpawnListEntry(EntityWolf.class, 8, 4, 4));
|
||||
this.theBiomeDecorator.treesPerChunk = 10;
|
||||
this.theBiomeDecorator.grassPerChunk = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a WorldGen appropriate for this biome.
|
||||
*/
|
||||
public WorldGenerator getRandomWorldGenForTrees(Random par1Random)
|
||||
{
|
||||
return (WorldGenerator)(par1Random.nextInt(3) == 0 ? new WorldGenTaiga1() : new WorldGenTaiga2(false));
|
||||
}
|
||||
}
|
||||
1388
src/main/java/net/minecraft/src/Block.java
Normal file
1388
src/main/java/net/minecraft/src/Block.java
Normal file
File diff suppressed because it is too large
Load Diff
182
src/main/java/net/minecraft/src/BlockAnvil.java
Normal file
182
src/main/java/net/minecraft/src/BlockAnvil.java
Normal file
@@ -0,0 +1,182 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlockAnvil extends BlockSand
|
||||
{
|
||||
/** List of types/statues the Anvil can be in. */
|
||||
public static final String[] statuses = new String[] {"intact", "slightlyDamaged", "veryDamaged"};
|
||||
private static final String[] anvilIconNames = new String[] {"anvil_top_damaged_0", "anvil_top_damaged_1", "anvil_top_damaged_2"};
|
||||
public int field_82521_b;
|
||||
private Icon[] iconArray;
|
||||
|
||||
protected BlockAnvil(int par1)
|
||||
{
|
||||
super(par1, Material.anvil);
|
||||
this.setLightOpacity(0);
|
||||
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
if (this.field_82521_b == 3 && par1 == 1)
|
||||
{
|
||||
int var3 = (par2 >> 2) % this.iconArray.length;
|
||||
return this.iconArray[var3];
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.blockIcon;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon("anvil_base");
|
||||
this.iconArray = new Icon[anvilIconNames.length];
|
||||
|
||||
for (int var2 = 0; var2 < this.iconArray.length; ++var2)
|
||||
{
|
||||
this.iconArray[var2] = par1IconRegister.registerIcon(anvilIconNames[var2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is placed in the world.
|
||||
*/
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
|
||||
{
|
||||
int var7 = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
int var8 = par1World.getBlockMetadata(par2, par3, par4) >> 2;
|
||||
++var7;
|
||||
var7 %= 4;
|
||||
|
||||
if (var7 == 0)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 2 | var8 << 2, 2);
|
||||
}
|
||||
|
||||
if (var7 == 1)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 3 | var8 << 2, 2);
|
||||
}
|
||||
|
||||
if (var7 == 2)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 0 | var8 << 2, 2);
|
||||
}
|
||||
|
||||
if (var7 == 3)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 1 | var8 << 2, 2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called upon block activation (right click on the block.)
|
||||
*/
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if (par1World.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
par5EntityPlayer.displayGUIAnvil(par2, par3, par4);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
public int getRenderType()
|
||||
{
|
||||
return 35;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the damage on the item the block drops. Used in cloth and wood.
|
||||
*/
|
||||
public int damageDropped(int par1)
|
||||
{
|
||||
return par1 >> 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the blocks bounds based on its current state. Args: world, x, y, z
|
||||
*/
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4) & 3;
|
||||
|
||||
if (var5 != 3 && var5 != 1)
|
||||
{
|
||||
this.setBlockBounds(0.125F, 0.0F, 0.0F, 0.875F, 1.0F, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.125F, 1.0F, 1.0F, 0.875F);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||
*/
|
||||
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
par3List.add(new ItemStack(par1, 1, 0));
|
||||
par3List.add(new ItemStack(par1, 1, 1));
|
||||
par3List.add(new ItemStack(par1, 1, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the falling block entity for this block is created
|
||||
*/
|
||||
protected void onStartFalling(EntityFallingSand par1EntityFallingSand)
|
||||
{
|
||||
par1EntityFallingSand.setIsAnvil(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the falling block entity for this block hits the ground and turns back into a block
|
||||
*/
|
||||
public void onFinishFalling(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
par1World.playAuxSFX(1022, par2, par3, par4, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
|
||||
* coordinates. Args: blockAccess, x, y, z, side
|
||||
*/
|
||||
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
269
src/main/java/net/minecraft/src/BlockBasePressurePlate.java
Normal file
269
src/main/java/net/minecraft/src/BlockBasePressurePlate.java
Normal file
@@ -0,0 +1,269 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class BlockBasePressurePlate extends Block
|
||||
{
|
||||
private String pressurePlateIconName;
|
||||
|
||||
protected BlockBasePressurePlate(int par1, String par2Str, Material par3Material)
|
||||
{
|
||||
super(par1, par3Material);
|
||||
this.pressurePlateIconName = par2Str;
|
||||
this.setCreativeTab(CreativeTabs.tabRedstone);
|
||||
this.setTickRandomly(true);
|
||||
this.func_94353_c_(this.getMetaFromWeight(15));
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the blocks bounds based on its current state. Args: world, x, y, z
|
||||
*/
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
this.func_94353_c_(par1IBlockAccess.getBlockMetadata(par2, par3, par4));
|
||||
}
|
||||
|
||||
protected void func_94353_c_(int par1)
|
||||
{
|
||||
boolean var2 = this.getPowerSupply(par1) > 0;
|
||||
float var3 = 0.0625F;
|
||||
|
||||
if (var2)
|
||||
{
|
||||
this.setBlockBounds(var3, 0.0F, var3, 1.0F - var3, 0.03125F, 1.0F - var3);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(var3, 0.0F, var3, 1.0F - var3, 0.0625F, 1.0F - var3);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* How many world ticks before ticking
|
||||
*/
|
||||
public int tickRate(World par1World)
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
|
||||
* cleared to be reused)
|
||||
*/
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean getBlocksMovement(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
|
||||
*/
|
||||
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) || BlockFence.isIdAFence(par1World.getBlockId(par2, par3 - 1, par4));
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
||||
* their own) Args: x, y, z, neighbor blockID
|
||||
*/
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
boolean var6 = false;
|
||||
|
||||
if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) && !BlockFence.isIdAFence(par1World.getBlockId(par2, par3 - 1, par4)))
|
||||
{
|
||||
var6 = true;
|
||||
}
|
||||
|
||||
if (var6)
|
||||
{
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticks the block if it's been scheduled
|
||||
*/
|
||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
int var6 = this.getPowerSupply(par1World.getBlockMetadata(par2, par3, par4));
|
||||
|
||||
if (var6 > 0)
|
||||
{
|
||||
this.setStateIfMobInteractsWithPlate(par1World, par2, par3, par4, var6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity
|
||||
*/
|
||||
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
int var6 = this.getPowerSupply(par1World.getBlockMetadata(par2, par3, par4));
|
||||
|
||||
if (var6 == 0)
|
||||
{
|
||||
this.setStateIfMobInteractsWithPlate(par1World, par2, par3, par4, var6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there are mobs on the plate. If a mob is on the plate and it is off, it turns it on, and vice versa.
|
||||
*/
|
||||
protected void setStateIfMobInteractsWithPlate(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
int var6 = this.getPlateState(par1World, par2, par3, par4);
|
||||
boolean var7 = par5 > 0;
|
||||
boolean var8 = var6 > 0;
|
||||
|
||||
if (par5 != var6)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, this.getMetaFromWeight(var6), 2);
|
||||
this.func_94354_b_(par1World, par2, par3, par4);
|
||||
par1World.markBlockRangeForRenderUpdate(par2, par3, par4, par2, par3, par4);
|
||||
}
|
||||
|
||||
if (!var8 && var7)
|
||||
{
|
||||
par1World.playSoundEffect((double)par2 + 0.5D, (double)par3 + 0.1D, (double)par4 + 0.5D, "random.click", 0.3F, 0.5F);
|
||||
}
|
||||
else if (var8 && !var7)
|
||||
{
|
||||
par1World.playSoundEffect((double)par2 + 0.5D, (double)par3 + 0.1D, (double)par4 + 0.5D, "random.click", 0.3F, 0.6F);
|
||||
}
|
||||
|
||||
if (var8)
|
||||
{
|
||||
par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate(par1World));
|
||||
}
|
||||
}
|
||||
|
||||
protected AxisAlignedBB getSensitiveAABB(int par1, int par2, int par3)
|
||||
{
|
||||
float var4 = 0.125F;
|
||||
return AxisAlignedBB.getAABBPool().getAABB((double)((float)par1 + var4), (double)par2, (double)((float)par3 + var4), (double)((float)(par1 + 1) - var4), (double)par2 + 0.25D, (double)((float)(par3 + 1) - var4));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on server worlds only when the block has been replaced by a different block ID, or the same block with a
|
||||
* different metadata value, but before the new metadata value is set. Args: World, x, y, z, old block ID, old
|
||||
* metadata
|
||||
*/
|
||||
public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
if (this.getPowerSupply(par6) > 0)
|
||||
{
|
||||
this.func_94354_b_(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
super.breakBlock(par1World, par2, par3, par4, par5, par6);
|
||||
}
|
||||
|
||||
protected void func_94354_b_(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this.blockID);
|
||||
par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this.blockID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the block is emitting indirect/weak redstone power on the specified side. If isBlockNormalCube
|
||||
* returns true, standard redstone propagation rules will apply instead and this will not be called. Args: World, X,
|
||||
* Y, Z, side. Note that the side is reversed - eg it is 1 (up) when checking the bottom of the block.
|
||||
*/
|
||||
public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return this.getPowerSupply(par1IBlockAccess.getBlockMetadata(par2, par3, par4));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the block is emitting direct/strong redstone power on the specified side. Args: World, X, Y, Z,
|
||||
* side. Note that the side is reversed - eg it is 1 (up) when checking the bottom of the block.
|
||||
*/
|
||||
public int isProvidingStrongPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return par5 == 1 ? this.getPowerSupply(par1IBlockAccess.getBlockMetadata(par2, par3, par4)) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can this block provide power. Only wire currently seems to have this change based on its state.
|
||||
*/
|
||||
public boolean canProvidePower()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the block's bounds for rendering it as an item
|
||||
*/
|
||||
public void setBlockBoundsForItemRender()
|
||||
{
|
||||
float var1 = 0.5F;
|
||||
float var2 = 0.125F;
|
||||
float var3 = 0.5F;
|
||||
this.setBlockBounds(0.5F - var1, 0.5F - var2, 0.5F - var3, 0.5F + var1, 0.5F + var2, 0.5F + var3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mobility information of the block, 0 = free, 1 = can't push but can move over, 2 = total immobility
|
||||
* and stop pistons
|
||||
*/
|
||||
public int getMobilityFlag()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current state of the pressure plate. Returns a value between 0 and 15 based on the number of items on
|
||||
* it.
|
||||
*/
|
||||
protected abstract int getPlateState(World var1, int var2, int var3, int var4);
|
||||
|
||||
/**
|
||||
* Argument is metadata. Returns power level (0-15)
|
||||
*/
|
||||
protected abstract int getPowerSupply(int var1);
|
||||
|
||||
/**
|
||||
* Argument is weight (0-15). Return the metadata to be set because of it.
|
||||
*/
|
||||
protected abstract int getMetaFromWeight(int var1);
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(this.pressurePlateIconName);
|
||||
}
|
||||
}
|
||||
450
src/main/java/net/minecraft/src/BlockBaseRailLogic.java
Normal file
450
src/main/java/net/minecraft/src/BlockBaseRailLogic.java
Normal file
@@ -0,0 +1,450 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockBaseRailLogic
|
||||
{
|
||||
private World logicWorld;
|
||||
private int railX;
|
||||
private int railY;
|
||||
private int railZ;
|
||||
private final boolean isStraightRail;
|
||||
|
||||
/** The chunk position the rail is at. */
|
||||
private List railChunkPosition;
|
||||
|
||||
final BlockRailBase theRail;
|
||||
|
||||
public BlockBaseRailLogic(BlockRailBase par1BlockRailBase, World par2World, int par3, int par4, int par5)
|
||||
{
|
||||
this.theRail = par1BlockRailBase;
|
||||
this.railChunkPosition = new ArrayList();
|
||||
this.logicWorld = par2World;
|
||||
this.railX = par3;
|
||||
this.railY = par4;
|
||||
this.railZ = par5;
|
||||
int var6 = par2World.getBlockId(par3, par4, par5);
|
||||
int var7 = par2World.getBlockMetadata(par3, par4, par5);
|
||||
|
||||
if (((BlockRailBase)Block.blocksList[var6]).isPowered)
|
||||
{
|
||||
this.isStraightRail = true;
|
||||
var7 &= -9;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isStraightRail = false;
|
||||
}
|
||||
|
||||
this.setBasicRail(var7);
|
||||
}
|
||||
|
||||
private void setBasicRail(int par1)
|
||||
{
|
||||
this.railChunkPosition.clear();
|
||||
|
||||
if (par1 == 0)
|
||||
{
|
||||
this.railChunkPosition.add(new ChunkPosition(this.railX, this.railY, this.railZ - 1));
|
||||
this.railChunkPosition.add(new ChunkPosition(this.railX, this.railY, this.railZ + 1));
|
||||
}
|
||||
else if (par1 == 1)
|
||||
{
|
||||
this.railChunkPosition.add(new ChunkPosition(this.railX - 1, this.railY, this.railZ));
|
||||
this.railChunkPosition.add(new ChunkPosition(this.railX + 1, this.railY, this.railZ));
|
||||
}
|
||||
else if (par1 == 2)
|
||||
{
|
||||
this.railChunkPosition.add(new ChunkPosition(this.railX - 1, this.railY, this.railZ));
|
||||
this.railChunkPosition.add(new ChunkPosition(this.railX + 1, this.railY + 1, this.railZ));
|
||||
}
|
||||
else if (par1 == 3)
|
||||
{
|
||||
this.railChunkPosition.add(new ChunkPosition(this.railX - 1, this.railY + 1, this.railZ));
|
||||
this.railChunkPosition.add(new ChunkPosition(this.railX + 1, this.railY, this.railZ));
|
||||
}
|
||||
else if (par1 == 4)
|
||||
{
|
||||
this.railChunkPosition.add(new ChunkPosition(this.railX, this.railY + 1, this.railZ - 1));
|
||||
this.railChunkPosition.add(new ChunkPosition(this.railX, this.railY, this.railZ + 1));
|
||||
}
|
||||
else if (par1 == 5)
|
||||
{
|
||||
this.railChunkPosition.add(new ChunkPosition(this.railX, this.railY, this.railZ - 1));
|
||||
this.railChunkPosition.add(new ChunkPosition(this.railX, this.railY + 1, this.railZ + 1));
|
||||
}
|
||||
else if (par1 == 6)
|
||||
{
|
||||
this.railChunkPosition.add(new ChunkPosition(this.railX + 1, this.railY, this.railZ));
|
||||
this.railChunkPosition.add(new ChunkPosition(this.railX, this.railY, this.railZ + 1));
|
||||
}
|
||||
else if (par1 == 7)
|
||||
{
|
||||
this.railChunkPosition.add(new ChunkPosition(this.railX - 1, this.railY, this.railZ));
|
||||
this.railChunkPosition.add(new ChunkPosition(this.railX, this.railY, this.railZ + 1));
|
||||
}
|
||||
else if (par1 == 8)
|
||||
{
|
||||
this.railChunkPosition.add(new ChunkPosition(this.railX - 1, this.railY, this.railZ));
|
||||
this.railChunkPosition.add(new ChunkPosition(this.railX, this.railY, this.railZ - 1));
|
||||
}
|
||||
else if (par1 == 9)
|
||||
{
|
||||
this.railChunkPosition.add(new ChunkPosition(this.railX + 1, this.railY, this.railZ));
|
||||
this.railChunkPosition.add(new ChunkPosition(this.railX, this.railY, this.railZ - 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshConnectedTracks()
|
||||
{
|
||||
for (int var1 = 0; var1 < this.railChunkPosition.size(); ++var1)
|
||||
{
|
||||
BlockBaseRailLogic var2 = this.getRailLogic((ChunkPosition)this.railChunkPosition.get(var1));
|
||||
|
||||
if (var2 != null && var2.isRailChunkPositionCorrect(this))
|
||||
{
|
||||
this.railChunkPosition.set(var1, new ChunkPosition(var2.railX, var2.railY, var2.railZ));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.railChunkPosition.remove(var1--);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isMinecartTrack(int par1, int par2, int par3)
|
||||
{
|
||||
return BlockRailBase.isRailBlockAt(this.logicWorld, par1, par2, par3) ? true : (BlockRailBase.isRailBlockAt(this.logicWorld, par1, par2 + 1, par3) ? true : BlockRailBase.isRailBlockAt(this.logicWorld, par1, par2 - 1, par3));
|
||||
}
|
||||
|
||||
private BlockBaseRailLogic getRailLogic(ChunkPosition par1ChunkPosition)
|
||||
{
|
||||
return BlockRailBase.isRailBlockAt(this.logicWorld, par1ChunkPosition.x, par1ChunkPosition.y, par1ChunkPosition.z) ? new BlockBaseRailLogic(this.theRail, this.logicWorld, par1ChunkPosition.x, par1ChunkPosition.y, par1ChunkPosition.z) : (BlockRailBase.isRailBlockAt(this.logicWorld, par1ChunkPosition.x, par1ChunkPosition.y + 1, par1ChunkPosition.z) ? new BlockBaseRailLogic(this.theRail, this.logicWorld, par1ChunkPosition.x, par1ChunkPosition.y + 1, par1ChunkPosition.z) : (BlockRailBase.isRailBlockAt(this.logicWorld, par1ChunkPosition.x, par1ChunkPosition.y - 1, par1ChunkPosition.z) ? new BlockBaseRailLogic(this.theRail, this.logicWorld, par1ChunkPosition.x, par1ChunkPosition.y - 1, par1ChunkPosition.z) : null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the rail is at the chunk position it is expected to be.
|
||||
*/
|
||||
private boolean isRailChunkPositionCorrect(BlockBaseRailLogic par1BlockBaseRailLogic)
|
||||
{
|
||||
for (int var2 = 0; var2 < this.railChunkPosition.size(); ++var2)
|
||||
{
|
||||
ChunkPosition var3 = (ChunkPosition)this.railChunkPosition.get(var2);
|
||||
|
||||
if (var3.x == par1BlockBaseRailLogic.railX && var3.z == par1BlockBaseRailLogic.railZ)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isPartOfTrack(int par1, int par2, int par3)
|
||||
{
|
||||
for (int var4 = 0; var4 < this.railChunkPosition.size(); ++var4)
|
||||
{
|
||||
ChunkPosition var5 = (ChunkPosition)this.railChunkPosition.get(var4);
|
||||
|
||||
if (var5.x == par1 && var5.z == par3)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected int getNumberOfAdjacentTracks()
|
||||
{
|
||||
int var1 = 0;
|
||||
|
||||
if (this.isMinecartTrack(this.railX, this.railY, this.railZ - 1))
|
||||
{
|
||||
++var1;
|
||||
}
|
||||
|
||||
if (this.isMinecartTrack(this.railX, this.railY, this.railZ + 1))
|
||||
{
|
||||
++var1;
|
||||
}
|
||||
|
||||
if (this.isMinecartTrack(this.railX - 1, this.railY, this.railZ))
|
||||
{
|
||||
++var1;
|
||||
}
|
||||
|
||||
if (this.isMinecartTrack(this.railX + 1, this.railY, this.railZ))
|
||||
{
|
||||
++var1;
|
||||
}
|
||||
|
||||
return var1;
|
||||
}
|
||||
|
||||
private boolean canConnectTo(BlockBaseRailLogic par1BlockBaseRailLogic)
|
||||
{
|
||||
return this.isRailChunkPositionCorrect(par1BlockBaseRailLogic) ? true : (this.railChunkPosition.size() == 2 ? false : (this.railChunkPosition.isEmpty() ? true : true));
|
||||
}
|
||||
|
||||
private void connectToNeighbor(BlockBaseRailLogic par1BlockBaseRailLogic)
|
||||
{
|
||||
this.railChunkPosition.add(new ChunkPosition(par1BlockBaseRailLogic.railX, par1BlockBaseRailLogic.railY, par1BlockBaseRailLogic.railZ));
|
||||
boolean var2 = this.isPartOfTrack(this.railX, this.railY, this.railZ - 1);
|
||||
boolean var3 = this.isPartOfTrack(this.railX, this.railY, this.railZ + 1);
|
||||
boolean var4 = this.isPartOfTrack(this.railX - 1, this.railY, this.railZ);
|
||||
boolean var5 = this.isPartOfTrack(this.railX + 1, this.railY, this.railZ);
|
||||
byte var6 = -1;
|
||||
|
||||
if (var2 || var3)
|
||||
{
|
||||
var6 = 0;
|
||||
}
|
||||
|
||||
if (var4 || var5)
|
||||
{
|
||||
var6 = 1;
|
||||
}
|
||||
|
||||
if (!this.isStraightRail)
|
||||
{
|
||||
if (var3 && var5 && !var2 && !var4)
|
||||
{
|
||||
var6 = 6;
|
||||
}
|
||||
|
||||
if (var3 && var4 && !var2 && !var5)
|
||||
{
|
||||
var6 = 7;
|
||||
}
|
||||
|
||||
if (var2 && var4 && !var3 && !var5)
|
||||
{
|
||||
var6 = 8;
|
||||
}
|
||||
|
||||
if (var2 && var5 && !var3 && !var4)
|
||||
{
|
||||
var6 = 9;
|
||||
}
|
||||
}
|
||||
|
||||
if (var6 == 0)
|
||||
{
|
||||
if (BlockRailBase.isRailBlockAt(this.logicWorld, this.railX, this.railY + 1, this.railZ - 1))
|
||||
{
|
||||
var6 = 4;
|
||||
}
|
||||
|
||||
if (BlockRailBase.isRailBlockAt(this.logicWorld, this.railX, this.railY + 1, this.railZ + 1))
|
||||
{
|
||||
var6 = 5;
|
||||
}
|
||||
}
|
||||
|
||||
if (var6 == 1)
|
||||
{
|
||||
if (BlockRailBase.isRailBlockAt(this.logicWorld, this.railX + 1, this.railY + 1, this.railZ))
|
||||
{
|
||||
var6 = 2;
|
||||
}
|
||||
|
||||
if (BlockRailBase.isRailBlockAt(this.logicWorld, this.railX - 1, this.railY + 1, this.railZ))
|
||||
{
|
||||
var6 = 3;
|
||||
}
|
||||
}
|
||||
|
||||
if (var6 < 0)
|
||||
{
|
||||
var6 = 0;
|
||||
}
|
||||
|
||||
int var7 = var6;
|
||||
|
||||
if (this.isStraightRail)
|
||||
{
|
||||
var7 = this.logicWorld.getBlockMetadata(this.railX, this.railY, this.railZ) & 8 | var6;
|
||||
}
|
||||
|
||||
this.logicWorld.setBlockMetadataWithNotify(this.railX, this.railY, this.railZ, var7, 3);
|
||||
}
|
||||
|
||||
private boolean canConnectFrom(int par1, int par2, int par3)
|
||||
{
|
||||
BlockBaseRailLogic var4 = this.getRailLogic(new ChunkPosition(par1, par2, par3));
|
||||
|
||||
if (var4 == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
var4.refreshConnectedTracks();
|
||||
return var4.canConnectTo(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void func_94511_a(boolean par1, boolean par2)
|
||||
{
|
||||
boolean var3 = this.canConnectFrom(this.railX, this.railY, this.railZ - 1);
|
||||
boolean var4 = this.canConnectFrom(this.railX, this.railY, this.railZ + 1);
|
||||
boolean var5 = this.canConnectFrom(this.railX - 1, this.railY, this.railZ);
|
||||
boolean var6 = this.canConnectFrom(this.railX + 1, this.railY, this.railZ);
|
||||
byte var7 = -1;
|
||||
|
||||
if ((var3 || var4) && !var5 && !var6)
|
||||
{
|
||||
var7 = 0;
|
||||
}
|
||||
|
||||
if ((var5 || var6) && !var3 && !var4)
|
||||
{
|
||||
var7 = 1;
|
||||
}
|
||||
|
||||
if (!this.isStraightRail)
|
||||
{
|
||||
if (var4 && var6 && !var3 && !var5)
|
||||
{
|
||||
var7 = 6;
|
||||
}
|
||||
|
||||
if (var4 && var5 && !var3 && !var6)
|
||||
{
|
||||
var7 = 7;
|
||||
}
|
||||
|
||||
if (var3 && var5 && !var4 && !var6)
|
||||
{
|
||||
var7 = 8;
|
||||
}
|
||||
|
||||
if (var3 && var6 && !var4 && !var5)
|
||||
{
|
||||
var7 = 9;
|
||||
}
|
||||
}
|
||||
|
||||
if (var7 == -1)
|
||||
{
|
||||
if (var3 || var4)
|
||||
{
|
||||
var7 = 0;
|
||||
}
|
||||
|
||||
if (var5 || var6)
|
||||
{
|
||||
var7 = 1;
|
||||
}
|
||||
|
||||
if (!this.isStraightRail)
|
||||
{
|
||||
if (par1)
|
||||
{
|
||||
if (var4 && var6)
|
||||
{
|
||||
var7 = 6;
|
||||
}
|
||||
|
||||
if (var5 && var4)
|
||||
{
|
||||
var7 = 7;
|
||||
}
|
||||
|
||||
if (var6 && var3)
|
||||
{
|
||||
var7 = 9;
|
||||
}
|
||||
|
||||
if (var3 && var5)
|
||||
{
|
||||
var7 = 8;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (var3 && var5)
|
||||
{
|
||||
var7 = 8;
|
||||
}
|
||||
|
||||
if (var6 && var3)
|
||||
{
|
||||
var7 = 9;
|
||||
}
|
||||
|
||||
if (var5 && var4)
|
||||
{
|
||||
var7 = 7;
|
||||
}
|
||||
|
||||
if (var4 && var6)
|
||||
{
|
||||
var7 = 6;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (var7 == 0)
|
||||
{
|
||||
if (BlockRailBase.isRailBlockAt(this.logicWorld, this.railX, this.railY + 1, this.railZ - 1))
|
||||
{
|
||||
var7 = 4;
|
||||
}
|
||||
|
||||
if (BlockRailBase.isRailBlockAt(this.logicWorld, this.railX, this.railY + 1, this.railZ + 1))
|
||||
{
|
||||
var7 = 5;
|
||||
}
|
||||
}
|
||||
|
||||
if (var7 == 1)
|
||||
{
|
||||
if (BlockRailBase.isRailBlockAt(this.logicWorld, this.railX + 1, this.railY + 1, this.railZ))
|
||||
{
|
||||
var7 = 2;
|
||||
}
|
||||
|
||||
if (BlockRailBase.isRailBlockAt(this.logicWorld, this.railX - 1, this.railY + 1, this.railZ))
|
||||
{
|
||||
var7 = 3;
|
||||
}
|
||||
}
|
||||
|
||||
if (var7 < 0)
|
||||
{
|
||||
var7 = 0;
|
||||
}
|
||||
|
||||
this.setBasicRail(var7);
|
||||
int var8 = var7;
|
||||
|
||||
if (this.isStraightRail)
|
||||
{
|
||||
var8 = this.logicWorld.getBlockMetadata(this.railX, this.railY, this.railZ) & 8 | var7;
|
||||
}
|
||||
|
||||
if (par2 || this.logicWorld.getBlockMetadata(this.railX, this.railY, this.railZ) != var8)
|
||||
{
|
||||
this.logicWorld.setBlockMetadataWithNotify(this.railX, this.railY, this.railZ, var8, 3);
|
||||
|
||||
for (int var9 = 0; var9 < this.railChunkPosition.size(); ++var9)
|
||||
{
|
||||
BlockBaseRailLogic var10 = this.getRailLogic((ChunkPosition)this.railChunkPosition.get(var9));
|
||||
|
||||
if (var10 != null)
|
||||
{
|
||||
var10.refreshConnectedTracks();
|
||||
|
||||
if (var10.canConnectTo(this))
|
||||
{
|
||||
var10.connectToNeighbor(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
88
src/main/java/net/minecraft/src/BlockBeacon.java
Normal file
88
src/main/java/net/minecraft/src/BlockBeacon.java
Normal file
@@ -0,0 +1,88 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class BlockBeacon extends BlockContainer
|
||||
{
|
||||
public BlockBeacon(int par1)
|
||||
{
|
||||
super(par1, Material.glass);
|
||||
this.setHardness(3.0F);
|
||||
this.setCreativeTab(CreativeTabs.tabMisc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||
*/
|
||||
public TileEntity createNewTileEntity(World par1World)
|
||||
{
|
||||
return new TileEntityBeacon();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called upon block activation (right click on the block.)
|
||||
*/
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if (par1World.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
TileEntityBeacon var10 = (TileEntityBeacon)par1World.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
if (var10 != null)
|
||||
{
|
||||
par5EntityPlayer.displayGUIBeacon(var10);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
public int getRenderType()
|
||||
{
|
||||
return 34;
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
super.registerIcons(par1IconRegister);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is placed in the world.
|
||||
*/
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
|
||||
{
|
||||
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
|
||||
|
||||
if (par6ItemStack.hasDisplayName())
|
||||
{
|
||||
((TileEntityBeacon)par1World.getBlockTileEntity(par2, par3, par4)).func_94047_a(par6ItemStack.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
343
src/main/java/net/minecraft/src/BlockBed.java
Normal file
343
src/main/java/net/minecraft/src/BlockBed.java
Normal file
@@ -0,0 +1,343 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockBed extends BlockDirectional
|
||||
{
|
||||
/** Maps the foot-of-bed block to the head-of-bed block. */
|
||||
public static final int[][] footBlockToHeadBlockMap = new int[][] {{0, 1}, { -1, 0}, {0, -1}, {1, 0}};
|
||||
private Icon[] field_94472_b;
|
||||
private Icon[] bedSideIcons;
|
||||
private Icon[] bedTopIcons;
|
||||
|
||||
public BlockBed(int par1)
|
||||
{
|
||||
super(par1, Material.cloth);
|
||||
this.setBounds();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called upon block activation (right click on the block.)
|
||||
*/
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if (par1World.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int var10 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
if (!isBlockHeadOfBed(var10))
|
||||
{
|
||||
int var11 = getDirection(var10);
|
||||
par2 += footBlockToHeadBlockMap[var11][0];
|
||||
par4 += footBlockToHeadBlockMap[var11][1];
|
||||
|
||||
if (par1World.getBlockId(par2, par3, par4) != this.blockID)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var10 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
}
|
||||
|
||||
if (par1World.provider.canRespawnHere() && par1World.getBiomeGenForCoords(par2, par4) != BiomeGenBase.hell)
|
||||
{
|
||||
if (isBedOccupied(var10))
|
||||
{
|
||||
EntityPlayer var19 = null;
|
||||
Iterator var12 = par1World.playerEntities.iterator();
|
||||
|
||||
while (var12.hasNext())
|
||||
{
|
||||
EntityPlayer var21 = (EntityPlayer)var12.next();
|
||||
|
||||
if (var21.isPlayerSleeping())
|
||||
{
|
||||
ChunkCoordinates var14 = var21.playerLocation;
|
||||
|
||||
if (var14.posX == par2 && var14.posY == par3 && var14.posZ == par4)
|
||||
{
|
||||
var19 = var21;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (var19 != null)
|
||||
{
|
||||
par5EntityPlayer.addChatMessage("tile.bed.occupied");
|
||||
return true;
|
||||
}
|
||||
|
||||
setBedOccupied(par1World, par2, par3, par4, false);
|
||||
}
|
||||
|
||||
EnumStatus var20 = par5EntityPlayer.sleepInBedAt(par2, par3, par4);
|
||||
|
||||
if (var20 == EnumStatus.OK)
|
||||
{
|
||||
setBedOccupied(par1World, par2, par3, par4, true);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (var20 == EnumStatus.NOT_POSSIBLE_NOW)
|
||||
{
|
||||
par5EntityPlayer.addChatMessage("tile.bed.noSleep");
|
||||
}
|
||||
else if (var20 == EnumStatus.NOT_SAFE)
|
||||
{
|
||||
par5EntityPlayer.addChatMessage("tile.bed.notSafe");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
double var18 = (double)par2 + 0.5D;
|
||||
double var13 = (double)par3 + 0.5D;
|
||||
double var15 = (double)par4 + 0.5D;
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
int var17 = getDirection(var10);
|
||||
par2 += footBlockToHeadBlockMap[var17][0];
|
||||
par4 += footBlockToHeadBlockMap[var17][1];
|
||||
|
||||
if (par1World.getBlockId(par2, par3, par4) == this.blockID)
|
||||
{
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
var18 = (var18 + (double)par2 + 0.5D) / 2.0D;
|
||||
var13 = (var13 + (double)par3 + 0.5D) / 2.0D;
|
||||
var15 = (var15 + (double)par4 + 0.5D) / 2.0D;
|
||||
}
|
||||
|
||||
par1World.newExplosion((Entity)null, (double)((float)par2 + 0.5F), (double)((float)par3 + 0.5F), (double)((float)par4 + 0.5F), 5.0F, true, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
if (par1 == 0)
|
||||
{
|
||||
return Block.planks.getBlockTextureFromSide(par1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int var3 = getDirection(par2);
|
||||
int var4 = Direction.bedDirection[var3][par1];
|
||||
int var5 = isBlockHeadOfBed(par2) ? 1 : 0;
|
||||
return (var5 != 1 || var4 != 2) && (var5 != 0 || var4 != 3) ? (var4 != 5 && var4 != 4 ? this.bedTopIcons[var5] : this.bedSideIcons[var5]) : this.field_94472_b[var5];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.bedTopIcons = new Icon[] {par1IconRegister.registerIcon(this.getTextureName() + "_feet_top"), par1IconRegister.registerIcon(this.getTextureName() + "_head_top")};
|
||||
this.field_94472_b = new Icon[] {par1IconRegister.registerIcon(this.getTextureName() + "_feet_end"), par1IconRegister.registerIcon(this.getTextureName() + "_head_end")};
|
||||
this.bedSideIcons = new Icon[] {par1IconRegister.registerIcon(this.getTextureName() + "_feet_side"), par1IconRegister.registerIcon(this.getTextureName() + "_head_side")};
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
public int getRenderType()
|
||||
{
|
||||
return 14;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the blocks bounds based on its current state. Args: world, x, y, z
|
||||
*/
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
this.setBounds();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
||||
* their own) Args: x, y, z, neighbor blockID
|
||||
*/
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
int var6 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
int var7 = getDirection(var6);
|
||||
|
||||
if (isBlockHeadOfBed(var6))
|
||||
{
|
||||
if (par1World.getBlockId(par2 - footBlockToHeadBlockMap[var7][0], par3, par4 - footBlockToHeadBlockMap[var7][1]) != this.blockID)
|
||||
{
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
}
|
||||
}
|
||||
else if (par1World.getBlockId(par2 + footBlockToHeadBlockMap[var7][0], par3, par4 + footBlockToHeadBlockMap[var7][1]) != this.blockID)
|
||||
{
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, var6, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the items to drop on destruction.
|
||||
*/
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return isBlockHeadOfBed(par1) ? 0 : Item.bed.itemID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the bounds of the bed block.
|
||||
*/
|
||||
private void setBounds()
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5625F, 1.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not this bed block is the head of the bed.
|
||||
*/
|
||||
public static boolean isBlockHeadOfBed(int par0)
|
||||
{
|
||||
return (par0 & 8) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether or not the bed is occupied.
|
||||
*/
|
||||
public static boolean isBedOccupied(int par0)
|
||||
{
|
||||
return (par0 & 4) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether or not the bed is occupied.
|
||||
*/
|
||||
public static void setBedOccupied(World par0World, int par1, int par2, int par3, boolean par4)
|
||||
{
|
||||
int var5 = par0World.getBlockMetadata(par1, par2, par3);
|
||||
|
||||
if (par4)
|
||||
{
|
||||
var5 |= 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
var5 &= -5;
|
||||
}
|
||||
|
||||
par0World.setBlockMetadataWithNotify(par1, par2, par3, var5, 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the nearest empty chunk coordinates for the player to wake up from a bed into.
|
||||
*/
|
||||
public static ChunkCoordinates getNearestEmptyChunkCoordinates(World par0World, int par1, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = par0World.getBlockMetadata(par1, par2, par3);
|
||||
int var6 = BlockDirectional.getDirection(var5);
|
||||
|
||||
for (int var7 = 0; var7 <= 1; ++var7)
|
||||
{
|
||||
int var8 = par1 - footBlockToHeadBlockMap[var6][0] * var7 - 1;
|
||||
int var9 = par3 - footBlockToHeadBlockMap[var6][1] * var7 - 1;
|
||||
int var10 = var8 + 2;
|
||||
int var11 = var9 + 2;
|
||||
|
||||
for (int var12 = var8; var12 <= var10; ++var12)
|
||||
{
|
||||
for (int var13 = var9; var13 <= var11; ++var13)
|
||||
{
|
||||
if (par0World.doesBlockHaveSolidTopSurface(var12, par2 - 1, var13) && !par0World.getBlockMaterial(var12, par2, var13).isOpaque() && !par0World.getBlockMaterial(var12, par2 + 1, var13).isOpaque())
|
||||
{
|
||||
if (par4 <= 0)
|
||||
{
|
||||
return new ChunkCoordinates(var12, par2, var13);
|
||||
}
|
||||
|
||||
--par4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops the block items with a specified chance of dropping the specified items
|
||||
*/
|
||||
public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7)
|
||||
{
|
||||
if (!isBlockHeadOfBed(par5))
|
||||
{
|
||||
super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mobility information of the block, 0 = free, 1 = can't push but can move over, 2 = total immobility
|
||||
* and stop pistons
|
||||
*/
|
||||
public int getMobilityFlag()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
|
||||
*/
|
||||
public int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return Item.bed.itemID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is attempted to be harvested
|
||||
*/
|
||||
public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer)
|
||||
{
|
||||
if (par6EntityPlayer.capabilities.isCreativeMode && isBlockHeadOfBed(par5))
|
||||
{
|
||||
int var7 = getDirection(par5);
|
||||
par2 -= footBlockToHeadBlockMap[var7][0];
|
||||
par4 -= footBlockToHeadBlockMap[var7][1];
|
||||
|
||||
if (par1World.getBlockId(par2, par3, par4) == this.blockID)
|
||||
{
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
src/main/java/net/minecraft/src/BlockBookshelf.java
Normal file
36
src/main/java/net/minecraft/src/BlockBookshelf.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockBookshelf extends Block
|
||||
{
|
||||
public BlockBookshelf(int par1)
|
||||
{
|
||||
super(par1, Material.wood);
|
||||
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||
}
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return par1 != 1 && par1 != 0 ? super.getIcon(par1, par2) : Block.planks.getBlockTextureFromSide(par1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quantity of items to drop on block destruction.
|
||||
*/
|
||||
public int quantityDropped(Random par1Random)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the items to drop on destruction.
|
||||
*/
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return Item.book.itemID;
|
||||
}
|
||||
}
|
||||
42
src/main/java/net/minecraft/src/BlockBreakable.java
Normal file
42
src/main/java/net/minecraft/src/BlockBreakable.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class BlockBreakable extends Block
|
||||
{
|
||||
private boolean localFlag;
|
||||
private String breakableBlockIcon;
|
||||
|
||||
protected BlockBreakable(int par1, String par2Str, Material par3Material, boolean par4)
|
||||
{
|
||||
super(par1, par3Material);
|
||||
this.localFlag = par4;
|
||||
this.breakableBlockIcon = par2Str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
|
||||
* coordinates. Args: blockAccess, x, y, z, side
|
||||
*/
|
||||
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
int var6 = par1IBlockAccess.getBlockId(par2, par3, par4);
|
||||
return !this.localFlag && var6 == this.blockID ? false : super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5);
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(this.breakableBlockIcon);
|
||||
}
|
||||
}
|
||||
208
src/main/java/net/minecraft/src/BlockBrewingStand.java
Normal file
208
src/main/java/net/minecraft/src/BlockBrewingStand.java
Normal file
@@ -0,0 +1,208 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockBrewingStand extends BlockContainer
|
||||
{
|
||||
private Random rand = new Random();
|
||||
private Icon theIcon;
|
||||
|
||||
public BlockBrewingStand(int par1)
|
||||
{
|
||||
super(par1, Material.iron);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
public int getRenderType()
|
||||
{
|
||||
return 25;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||
*/
|
||||
public TileEntity createNewTileEntity(World par1World)
|
||||
{
|
||||
return new TileEntityBrewingStand();
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the list if they intersect the
|
||||
* mask.) Parameters: World, X, Y, Z, mask, list, colliding entity
|
||||
*/
|
||||
public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
|
||||
{
|
||||
this.setBlockBounds(0.4375F, 0.0F, 0.4375F, 0.5625F, 0.875F, 0.5625F);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
this.setBlockBoundsForItemRender();
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the block's bounds for rendering it as an item
|
||||
*/
|
||||
public void setBlockBoundsForItemRender()
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called upon block activation (right click on the block.)
|
||||
*/
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if (par1World.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
TileEntityBrewingStand var10 = (TileEntityBrewingStand)par1World.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
if (var10 != null)
|
||||
{
|
||||
par5EntityPlayer.displayGUIBrewingStand(var10);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is placed in the world.
|
||||
*/
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
|
||||
{
|
||||
if (par6ItemStack.hasDisplayName())
|
||||
{
|
||||
((TileEntityBrewingStand)par1World.getBlockTileEntity(par2, par3, par4)).func_94131_a(par6ItemStack.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A randomly called display update to be able to add particles or other items for display
|
||||
*/
|
||||
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
double var6 = (double)((float)par2 + 0.4F + par5Random.nextFloat() * 0.2F);
|
||||
double var8 = (double)((float)par3 + 0.7F + par5Random.nextFloat() * 0.3F);
|
||||
double var10 = (double)((float)par4 + 0.4F + par5Random.nextFloat() * 0.2F);
|
||||
par1World.spawnParticle("smoke", var6, var8, var10, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on server worlds only when the block has been replaced by a different block ID, or the same block with a
|
||||
* different metadata value, but before the new metadata value is set. Args: World, x, y, z, old block ID, old
|
||||
* metadata
|
||||
*/
|
||||
public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
TileEntity var7 = par1World.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
if (var7 instanceof TileEntityBrewingStand)
|
||||
{
|
||||
TileEntityBrewingStand var8 = (TileEntityBrewingStand)var7;
|
||||
|
||||
for (int var9 = 0; var9 < var8.getSizeInventory(); ++var9)
|
||||
{
|
||||
ItemStack var10 = var8.getStackInSlot(var9);
|
||||
|
||||
if (var10 != null)
|
||||
{
|
||||
float var11 = this.rand.nextFloat() * 0.8F + 0.1F;
|
||||
float var12 = this.rand.nextFloat() * 0.8F + 0.1F;
|
||||
float var13 = this.rand.nextFloat() * 0.8F + 0.1F;
|
||||
|
||||
while (var10.stackSize > 0)
|
||||
{
|
||||
int var14 = this.rand.nextInt(21) + 10;
|
||||
|
||||
if (var14 > var10.stackSize)
|
||||
{
|
||||
var14 = var10.stackSize;
|
||||
}
|
||||
|
||||
var10.stackSize -= var14;
|
||||
EntityItem var15 = new EntityItem(par1World, (double)((float)par2 + var11), (double)((float)par3 + var12), (double)((float)par4 + var13), new ItemStack(var10.itemID, var14, var10.getItemDamage()));
|
||||
float var16 = 0.05F;
|
||||
var15.motionX = (double)((float)this.rand.nextGaussian() * var16);
|
||||
var15.motionY = (double)((float)this.rand.nextGaussian() * var16 + 0.2F);
|
||||
var15.motionZ = (double)((float)this.rand.nextGaussian() * var16);
|
||||
par1World.spawnEntityInWorld(var15);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(par1World, par2, par3, par4, par5, par6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the items to drop on destruction.
|
||||
*/
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return Item.brewingStand.itemID;
|
||||
}
|
||||
|
||||
/**
|
||||
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
|
||||
*/
|
||||
public int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return Item.brewingStand.itemID;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this returns true, then comparators facing away from this block will use the value from
|
||||
* getComparatorInputOverride instead of the actual redstone signal strength.
|
||||
*/
|
||||
public boolean hasComparatorInputOverride()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* If hasComparatorInputOverride returns true, the return value from this is used instead of the redstone signal
|
||||
* strength when this block inputs to a comparator.
|
||||
*/
|
||||
public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return Container.calcRedstoneFromInventory((IInventory)par1World.getBlockTileEntity(par2, par3, par4));
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
super.registerIcons(par1IconRegister);
|
||||
this.theIcon = par1IconRegister.registerIcon(this.getTextureName() + "_base");
|
||||
}
|
||||
|
||||
public Icon getBrewingStandIcon()
|
||||
{
|
||||
return this.theIcon;
|
||||
}
|
||||
}
|
||||
406
src/main/java/net/minecraft/src/BlockButton.java
Normal file
406
src/main/java/net/minecraft/src/BlockButton.java
Normal file
@@ -0,0 +1,406 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class BlockButton extends Block
|
||||
{
|
||||
/** Whether this button is sensible to arrows, used by wooden buttons. */
|
||||
private final boolean sensible;
|
||||
|
||||
protected BlockButton(int par1, boolean par2)
|
||||
{
|
||||
super(par1, Material.circuits);
|
||||
this.setTickRandomly(true);
|
||||
this.setCreativeTab(CreativeTabs.tabRedstone);
|
||||
this.sensible = par2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
|
||||
* cleared to be reused)
|
||||
*/
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* How many world ticks before ticking
|
||||
*/
|
||||
public int tickRate(World par1World)
|
||||
{
|
||||
return this.sensible ? 30 : 20;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks to see if you can place this block can be placed on that side of a block: BlockLever overrides
|
||||
*/
|
||||
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)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
|
||||
*/
|
||||
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)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata
|
||||
*/
|
||||
public int onBlockPlaced(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)
|
||||
{
|
||||
int var10 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
int var11 = var10 & 8;
|
||||
var10 &= 7;
|
||||
|
||||
if (par5 == 2 && par1World.isBlockNormalCube(par2, par3, par4 + 1))
|
||||
{
|
||||
var10 = 4;
|
||||
}
|
||||
else if (par5 == 3 && par1World.isBlockNormalCube(par2, par3, par4 - 1))
|
||||
{
|
||||
var10 = 3;
|
||||
}
|
||||
else if (par5 == 4 && par1World.isBlockNormalCube(par2 + 1, par3, par4))
|
||||
{
|
||||
var10 = 2;
|
||||
}
|
||||
else if (par5 == 5 && par1World.isBlockNormalCube(par2 - 1, par3, par4))
|
||||
{
|
||||
var10 = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
var10 = this.getOrientation(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
return var10 + var11;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get side which this button is facing.
|
||||
*/
|
||||
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)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
||||
* their own) Args: x, y, z, neighbor blockID
|
||||
*/
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if (this.redundantCanPlaceBlockAt(par1World, par2, par3, par4))
|
||||
{
|
||||
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 (var7)
|
||||
{
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is redundant, check it out...
|
||||
*/
|
||||
private boolean redundantCanPlaceBlockAt(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if (!this.canPlaceBlockAt(par1World, par2, par3, par4))
|
||||
{
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the blocks bounds based on its current state. Args: world, x, y, z
|
||||
*/
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
|
||||
this.func_82534_e(var5);
|
||||
}
|
||||
|
||||
private void func_82534_e(int par1)
|
||||
{
|
||||
int var2 = par1 & 7;
|
||||
boolean var3 = (par1 & 8) > 0;
|
||||
float var4 = 0.375F;
|
||||
float var5 = 0.625F;
|
||||
float var6 = 0.1875F;
|
||||
float var7 = 0.125F;
|
||||
|
||||
if (var3)
|
||||
{
|
||||
var7 = 0.0625F;
|
||||
}
|
||||
|
||||
if (var2 == 1)
|
||||
{
|
||||
this.setBlockBounds(0.0F, var4, 0.5F - var6, var7, var5, 0.5F + var6);
|
||||
}
|
||||
else if (var2 == 2)
|
||||
{
|
||||
this.setBlockBounds(1.0F - var7, var4, 0.5F - var6, 1.0F, var5, 0.5F + var6);
|
||||
}
|
||||
else if (var2 == 3)
|
||||
{
|
||||
this.setBlockBounds(0.5F - var6, var4, 0.0F, 0.5F + var6, var5, var7);
|
||||
}
|
||||
else if (var2 == 4)
|
||||
{
|
||||
this.setBlockBounds(0.5F - var6, var4, 1.0F - var7, 0.5F + var6, var5, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is clicked by a player. Args: x, y, z, entityPlayer
|
||||
*/
|
||||
public void onBlockClicked(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) {}
|
||||
|
||||
/**
|
||||
* Called upon block activation (right click on the block.)
|
||||
*/
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
int var10 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
int var11 = var10 & 7;
|
||||
int var12 = 8 - (var10 & 8);
|
||||
|
||||
if (var12 == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var11 + var12, 3);
|
||||
par1World.markBlockRangeForRenderUpdate(par2, par3, par4, par2, par3, par4);
|
||||
par1World.playSoundEffect((double)par2 + 0.5D, (double)par3 + 0.5D, (double)par4 + 0.5D, "random.click", 0.3F, 0.6F);
|
||||
this.func_82536_d(par1World, par2, par3, par4, var11);
|
||||
par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate(par1World));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on server worlds only when the block has been replaced by a different block ID, or the same block with a
|
||||
* different metadata value, but before the new metadata value is set. Args: World, x, y, z, old block ID, old
|
||||
* metadata
|
||||
*/
|
||||
public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
if ((par6 & 8) > 0)
|
||||
{
|
||||
int var7 = par6 & 7;
|
||||
this.func_82536_d(par1World, par2, par3, par4, var7);
|
||||
}
|
||||
|
||||
super.breakBlock(par1World, par2, par3, par4, par5, par6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the block is emitting indirect/weak redstone power on the specified side. If isBlockNormalCube
|
||||
* returns true, standard redstone propagation rules will apply instead and this will not be called. Args: World, X,
|
||||
* Y, Z, side. Note that the side is reversed - eg it is 1 (up) when checking the bottom of the block.
|
||||
*/
|
||||
public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return (par1IBlockAccess.getBlockMetadata(par2, par3, par4) & 8) > 0 ? 15 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the block is emitting direct/strong redstone power on the specified side. Args: World, X, Y, Z,
|
||||
* side. Note that the side is reversed - eg it is 1 (up) when checking the bottom of the block.
|
||||
*/
|
||||
public int isProvidingStrongPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
int var6 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
if ((var6 & 8) == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int var7 = var6 & 7;
|
||||
return var7 == 5 && par5 == 1 ? 15 : (var7 == 4 && par5 == 2 ? 15 : (var7 == 3 && par5 == 3 ? 15 : (var7 == 2 && par5 == 4 ? 15 : (var7 == 1 && par5 == 5 ? 15 : 0))));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Can this block provide power. Only wire currently seems to have this change based on its state.
|
||||
*/
|
||||
public boolean canProvidePower()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticks the block if it's been scheduled
|
||||
*/
|
||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
int var6 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
if ((var6 & 8) != 0)
|
||||
{
|
||||
if (this.sensible)
|
||||
{
|
||||
this.func_82535_o(par1World, par2, par3, par4);
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6 & 7, 3);
|
||||
int var7 = var6 & 7;
|
||||
this.func_82536_d(par1World, par2, par3, par4, var7);
|
||||
par1World.playSoundEffect((double)par2 + 0.5D, (double)par3 + 0.5D, (double)par4 + 0.5D, "random.click", 0.3F, 0.5F);
|
||||
par1World.markBlockRangeForRenderUpdate(par2, par3, par4, par2, par3, par4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the block's bounds for rendering it as an item
|
||||
*/
|
||||
public void setBlockBoundsForItemRender()
|
||||
{
|
||||
float var1 = 0.1875F;
|
||||
float var2 = 0.125F;
|
||||
float var3 = 0.125F;
|
||||
this.setBlockBounds(0.5F - var1, 0.5F - var2, 0.5F - var3, 0.5F + var1, 0.5F + var2, 0.5F + var3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity
|
||||
*/
|
||||
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
if (this.sensible)
|
||||
{
|
||||
if ((par1World.getBlockMetadata(par2, par3, par4) & 8) == 0)
|
||||
{
|
||||
this.func_82535_o(par1World, par2, par3, par4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void func_82535_o(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
int var6 = var5 & 7;
|
||||
boolean var7 = (var5 & 8) != 0;
|
||||
this.func_82534_e(var5);
|
||||
List var9 = par1World.getEntitiesWithinAABB(EntityArrow.class, AxisAlignedBB.getAABBPool().getAABB((double)par2 + this.minX, (double)par3 + this.minY, (double)par4 + this.minZ, (double)par2 + this.maxX, (double)par3 + this.maxY, (double)par4 + this.maxZ));
|
||||
boolean var8 = !var9.isEmpty();
|
||||
|
||||
if (var8 && !var7)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6 | 8, 3);
|
||||
this.func_82536_d(par1World, par2, par3, par4, var6);
|
||||
par1World.markBlockRangeForRenderUpdate(par2, par3, par4, par2, par3, par4);
|
||||
par1World.playSoundEffect((double)par2 + 0.5D, (double)par3 + 0.5D, (double)par4 + 0.5D, "random.click", 0.3F, 0.6F);
|
||||
}
|
||||
|
||||
if (!var8 && var7)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6, 3);
|
||||
this.func_82536_d(par1World, par2, par3, par4, var6);
|
||||
par1World.markBlockRangeForRenderUpdate(par2, par3, par4, par2, par3, par4);
|
||||
par1World.playSoundEffect((double)par2 + 0.5D, (double)par3 + 0.5D, (double)par4 + 0.5D, "random.click", 0.3F, 0.5F);
|
||||
}
|
||||
|
||||
if (var8)
|
||||
{
|
||||
par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate(par1World));
|
||||
}
|
||||
}
|
||||
|
||||
private void func_82536_d(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this.blockID);
|
||||
|
||||
if (par5 == 1)
|
||||
{
|
||||
par1World.notifyBlocksOfNeighborChange(par2 - 1, par3, par4, this.blockID);
|
||||
}
|
||||
else if (par5 == 2)
|
||||
{
|
||||
par1World.notifyBlocksOfNeighborChange(par2 + 1, par3, par4, this.blockID);
|
||||
}
|
||||
else if (par5 == 3)
|
||||
{
|
||||
par1World.notifyBlocksOfNeighborChange(par2, par3, par4 - 1, this.blockID);
|
||||
}
|
||||
else if (par5 == 4)
|
||||
{
|
||||
par1World.notifyBlocksOfNeighborChange(par2, par3, par4 + 1, this.blockID);
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this.blockID);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister) {}
|
||||
}
|
||||
17
src/main/java/net/minecraft/src/BlockButtonStone.java
Normal file
17
src/main/java/net/minecraft/src/BlockButtonStone.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class BlockButtonStone extends BlockButton
|
||||
{
|
||||
protected BlockButtonStone(int par1)
|
||||
{
|
||||
super(par1, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return Block.stone.getBlockTextureFromSide(1);
|
||||
}
|
||||
}
|
||||
17
src/main/java/net/minecraft/src/BlockButtonWood.java
Normal file
17
src/main/java/net/minecraft/src/BlockButtonWood.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class BlockButtonWood extends BlockButton
|
||||
{
|
||||
protected BlockButtonWood(int par1)
|
||||
{
|
||||
super(par1, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return Block.planks.getBlockTextureFromSide(1);
|
||||
}
|
||||
}
|
||||
167
src/main/java/net/minecraft/src/BlockCactus.java
Normal file
167
src/main/java/net/minecraft/src/BlockCactus.java
Normal file
@@ -0,0 +1,167 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockCactus extends Block
|
||||
{
|
||||
private Icon cactusTopIcon;
|
||||
private Icon cactusBottomIcon;
|
||||
|
||||
protected BlockCactus(int par1)
|
||||
{
|
||||
super(par1, Material.cactus);
|
||||
this.setTickRandomly(true);
|
||||
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticks the block if it's been scheduled
|
||||
*/
|
||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
if (par1World.isAirBlock(par2, par3 + 1, par4))
|
||||
{
|
||||
int var6;
|
||||
|
||||
for (var6 = 1; par1World.getBlockId(par2, par3 - var6, par4) == this.blockID; ++var6)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
if (var6 < 3)
|
||||
{
|
||||
int var7 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
if (var7 == 15)
|
||||
{
|
||||
par1World.setBlock(par2, par3 + 1, par4, this.blockID);
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 0, 4);
|
||||
this.onNeighborBlockChange(par1World, par2, par3 + 1, par4, this.blockID);
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var7 + 1, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
|
||||
* cleared to be reused)
|
||||
*/
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
float var5 = 0.0625F;
|
||||
return AxisAlignedBB.getAABBPool().getAABB((double)((float)par2 + var5), (double)par3, (double)((float)par4 + var5), (double)((float)(par2 + 1) - var5), (double)((float)(par3 + 1) - var5), (double)((float)(par4 + 1) - var5));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bounding box of the wired rectangular prism to render.
|
||||
*/
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
float var5 = 0.0625F;
|
||||
return AxisAlignedBB.getAABBPool().getAABB((double)((float)par2 + var5), (double)par3, (double)((float)par4 + var5), (double)((float)(par2 + 1) - var5), (double)(par3 + 1), (double)((float)(par4 + 1) - var5));
|
||||
}
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return par1 == 1 ? this.cactusTopIcon : (par1 == 0 ? this.cactusBottomIcon : this.blockIcon);
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
public int getRenderType()
|
||||
{
|
||||
return 13;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
|
||||
*/
|
||||
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return !super.canPlaceBlockAt(par1World, par2, par3, par4) ? false : this.canBlockStay(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
||||
* their own) Args: x, y, z, neighbor blockID
|
||||
*/
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if (!this.canBlockStay(par1World, par2, par3, par4))
|
||||
{
|
||||
par1World.destroyBlock(par2, par3, par4, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Can this block stay at this position. Similar to canPlaceBlockAt except gets checked often with plants.
|
||||
*/
|
||||
public boolean canBlockStay(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if (par1World.getBlockMaterial(par2 - 1, par3, par4).isSolid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (par1World.getBlockMaterial(par2 + 1, par3, par4).isSolid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (par1World.getBlockMaterial(par2, par3, par4 - 1).isSolid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (par1World.getBlockMaterial(par2, par3, par4 + 1).isSolid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int var5 = par1World.getBlockId(par2, par3 - 1, par4);
|
||||
return var5 == Block.cactus.blockID || var5 == Block.sand.blockID;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity
|
||||
*/
|
||||
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
|
||||
{
|
||||
par5Entity.attackEntityFrom(DamageSource.cactus, 1.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(this.getTextureName() + "_side");
|
||||
this.cactusTopIcon = par1IconRegister.registerIcon(this.getTextureName() + "_top");
|
||||
this.cactusBottomIcon = par1IconRegister.registerIcon(this.getTextureName() + "_bottom");
|
||||
}
|
||||
}
|
||||
190
src/main/java/net/minecraft/src/BlockCake.java
Normal file
190
src/main/java/net/minecraft/src/BlockCake.java
Normal file
@@ -0,0 +1,190 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockCake extends Block
|
||||
{
|
||||
private Icon cakeTopIcon;
|
||||
private Icon cakeBottomIcon;
|
||||
private Icon field_94382_c;
|
||||
|
||||
protected BlockCake(int par1)
|
||||
{
|
||||
super(par1, Material.cake);
|
||||
this.setTickRandomly(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the blocks bounds based on its current state. Args: world, x, y, z
|
||||
*/
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
|
||||
float var6 = 0.0625F;
|
||||
float var7 = (float)(1 + var5 * 2) / 16.0F;
|
||||
float var8 = 0.5F;
|
||||
this.setBlockBounds(var7, 0.0F, var6, 1.0F - var6, var8, 1.0F - var6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the block's bounds for rendering it as an item
|
||||
*/
|
||||
public void setBlockBoundsForItemRender()
|
||||
{
|
||||
float var1 = 0.0625F;
|
||||
float var2 = 0.5F;
|
||||
this.setBlockBounds(var1, 0.0F, var1, 1.0F - var1, var2, 1.0F - var1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
|
||||
* cleared to be reused)
|
||||
*/
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
float var6 = 0.0625F;
|
||||
float var7 = (float)(1 + var5 * 2) / 16.0F;
|
||||
float var8 = 0.5F;
|
||||
return AxisAlignedBB.getAABBPool().getAABB((double)((float)par2 + var7), (double)par3, (double)((float)par4 + var6), (double)((float)(par2 + 1) - var6), (double)((float)par3 + var8 - var6), (double)((float)(par4 + 1) - var6));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bounding box of the wired rectangular prism to render.
|
||||
*/
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
float var6 = 0.0625F;
|
||||
float var7 = (float)(1 + var5 * 2) / 16.0F;
|
||||
float var8 = 0.5F;
|
||||
return AxisAlignedBB.getAABBPool().getAABB((double)((float)par2 + var7), (double)par3, (double)((float)par4 + var6), (double)((float)(par2 + 1) - var6), (double)((float)par3 + var8), (double)((float)(par4 + 1) - var6));
|
||||
}
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return par1 == 1 ? this.cakeTopIcon : (par1 == 0 ? this.cakeBottomIcon : (par2 > 0 && par1 == 4 ? this.field_94382_c : this.blockIcon));
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(this.getTextureName() + "_side");
|
||||
this.field_94382_c = par1IconRegister.registerIcon(this.getTextureName() + "_inner");
|
||||
this.cakeTopIcon = par1IconRegister.registerIcon(this.getTextureName() + "_top");
|
||||
this.cakeBottomIcon = par1IconRegister.registerIcon(this.getTextureName() + "_bottom");
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called upon block activation (right click on the block.)
|
||||
*/
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
this.eatCakeSlice(par1World, par2, par3, par4, par5EntityPlayer);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is clicked by a player. Args: x, y, z, entityPlayer
|
||||
*/
|
||||
public void onBlockClicked(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
|
||||
{
|
||||
this.eatCakeSlice(par1World, par2, par3, par4, par5EntityPlayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Heals the player and removes a slice from the cake.
|
||||
*/
|
||||
private void eatCakeSlice(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
|
||||
{
|
||||
if (par5EntityPlayer.canEat(false))
|
||||
{
|
||||
par5EntityPlayer.getFoodStats().addStats(2, 0.1F);
|
||||
int var6 = par1World.getBlockMetadata(par2, par3, par4) + 1;
|
||||
|
||||
if (var6 >= 6)
|
||||
{
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
|
||||
*/
|
||||
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return !super.canPlaceBlockAt(par1World, par2, par3, par4) ? false : this.canBlockStay(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
||||
* their own) Args: x, y, z, neighbor blockID
|
||||
*/
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if (!this.canBlockStay(par1World, par2, par3, par4))
|
||||
{
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Can this block stay at this position. Similar to canPlaceBlockAt except gets checked often with plants.
|
||||
*/
|
||||
public boolean canBlockStay(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return par1World.getBlockMaterial(par2, par3 - 1, par4).isSolid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quantity of items to drop on block destruction.
|
||||
*/
|
||||
public int quantityDropped(Random par1Random)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the items to drop on destruction.
|
||||
*/
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
|
||||
*/
|
||||
public int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return Item.cake.itemID;
|
||||
}
|
||||
}
|
||||
147
src/main/java/net/minecraft/src/BlockCarpet.java
Normal file
147
src/main/java/net/minecraft/src/BlockCarpet.java
Normal file
@@ -0,0 +1,147 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlockCarpet extends Block
|
||||
{
|
||||
protected BlockCarpet(int par1)
|
||||
{
|
||||
super(par1, Material.materialCarpet);
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
|
||||
this.setTickRandomly(true);
|
||||
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||
this.func_111047_d(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return Block.cloth.getIcon(par1, par2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
|
||||
* cleared to be reused)
|
||||
*/
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
byte var5 = 0;
|
||||
float var6 = 0.0625F;
|
||||
return AxisAlignedBB.getAABBPool().getAABB((double)par2 + this.minX, (double)par3 + this.minY, (double)par4 + this.minZ, (double)par2 + this.maxX, (double)((float)par3 + (float)var5 * var6), (double)par4 + this.maxZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the block's bounds for rendering it as an item
|
||||
*/
|
||||
public void setBlockBoundsForItemRender()
|
||||
{
|
||||
this.func_111047_d(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the blocks bounds based on its current state. Args: world, x, y, z
|
||||
*/
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
this.func_111047_d(par1IBlockAccess.getBlockMetadata(par2, par3, par4));
|
||||
}
|
||||
|
||||
protected void func_111047_d(int par1)
|
||||
{
|
||||
byte var2 = 0;
|
||||
float var3 = (float)(1 * (1 + var2)) / 16.0F;
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, var3, 1.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
|
||||
*/
|
||||
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return super.canPlaceBlockAt(par1World, par2, par3, par4) && this.canBlockStay(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
||||
* their own) Args: x, y, z, neighbor blockID
|
||||
*/
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
this.func_111046_k(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
private boolean func_111046_k(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if (!this.canBlockStay(par1World, par2, par3, par4))
|
||||
{
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Can this block stay at this position. Similar to canPlaceBlockAt except gets checked often with plants.
|
||||
*/
|
||||
public boolean canBlockStay(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return !par1World.isAirBlock(par2, par3 - 1, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
|
||||
* coordinates. Args: blockAccess, x, y, z, side
|
||||
*/
|
||||
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return par5 == 1 ? true : super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the damage on the item the block drops. Used in cloth and wood.
|
||||
*/
|
||||
public int damageDropped(int par1)
|
||||
{
|
||||
return par1;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||
*/
|
||||
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
for (int var4 = 0; var4 < 16; ++var4)
|
||||
{
|
||||
par3List.add(new ItemStack(par1, 1, var4));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister) {}
|
||||
}
|
||||
61
src/main/java/net/minecraft/src/BlockCarrot.java
Normal file
61
src/main/java/net/minecraft/src/BlockCarrot.java
Normal file
@@ -0,0 +1,61 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class BlockCarrot extends BlockCrops
|
||||
{
|
||||
private Icon[] iconArray;
|
||||
|
||||
public BlockCarrot(int par1)
|
||||
{
|
||||
super(par1);
|
||||
}
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
if (par2 < 7)
|
||||
{
|
||||
if (par2 == 6)
|
||||
{
|
||||
par2 = 5;
|
||||
}
|
||||
|
||||
return this.iconArray[par2 >> 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.iconArray[3];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a seed ItemStack for this crop.
|
||||
*/
|
||||
protected int getSeedItem()
|
||||
{
|
||||
return Item.carrot.itemID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a crop produce ItemStack for this crop.
|
||||
*/
|
||||
protected int getCropItem()
|
||||
{
|
||||
return Item.carrot.itemID;
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.iconArray = new Icon[4];
|
||||
|
||||
for (int var2 = 0; var2 < this.iconArray.length; ++var2)
|
||||
{
|
||||
this.iconArray[var2] = par1IconRegister.registerIcon(this.getTextureName() + "_stage_" + var2);
|
||||
}
|
||||
}
|
||||
}
|
||||
230
src/main/java/net/minecraft/src/BlockCauldron.java
Normal file
230
src/main/java/net/minecraft/src/BlockCauldron.java
Normal file
@@ -0,0 +1,230 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockCauldron extends Block
|
||||
{
|
||||
private Icon field_94378_a;
|
||||
private Icon cauldronTopIcon;
|
||||
private Icon cauldronBottomIcon;
|
||||
|
||||
public BlockCauldron(int par1)
|
||||
{
|
||||
super(par1, Material.iron);
|
||||
}
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return par1 == 1 ? this.cauldronTopIcon : (par1 == 0 ? this.cauldronBottomIcon : this.blockIcon);
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.field_94378_a = par1IconRegister.registerIcon(this.getTextureName() + "_" + "inner");
|
||||
this.cauldronTopIcon = par1IconRegister.registerIcon(this.getTextureName() + "_top");
|
||||
this.cauldronBottomIcon = par1IconRegister.registerIcon(this.getTextureName() + "_" + "bottom");
|
||||
this.blockIcon = par1IconRegister.registerIcon(this.getTextureName() + "_side");
|
||||
}
|
||||
|
||||
public static Icon getCauldronIcon(String par0Str)
|
||||
{
|
||||
return par0Str.equals("inner") ? Block.cauldron.field_94378_a : (par0Str.equals("bottom") ? Block.cauldron.cauldronBottomIcon : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the list if they intersect the
|
||||
* mask.) Parameters: World, X, Y, Z, mask, list, colliding entity
|
||||
*/
|
||||
public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.3125F, 1.0F);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
float var8 = 0.125F;
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, var8, 1.0F, 1.0F);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, var8);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
this.setBlockBounds(1.0F - var8, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
this.setBlockBounds(0.0F, 0.0F, 1.0F - var8, 1.0F, 1.0F, 1.0F);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
this.setBlockBoundsForItemRender();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the block's bounds for rendering it as an item
|
||||
*/
|
||||
public void setBlockBoundsForItemRender()
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
public int getRenderType()
|
||||
{
|
||||
return 24;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called upon block activation (right click on the block.)
|
||||
*/
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if (par1World.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack var10 = par5EntityPlayer.inventory.getCurrentItem();
|
||||
|
||||
if (var10 == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int var11 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
int var12 = func_111045_h_(var11);
|
||||
|
||||
if (var10.itemID == Item.bucketWater.itemID)
|
||||
{
|
||||
if (var12 < 3)
|
||||
{
|
||||
if (!par5EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, new ItemStack(Item.bucketEmpty));
|
||||
}
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 3, 2);
|
||||
par1World.func_96440_m(par2, par3, par4, this.blockID);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (var10.itemID == Item.glassBottle.itemID)
|
||||
{
|
||||
if (var12 > 0)
|
||||
{
|
||||
ItemStack var13 = new ItemStack(Item.potion, 1, 0);
|
||||
|
||||
if (!par5EntityPlayer.inventory.addItemStackToInventory(var13))
|
||||
{
|
||||
par1World.spawnEntityInWorld(new EntityItem(par1World, (double)par2 + 0.5D, (double)par3 + 1.5D, (double)par4 + 0.5D, var13));
|
||||
}
|
||||
else if (par5EntityPlayer instanceof EntityPlayerMP)
|
||||
{
|
||||
((EntityPlayerMP)par5EntityPlayer).sendContainerToPlayer(par5EntityPlayer.inventoryContainer);
|
||||
}
|
||||
|
||||
--var10.stackSize;
|
||||
|
||||
if (var10.stackSize <= 0)
|
||||
{
|
||||
par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, (ItemStack)null);
|
||||
}
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var12 - 1, 2);
|
||||
par1World.func_96440_m(par2, par3, par4, this.blockID);
|
||||
}
|
||||
}
|
||||
else if (var12 > 0 && var10.getItem() instanceof ItemArmor && ((ItemArmor)var10.getItem()).getArmorMaterial() == EnumArmorMaterial.CLOTH)
|
||||
{
|
||||
ItemArmor var14 = (ItemArmor)var10.getItem();
|
||||
var14.removeColor(var10);
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var12 - 1, 2);
|
||||
par1World.func_96440_m(par2, par3, par4, this.blockID);
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* currently only used by BlockCauldron to incrament meta-data during rain
|
||||
*/
|
||||
public void fillWithRain(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if (par1World.rand.nextInt(20) == 1)
|
||||
{
|
||||
int var5 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
if (var5 < 3)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var5 + 1, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the items to drop on destruction.
|
||||
*/
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return Item.cauldron.itemID;
|
||||
}
|
||||
|
||||
/**
|
||||
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
|
||||
*/
|
||||
public int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return Item.cauldron.itemID;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this returns true, then comparators facing away from this block will use the value from
|
||||
* getComparatorInputOverride instead of the actual redstone signal strength.
|
||||
*/
|
||||
public boolean hasComparatorInputOverride()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* If hasComparatorInputOverride returns true, the return value from this is used instead of the redstone signal
|
||||
* strength when this block inputs to a comparator.
|
||||
*/
|
||||
public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
int var6 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
return func_111045_h_(var6);
|
||||
}
|
||||
|
||||
public static int func_111045_h_(int par0)
|
||||
{
|
||||
return par0;
|
||||
}
|
||||
}
|
||||
573
src/main/java/net/minecraft/src/BlockChest.java
Normal file
573
src/main/java/net/minecraft/src/BlockChest.java
Normal file
@@ -0,0 +1,573 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockChest extends BlockContainer
|
||||
{
|
||||
private final Random random = new Random();
|
||||
|
||||
/** 1 for trapped chests, 0 for normal chests. */
|
||||
public final int chestType;
|
||||
|
||||
protected BlockChest(int par1, int par2)
|
||||
{
|
||||
super(par1, Material.wood);
|
||||
this.chestType = par2;
|
||||
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
public int getRenderType()
|
||||
{
|
||||
return 22;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the blocks bounds based on its current state. Args: world, x, y, z
|
||||
*/
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
if (par1IBlockAccess.getBlockId(par2, par3, par4 - 1) == this.blockID)
|
||||
{
|
||||
this.setBlockBounds(0.0625F, 0.0F, 0.0F, 0.9375F, 0.875F, 0.9375F);
|
||||
}
|
||||
else if (par1IBlockAccess.getBlockId(par2, par3, par4 + 1) == this.blockID)
|
||||
{
|
||||
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 1.0F);
|
||||
}
|
||||
else if (par1IBlockAccess.getBlockId(par2 - 1, par3, par4) == this.blockID)
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
|
||||
}
|
||||
else if (par1IBlockAccess.getBlockId(par2 + 1, par3, par4) == this.blockID)
|
||||
{
|
||||
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 1.0F, 0.875F, 0.9375F);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever the block is added into the world. Args: world, x, y, z
|
||||
*/
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
super.onBlockAdded(par1World, par2, par3, par4);
|
||||
this.unifyAdjacentChests(par1World, par2, par3, par4);
|
||||
int var5 = par1World.getBlockId(par2, par3, par4 - 1);
|
||||
int var6 = par1World.getBlockId(par2, par3, par4 + 1);
|
||||
int var7 = par1World.getBlockId(par2 - 1, par3, par4);
|
||||
int var8 = par1World.getBlockId(par2 + 1, par3, par4);
|
||||
|
||||
if (var5 == this.blockID)
|
||||
{
|
||||
this.unifyAdjacentChests(par1World, par2, par3, par4 - 1);
|
||||
}
|
||||
|
||||
if (var6 == this.blockID)
|
||||
{
|
||||
this.unifyAdjacentChests(par1World, par2, par3, par4 + 1);
|
||||
}
|
||||
|
||||
if (var7 == this.blockID)
|
||||
{
|
||||
this.unifyAdjacentChests(par1World, par2 - 1, par3, par4);
|
||||
}
|
||||
|
||||
if (var8 == this.blockID)
|
||||
{
|
||||
this.unifyAdjacentChests(par1World, par2 + 1, par3, par4);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is placed in the world.
|
||||
*/
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
|
||||
{
|
||||
int var7 = par1World.getBlockId(par2, par3, par4 - 1);
|
||||
int var8 = par1World.getBlockId(par2, par3, par4 + 1);
|
||||
int var9 = par1World.getBlockId(par2 - 1, par3, par4);
|
||||
int var10 = par1World.getBlockId(par2 + 1, par3, par4);
|
||||
byte var11 = 0;
|
||||
int var12 = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
|
||||
if (var12 == 0)
|
||||
{
|
||||
var11 = 2;
|
||||
}
|
||||
|
||||
if (var12 == 1)
|
||||
{
|
||||
var11 = 5;
|
||||
}
|
||||
|
||||
if (var12 == 2)
|
||||
{
|
||||
var11 = 3;
|
||||
}
|
||||
|
||||
if (var12 == 3)
|
||||
{
|
||||
var11 = 4;
|
||||
}
|
||||
|
||||
if (var7 != this.blockID && var8 != this.blockID && var9 != this.blockID && var10 != this.blockID)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var11, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((var7 == this.blockID || var8 == this.blockID) && (var11 == 4 || var11 == 5))
|
||||
{
|
||||
if (var7 == this.blockID)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4 - 1, var11, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4 + 1, var11, 3);
|
||||
}
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var11, 3);
|
||||
}
|
||||
|
||||
if ((var9 == this.blockID || var10 == this.blockID) && (var11 == 2 || var11 == 3))
|
||||
{
|
||||
if (var9 == this.blockID)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2 - 1, par3, par4, var11, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2 + 1, par3, par4, var11, 3);
|
||||
}
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var11, 3);
|
||||
}
|
||||
}
|
||||
|
||||
if (par6ItemStack.hasDisplayName())
|
||||
{
|
||||
((TileEntityChest)par1World.getBlockTileEntity(par2, par3, par4)).setChestGuiName(par6ItemStack.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns the adjacent chests to a double chest.
|
||||
*/
|
||||
public void unifyAdjacentChests(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
int var5 = par1World.getBlockId(par2, par3, par4 - 1);
|
||||
int var6 = par1World.getBlockId(par2, par3, par4 + 1);
|
||||
int var7 = par1World.getBlockId(par2 - 1, par3, par4);
|
||||
int var8 = par1World.getBlockId(par2 + 1, par3, par4);
|
||||
boolean var9 = true;
|
||||
int var10;
|
||||
int var11;
|
||||
boolean var12;
|
||||
byte var13;
|
||||
int var14;
|
||||
|
||||
if (var5 != this.blockID && var6 != this.blockID)
|
||||
{
|
||||
if (var7 != this.blockID && var8 != this.blockID)
|
||||
{
|
||||
var13 = 3;
|
||||
|
||||
if (Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var6])
|
||||
{
|
||||
var13 = 3;
|
||||
}
|
||||
|
||||
if (Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var5])
|
||||
{
|
||||
var13 = 2;
|
||||
}
|
||||
|
||||
if (Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var8])
|
||||
{
|
||||
var13 = 5;
|
||||
}
|
||||
|
||||
if (Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var7])
|
||||
{
|
||||
var13 = 4;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var10 = par1World.getBlockId(var7 == this.blockID ? par2 - 1 : par2 + 1, par3, par4 - 1);
|
||||
var11 = par1World.getBlockId(var7 == this.blockID ? par2 - 1 : par2 + 1, par3, par4 + 1);
|
||||
var13 = 3;
|
||||
var12 = true;
|
||||
|
||||
if (var7 == this.blockID)
|
||||
{
|
||||
var14 = par1World.getBlockMetadata(par2 - 1, par3, par4);
|
||||
}
|
||||
else
|
||||
{
|
||||
var14 = par1World.getBlockMetadata(par2 + 1, par3, par4);
|
||||
}
|
||||
|
||||
if (var14 == 2)
|
||||
{
|
||||
var13 = 2;
|
||||
}
|
||||
|
||||
if ((Block.opaqueCubeLookup[var5] || Block.opaqueCubeLookup[var10]) && !Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var11])
|
||||
{
|
||||
var13 = 3;
|
||||
}
|
||||
|
||||
if ((Block.opaqueCubeLookup[var6] || Block.opaqueCubeLookup[var11]) && !Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var10])
|
||||
{
|
||||
var13 = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var10 = par1World.getBlockId(par2 - 1, par3, var5 == this.blockID ? par4 - 1 : par4 + 1);
|
||||
var11 = par1World.getBlockId(par2 + 1, par3, var5 == this.blockID ? par4 - 1 : par4 + 1);
|
||||
var13 = 5;
|
||||
var12 = true;
|
||||
|
||||
if (var5 == this.blockID)
|
||||
{
|
||||
var14 = par1World.getBlockMetadata(par2, par3, par4 - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
var14 = par1World.getBlockMetadata(par2, par3, par4 + 1);
|
||||
}
|
||||
|
||||
if (var14 == 4)
|
||||
{
|
||||
var13 = 4;
|
||||
}
|
||||
|
||||
if ((Block.opaqueCubeLookup[var7] || Block.opaqueCubeLookup[var10]) && !Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var11])
|
||||
{
|
||||
var13 = 5;
|
||||
}
|
||||
|
||||
if ((Block.opaqueCubeLookup[var8] || Block.opaqueCubeLookup[var11]) && !Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var10])
|
||||
{
|
||||
var13 = 4;
|
||||
}
|
||||
}
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var13, 3);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
|
||||
*/
|
||||
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = 0;
|
||||
|
||||
if (par1World.getBlockId(par2 - 1, par3, par4) == this.blockID)
|
||||
{
|
||||
++var5;
|
||||
}
|
||||
|
||||
if (par1World.getBlockId(par2 + 1, par3, par4) == this.blockID)
|
||||
{
|
||||
++var5;
|
||||
}
|
||||
|
||||
if (par1World.getBlockId(par2, par3, par4 - 1) == this.blockID)
|
||||
{
|
||||
++var5;
|
||||
}
|
||||
|
||||
if (par1World.getBlockId(par2, par3, par4 + 1) == this.blockID)
|
||||
{
|
||||
++var5;
|
||||
}
|
||||
|
||||
return var5 > 1 ? false : (this.isThereANeighborChest(par1World, par2 - 1, par3, par4) ? false : (this.isThereANeighborChest(par1World, par2 + 1, par3, par4) ? false : (this.isThereANeighborChest(par1World, par2, par3, par4 - 1) ? false : !this.isThereANeighborChest(par1World, par2, par3, par4 + 1))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the neighbor blocks to see if there is a chest there. Args: world, x, y, z
|
||||
*/
|
||||
private boolean isThereANeighborChest(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return par1World.getBlockId(par2, par3, par4) != this.blockID ? false : (par1World.getBlockId(par2 - 1, par3, par4) == this.blockID ? true : (par1World.getBlockId(par2 + 1, par3, par4) == this.blockID ? true : (par1World.getBlockId(par2, par3, par4 - 1) == this.blockID ? true : par1World.getBlockId(par2, par3, par4 + 1) == this.blockID)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
||||
* their own) Args: x, y, z, neighbor blockID
|
||||
*/
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
|
||||
TileEntityChest var6 = (TileEntityChest)par1World.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
if (var6 != null)
|
||||
{
|
||||
var6.updateContainingBlockInfo();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on server worlds only when the block has been replaced by a different block ID, or the same block with a
|
||||
* different metadata value, but before the new metadata value is set. Args: World, x, y, z, old block ID, old
|
||||
* metadata
|
||||
*/
|
||||
public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
TileEntityChest var7 = (TileEntityChest)par1World.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
if (var7 != null)
|
||||
{
|
||||
for (int var8 = 0; var8 < var7.getSizeInventory(); ++var8)
|
||||
{
|
||||
ItemStack var9 = var7.getStackInSlot(var8);
|
||||
|
||||
if (var9 != null)
|
||||
{
|
||||
float var10 = this.random.nextFloat() * 0.8F + 0.1F;
|
||||
float var11 = this.random.nextFloat() * 0.8F + 0.1F;
|
||||
EntityItem var14;
|
||||
|
||||
for (float var12 = this.random.nextFloat() * 0.8F + 0.1F; var9.stackSize > 0; par1World.spawnEntityInWorld(var14))
|
||||
{
|
||||
int var13 = this.random.nextInt(21) + 10;
|
||||
|
||||
if (var13 > var9.stackSize)
|
||||
{
|
||||
var13 = var9.stackSize;
|
||||
}
|
||||
|
||||
var9.stackSize -= var13;
|
||||
var14 = new EntityItem(par1World, (double)((float)par2 + var10), (double)((float)par3 + var11), (double)((float)par4 + var12), new ItemStack(var9.itemID, var13, var9.getItemDamage()));
|
||||
float var15 = 0.05F;
|
||||
var14.motionX = (double)((float)this.random.nextGaussian() * var15);
|
||||
var14.motionY = (double)((float)this.random.nextGaussian() * var15 + 0.2F);
|
||||
var14.motionZ = (double)((float)this.random.nextGaussian() * var15);
|
||||
|
||||
if (var9.hasTagCompound())
|
||||
{
|
||||
var14.getEntityItem().setTagCompound((NBTTagCompound)var9.getTagCompound().copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
par1World.func_96440_m(par2, par3, par4, par5);
|
||||
}
|
||||
|
||||
super.breakBlock(par1World, par2, par3, par4, par5, par6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called upon block activation (right click on the block.)
|
||||
*/
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if (par1World.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
IInventory var10 = this.getInventory(par1World, par2, par3, par4);
|
||||
|
||||
if (var10 != null)
|
||||
{
|
||||
par5EntityPlayer.displayGUIChest(var10);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the inventory of the chest at the specified coords, accounting for blocks or ocelots on top of the chest,
|
||||
* and double chests.
|
||||
*/
|
||||
public IInventory getInventory(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
Object var5 = (TileEntityChest)par1World.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
if (var5 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if (par1World.isBlockNormalCube(par2, par3 + 1, par4))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if (isOcelotBlockingChest(par1World, par2, par3, par4))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if (par1World.getBlockId(par2 - 1, par3, par4) == this.blockID && (par1World.isBlockNormalCube(par2 - 1, par3 + 1, par4) || isOcelotBlockingChest(par1World, par2 - 1, par3, par4)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if (par1World.getBlockId(par2 + 1, par3, par4) == this.blockID && (par1World.isBlockNormalCube(par2 + 1, par3 + 1, par4) || isOcelotBlockingChest(par1World, par2 + 1, par3, par4)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if (par1World.getBlockId(par2, par3, par4 - 1) == this.blockID && (par1World.isBlockNormalCube(par2, par3 + 1, par4 - 1) || isOcelotBlockingChest(par1World, par2, par3, par4 - 1)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if (par1World.getBlockId(par2, par3, par4 + 1) == this.blockID && (par1World.isBlockNormalCube(par2, par3 + 1, par4 + 1) || isOcelotBlockingChest(par1World, par2, par3, par4 + 1)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (par1World.getBlockId(par2 - 1, par3, par4) == this.blockID)
|
||||
{
|
||||
var5 = new InventoryLargeChest("container.chestDouble", (TileEntityChest)par1World.getBlockTileEntity(par2 - 1, par3, par4), (IInventory)var5);
|
||||
}
|
||||
|
||||
if (par1World.getBlockId(par2 + 1, par3, par4) == this.blockID)
|
||||
{
|
||||
var5 = new InventoryLargeChest("container.chestDouble", (IInventory)var5, (TileEntityChest)par1World.getBlockTileEntity(par2 + 1, par3, par4));
|
||||
}
|
||||
|
||||
if (par1World.getBlockId(par2, par3, par4 - 1) == this.blockID)
|
||||
{
|
||||
var5 = new InventoryLargeChest("container.chestDouble", (TileEntityChest)par1World.getBlockTileEntity(par2, par3, par4 - 1), (IInventory)var5);
|
||||
}
|
||||
|
||||
if (par1World.getBlockId(par2, par3, par4 + 1) == this.blockID)
|
||||
{
|
||||
var5 = new InventoryLargeChest("container.chestDouble", (IInventory)var5, (TileEntityChest)par1World.getBlockTileEntity(par2, par3, par4 + 1));
|
||||
}
|
||||
|
||||
return (IInventory)var5;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||
*/
|
||||
public TileEntity createNewTileEntity(World par1World)
|
||||
{
|
||||
TileEntityChest var2 = new TileEntityChest();
|
||||
return var2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can this block provide power. Only wire currently seems to have this change based on its state.
|
||||
*/
|
||||
public boolean canProvidePower()
|
||||
{
|
||||
return this.chestType == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the block is emitting indirect/weak redstone power on the specified side. If isBlockNormalCube
|
||||
* returns true, standard redstone propagation rules will apply instead and this will not be called. Args: World, X,
|
||||
* Y, Z, side. Note that the side is reversed - eg it is 1 (up) when checking the bottom of the block.
|
||||
*/
|
||||
public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if (!this.canProvidePower())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int var6 = ((TileEntityChest)par1IBlockAccess.getBlockTileEntity(par2, par3, par4)).numUsingPlayers;
|
||||
return MathHelper.clamp_int(var6, 0, 15);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the block is emitting direct/strong redstone power on the specified side. Args: World, X, Y, Z,
|
||||
* side. Note that the side is reversed - eg it is 1 (up) when checking the bottom of the block.
|
||||
*/
|
||||
public int isProvidingStrongPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return par5 == 1 ? this.isProvidingWeakPower(par1IBlockAccess, par2, par3, par4, par5) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks for a sitting ocelot within certain bounds. Such an ocelot is considered to be blocking access to the
|
||||
* chest.
|
||||
*/
|
||||
private static boolean isOcelotBlockingChest(World par0World, int par1, int par2, int par3)
|
||||
{
|
||||
Iterator var4 = par0World.getEntitiesWithinAABB(EntityOcelot.class, AxisAlignedBB.getAABBPool().getAABB((double)par1, (double)(par2 + 1), (double)par3, (double)(par1 + 1), (double)(par2 + 2), (double)(par3 + 1))).iterator();
|
||||
EntityOcelot var6;
|
||||
|
||||
do
|
||||
{
|
||||
if (!var4.hasNext())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
EntityOcelot var5 = (EntityOcelot)var4.next();
|
||||
var6 = (EntityOcelot)var5;
|
||||
}
|
||||
while (!var6.isSitting());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this returns true, then comparators facing away from this block will use the value from
|
||||
* getComparatorInputOverride instead of the actual redstone signal strength.
|
||||
*/
|
||||
public boolean hasComparatorInputOverride()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* If hasComparatorInputOverride returns true, the return value from this is used instead of the redstone signal
|
||||
* strength when this block inputs to a comparator.
|
||||
*/
|
||||
public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return Container.calcRedstoneFromInventory(this.getInventory(par1World, par2, par3, par4));
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon("planks_oak");
|
||||
}
|
||||
}
|
||||
28
src/main/java/net/minecraft/src/BlockClay.java
Normal file
28
src/main/java/net/minecraft/src/BlockClay.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockClay extends Block
|
||||
{
|
||||
public BlockClay(int par1)
|
||||
{
|
||||
super(par1, Material.clay);
|
||||
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the items to drop on destruction.
|
||||
*/
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return Item.clay.itemID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quantity of items to drop on block destruction.
|
||||
*/
|
||||
public int quantityDropped(Random par1Random)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
231
src/main/java/net/minecraft/src/BlockCocoa.java
Normal file
231
src/main/java/net/minecraft/src/BlockCocoa.java
Normal file
@@ -0,0 +1,231 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockCocoa extends BlockDirectional
|
||||
{
|
||||
private Icon[] iconArray;
|
||||
|
||||
public BlockCocoa(int par1)
|
||||
{
|
||||
super(par1, Material.plants);
|
||||
this.setTickRandomly(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return this.iconArray[2];
|
||||
}
|
||||
|
||||
public Icon getCocoaIcon(int par1)
|
||||
{
|
||||
if (par1 < 0 || par1 >= this.iconArray.length)
|
||||
{
|
||||
par1 = this.iconArray.length - 1;
|
||||
}
|
||||
|
||||
return this.iconArray[par1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticks the block if it's been scheduled
|
||||
*/
|
||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
if (!this.canBlockStay(par1World, par2, par3, par4))
|
||||
{
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
|
||||
par1World.setBlock(par2, par3, par4, 0, 0, 2);
|
||||
}
|
||||
else if (par1World.rand.nextInt(5) == 0)
|
||||
{
|
||||
int var6 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
int var7 = func_72219_c(var6);
|
||||
|
||||
if (var7 < 2)
|
||||
{
|
||||
++var7;
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var7 << 2 | getDirection(var6), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Can this block stay at this position. Similar to canPlaceBlockAt except gets checked often with plants.
|
||||
*/
|
||||
public boolean canBlockStay(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = getDirection(par1World.getBlockMetadata(par2, par3, par4));
|
||||
par2 += Direction.offsetX[var5];
|
||||
par4 += Direction.offsetZ[var5];
|
||||
int var6 = par1World.getBlockId(par2, par3, par4);
|
||||
return var6 == Block.wood.blockID && BlockLog.limitToValidMetadata(par1World.getBlockMetadata(par2, par3, par4)) == 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
public int getRenderType()
|
||||
{
|
||||
return 28;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
|
||||
* cleared to be reused)
|
||||
*/
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
this.setBlockBoundsBasedOnState(par1World, par2, par3, par4);
|
||||
return super.getCollisionBoundingBoxFromPool(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bounding box of the wired rectangular prism to render.
|
||||
*/
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
this.setBlockBoundsBasedOnState(par1World, par2, par3, par4);
|
||||
return super.getSelectedBoundingBoxFromPool(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the blocks bounds based on its current state. Args: world, x, y, z
|
||||
*/
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
|
||||
int var6 = getDirection(var5);
|
||||
int var7 = func_72219_c(var5);
|
||||
int var8 = 4 + var7 * 2;
|
||||
int var9 = 5 + var7 * 2;
|
||||
float var10 = (float)var8 / 2.0F;
|
||||
|
||||
switch (var6)
|
||||
{
|
||||
case 0:
|
||||
this.setBlockBounds((8.0F - var10) / 16.0F, (12.0F - (float)var9) / 16.0F, (15.0F - (float)var8) / 16.0F, (8.0F + var10) / 16.0F, 0.75F, 0.9375F);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
this.setBlockBounds(0.0625F, (12.0F - (float)var9) / 16.0F, (8.0F - var10) / 16.0F, (1.0F + (float)var8) / 16.0F, 0.75F, (8.0F + var10) / 16.0F);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
this.setBlockBounds((8.0F - var10) / 16.0F, (12.0F - (float)var9) / 16.0F, 0.0625F, (8.0F + var10) / 16.0F, 0.75F, (1.0F + (float)var8) / 16.0F);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
this.setBlockBounds((15.0F - (float)var8) / 16.0F, (12.0F - (float)var9) / 16.0F, (8.0F - var10) / 16.0F, 0.9375F, 0.75F, (8.0F + var10) / 16.0F);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is placed in the world.
|
||||
*/
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
|
||||
{
|
||||
int var7 = ((MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) + 0) % 4;
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var7, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata
|
||||
*/
|
||||
public int onBlockPlaced(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)
|
||||
{
|
||||
if (par5 == 1 || par5 == 0)
|
||||
{
|
||||
par5 = 2;
|
||||
}
|
||||
|
||||
return Direction.rotateOpposite[Direction.facingToDirection[par5]];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
||||
* their own) Args: x, y, z, neighbor blockID
|
||||
*/
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if (!this.canBlockStay(par1World, par2, par3, par4))
|
||||
{
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
|
||||
par1World.setBlock(par2, par3, par4, 0, 0, 2);
|
||||
}
|
||||
}
|
||||
|
||||
public static int func_72219_c(int par0)
|
||||
{
|
||||
return (par0 & 12) >> 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops the block items with a specified chance of dropping the specified items
|
||||
*/
|
||||
public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7)
|
||||
{
|
||||
int var8 = func_72219_c(par5);
|
||||
byte var9 = 1;
|
||||
|
||||
if (var8 >= 2)
|
||||
{
|
||||
var9 = 3;
|
||||
}
|
||||
|
||||
for (int var10 = 0; var10 < var9; ++var10)
|
||||
{
|
||||
this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(Item.dyePowder, 1, 3));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
|
||||
*/
|
||||
public int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return Item.dyePowder.itemID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the block's damage value (for use with pick block).
|
||||
*/
|
||||
public int getDamageValue(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.iconArray = new Icon[3];
|
||||
|
||||
for (int var2 = 0; var2 < this.iconArray.length; ++var2)
|
||||
{
|
||||
this.iconArray[var2] = par1IconRegister.registerIcon(this.getTextureName() + "_stage_" + var2);
|
||||
}
|
||||
}
|
||||
}
|
||||
71
src/main/java/net/minecraft/src/BlockColored.java
Normal file
71
src/main/java/net/minecraft/src/BlockColored.java
Normal file
@@ -0,0 +1,71 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlockColored extends Block
|
||||
{
|
||||
private Icon[] iconArray;
|
||||
|
||||
public BlockColored(int par1, Material par2Material)
|
||||
{
|
||||
super(par1, par2Material);
|
||||
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||
}
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return this.iconArray[par2 % this.iconArray.length];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the damage on the item the block drops. Used in cloth and wood.
|
||||
*/
|
||||
public int damageDropped(int par1)
|
||||
{
|
||||
return par1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a dye damage value and returns the block damage value to match
|
||||
*/
|
||||
public static int getBlockFromDye(int par0)
|
||||
{
|
||||
return ~par0 & 15;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a block damage value and returns the dye damage value to match
|
||||
*/
|
||||
public static int getDyeFromBlock(int par0)
|
||||
{
|
||||
return ~par0 & 15;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||
*/
|
||||
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
for (int var4 = 0; var4 < 16; ++var4)
|
||||
{
|
||||
par3List.add(new ItemStack(par1, 1, var4));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.iconArray = new Icon[16];
|
||||
|
||||
for (int var2 = 0; var2 < this.iconArray.length; ++var2)
|
||||
{
|
||||
this.iconArray[var2] = par1IconRegister.registerIcon(this.getTextureName() + "_" + ItemDye.dyeItemNames[getDyeFromBlock(var2)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
121
src/main/java/net/minecraft/src/BlockCommandBlock.java
Normal file
121
src/main/java/net/minecraft/src/BlockCommandBlock.java
Normal file
@@ -0,0 +1,121 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockCommandBlock extends BlockContainer
|
||||
{
|
||||
public BlockCommandBlock(int par1)
|
||||
{
|
||||
super(par1, Material.iron);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||
*/
|
||||
public TileEntity createNewTileEntity(World par1World)
|
||||
{
|
||||
return new TileEntityCommandBlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
||||
* their own) Args: x, y, z, neighbor blockID
|
||||
*/
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
boolean var6 = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4);
|
||||
int var7 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
boolean var8 = (var7 & 1) != 0;
|
||||
|
||||
if (var6 && !var8)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var7 | 1, 4);
|
||||
par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate(par1World));
|
||||
}
|
||||
else if (!var6 && var8)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var7 & -2, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticks the block if it's been scheduled
|
||||
*/
|
||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
TileEntity var6 = par1World.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
if (var6 != null && var6 instanceof TileEntityCommandBlock)
|
||||
{
|
||||
TileEntityCommandBlock var7 = (TileEntityCommandBlock)var6;
|
||||
var7.func_96102_a(var7.executeCommandOnPowered(par1World));
|
||||
par1World.func_96440_m(par2, par3, par4, this.blockID);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* How many world ticks before ticking
|
||||
*/
|
||||
public int tickRate(World par1World)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called upon block activation (right click on the block.)
|
||||
*/
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
TileEntityCommandBlock var10 = (TileEntityCommandBlock)par1World.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
if (var10 != null)
|
||||
{
|
||||
par5EntityPlayer.displayGUIEditSign(var10);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this returns true, then comparators facing away from this block will use the value from
|
||||
* getComparatorInputOverride instead of the actual redstone signal strength.
|
||||
*/
|
||||
public boolean hasComparatorInputOverride()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* If hasComparatorInputOverride returns true, the return value from this is used instead of the redstone signal
|
||||
* strength when this block inputs to a comparator.
|
||||
*/
|
||||
public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
TileEntity var6 = par1World.getBlockTileEntity(par2, par3, par4);
|
||||
return var6 != null && var6 instanceof TileEntityCommandBlock ? ((TileEntityCommandBlock)var6).func_96103_d() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is placed in the world.
|
||||
*/
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
|
||||
{
|
||||
TileEntityCommandBlock var7 = (TileEntityCommandBlock)par1World.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
if (par6ItemStack.hasDisplayName())
|
||||
{
|
||||
var7.setCommandSenderName(par6ItemStack.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quantity of items to drop on block destruction.
|
||||
*/
|
||||
public int quantityDropped(Random par1Random)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
257
src/main/java/net/minecraft/src/BlockComparator.java
Normal file
257
src/main/java/net/minecraft/src/BlockComparator.java
Normal file
@@ -0,0 +1,257 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockComparator extends BlockRedstoneLogic implements ITileEntityProvider
|
||||
{
|
||||
public BlockComparator(int par1, boolean par2)
|
||||
{
|
||||
super(par1, par2);
|
||||
this.isBlockContainer = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the items to drop on destruction.
|
||||
*/
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return Item.comparator.itemID;
|
||||
}
|
||||
|
||||
/**
|
||||
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
|
||||
*/
|
||||
public int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return Item.comparator.itemID;
|
||||
}
|
||||
|
||||
protected int func_94481_j_(int par1)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
protected BlockRedstoneLogic func_94485_e()
|
||||
{
|
||||
return Block.redstoneComparatorActive;
|
||||
}
|
||||
|
||||
protected BlockRedstoneLogic func_94484_i()
|
||||
{
|
||||
return Block.redstoneComparatorIdle;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
public int getRenderType()
|
||||
{
|
||||
return 37;
|
||||
}
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
boolean var3 = this.isRepeaterPowered || (par2 & 8) != 0;
|
||||
return par1 == 0 ? (var3 ? Block.torchRedstoneActive.getBlockTextureFromSide(par1) : Block.torchRedstoneIdle.getBlockTextureFromSide(par1)) : (par1 == 1 ? (var3 ? Block.redstoneComparatorActive.blockIcon : this.blockIcon) : Block.stoneDoubleSlab.getBlockTextureFromSide(1));
|
||||
}
|
||||
|
||||
protected boolean func_96470_c(int par1)
|
||||
{
|
||||
return this.isRepeaterPowered || (par1 & 8) != 0;
|
||||
}
|
||||
|
||||
protected int func_94480_d(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return this.getTileEntityComparator(par1IBlockAccess, par2, par3, par4).getOutputSignal();
|
||||
}
|
||||
|
||||
private int getOutputStrength(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return !this.func_94490_c(par5) ? this.getInputStrength(par1World, par2, par3, par4, par5) : Math.max(this.getInputStrength(par1World, par2, par3, par4, par5) - this.func_94482_f(par1World, par2, par3, par4, par5), 0);
|
||||
}
|
||||
|
||||
public boolean func_94490_c(int par1)
|
||||
{
|
||||
return (par1 & 4) == 4;
|
||||
}
|
||||
|
||||
protected boolean isGettingInput(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
int var6 = this.getInputStrength(par1World, par2, par3, par4, par5);
|
||||
|
||||
if (var6 >= 15)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (var6 == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int var7 = this.func_94482_f(par1World, par2, par3, par4, par5);
|
||||
return var7 == 0 ? true : var6 >= var7;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the signal strength at one input of the block. Args: world, X, Y, Z, side
|
||||
*/
|
||||
protected int getInputStrength(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
int var6 = super.getInputStrength(par1World, par2, par3, par4, par5);
|
||||
int var7 = getDirection(par5);
|
||||
int var8 = par2 + Direction.offsetX[var7];
|
||||
int var9 = par4 + Direction.offsetZ[var7];
|
||||
int var10 = par1World.getBlockId(var8, par3, var9);
|
||||
|
||||
if (var10 > 0)
|
||||
{
|
||||
if (Block.blocksList[var10].hasComparatorInputOverride())
|
||||
{
|
||||
var6 = Block.blocksList[var10].getComparatorInputOverride(par1World, var8, par3, var9, Direction.rotateOpposite[var7]);
|
||||
}
|
||||
else if (var6 < 15 && Block.isNormalCube(var10))
|
||||
{
|
||||
var8 += Direction.offsetX[var7];
|
||||
var9 += Direction.offsetZ[var7];
|
||||
var10 = par1World.getBlockId(var8, par3, var9);
|
||||
|
||||
if (var10 > 0 && Block.blocksList[var10].hasComparatorInputOverride())
|
||||
{
|
||||
var6 = Block.blocksList[var10].getComparatorInputOverride(par1World, var8, par3, var9, Direction.rotateOpposite[var7]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return var6;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the blockTileEntity at given coordinates.
|
||||
*/
|
||||
public TileEntityComparator getTileEntityComparator(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
return (TileEntityComparator)par1IBlockAccess.getBlockTileEntity(par2, par3, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called upon block activation (right click on the block.)
|
||||
*/
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
int var10 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
boolean var11 = this.isRepeaterPowered | (var10 & 8) != 0;
|
||||
boolean var12 = !this.func_94490_c(var10);
|
||||
int var13 = var12 ? 4 : 0;
|
||||
var13 |= var11 ? 8 : 0;
|
||||
par1World.playSoundEffect((double)par2 + 0.5D, (double)par3 + 0.5D, (double)par4 + 0.5D, "random.click", 0.3F, var12 ? 0.55F : 0.5F);
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var13 | var10 & 3, 2);
|
||||
this.func_96476_c(par1World, par2, par3, par4, par1World.rand);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void func_94479_f(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if (!par1World.isBlockTickScheduledThisTick(par2, par3, par4, this.blockID))
|
||||
{
|
||||
int var6 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
int var7 = this.getOutputStrength(par1World, par2, par3, par4, var6);
|
||||
int var8 = this.getTileEntityComparator(par1World, par2, par3, par4).getOutputSignal();
|
||||
|
||||
if (var7 != var8 || this.func_96470_c(var6) != this.isGettingInput(par1World, par2, par3, par4, var6))
|
||||
{
|
||||
if (this.func_83011_d(par1World, par2, par3, par4, var6))
|
||||
{
|
||||
par1World.scheduleBlockUpdateWithPriority(par2, par3, par4, this.blockID, this.func_94481_j_(0), -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.scheduleBlockUpdateWithPriority(par2, par3, par4, this.blockID, this.func_94481_j_(0), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void func_96476_c(World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
int var6 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
int var7 = this.getOutputStrength(par1World, par2, par3, par4, var6);
|
||||
int var8 = this.getTileEntityComparator(par1World, par2, par3, par4).getOutputSignal();
|
||||
this.getTileEntityComparator(par1World, par2, par3, par4).setOutputSignal(var7);
|
||||
|
||||
if (var8 != var7 || !this.func_94490_c(var6))
|
||||
{
|
||||
boolean var9 = this.isGettingInput(par1World, par2, par3, par4, var6);
|
||||
boolean var10 = this.isRepeaterPowered || (var6 & 8) != 0;
|
||||
|
||||
if (var10 && !var9)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6 & -9, 2);
|
||||
}
|
||||
else if (!var10 && var9)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6 | 8, 2);
|
||||
}
|
||||
|
||||
this.func_94483_i_(par1World, par2, par3, par4);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticks the block if it's been scheduled
|
||||
*/
|
||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
if (this.isRepeaterPowered)
|
||||
{
|
||||
int var6 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
par1World.setBlock(par2, par3, par4, this.func_94484_i().blockID, var6 | 8, 4);
|
||||
}
|
||||
|
||||
this.func_96476_c(par1World, par2, par3, par4, par5Random);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever the block is added into the world. Args: world, x, y, z
|
||||
*/
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
super.onBlockAdded(par1World, par2, par3, par4);
|
||||
par1World.setBlockTileEntity(par2, par3, par4, this.createNewTileEntity(par1World));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on server worlds only when the block has been replaced by a different block ID, or the same block with a
|
||||
* different metadata value, but before the new metadata value is set. Args: World, x, y, z, old block ID, old
|
||||
* metadata
|
||||
*/
|
||||
public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
super.breakBlock(par1World, par2, par3, par4, par5, par6);
|
||||
par1World.removeBlockTileEntity(par2, par3, par4);
|
||||
this.func_94483_i_(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block receives a BlockEvent - see World.addBlockEvent. By default, passes it on to the tile
|
||||
* entity at this location. Args: world, x, y, z, blockID, EventID, event parameter
|
||||
*/
|
||||
public boolean onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6);
|
||||
TileEntity var7 = par1World.getBlockTileEntity(par2, par3, par4);
|
||||
return var7 != null ? var7.receiveClientEvent(par5, par6) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||
*/
|
||||
public TileEntity createNewTileEntity(World par1World)
|
||||
{
|
||||
return new TileEntityComparator();
|
||||
}
|
||||
}
|
||||
40
src/main/java/net/minecraft/src/BlockContainer.java
Normal file
40
src/main/java/net/minecraft/src/BlockContainer.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public abstract class BlockContainer extends Block implements ITileEntityProvider
|
||||
{
|
||||
protected BlockContainer(int par1, Material par2Material)
|
||||
{
|
||||
super(par1, par2Material);
|
||||
this.isBlockContainer = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever the block is added into the world. Args: world, x, y, z
|
||||
*/
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
super.onBlockAdded(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on server worlds only when the block has been replaced by a different block ID, or the same block with a
|
||||
* different metadata value, but before the new metadata value is set. Args: World, x, y, z, old block ID, old
|
||||
* metadata
|
||||
*/
|
||||
public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
super.breakBlock(par1World, par2, par3, par4, par5, par6);
|
||||
par1World.removeBlockTileEntity(par2, par3, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block receives a BlockEvent - see World.addBlockEvent. By default, passes it on to the tile
|
||||
* entity at this location. Args: world, x, y, z, blockID, EventID, event parameter
|
||||
*/
|
||||
public boolean onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6);
|
||||
TileEntity var7 = par1World.getBlockTileEntity(par2, par3, par4);
|
||||
return var7 != null ? var7.receiveClientEvent(par5, par6) : false;
|
||||
}
|
||||
}
|
||||
221
src/main/java/net/minecraft/src/BlockCrops.java
Normal file
221
src/main/java/net/minecraft/src/BlockCrops.java
Normal file
@@ -0,0 +1,221 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockCrops extends BlockFlower
|
||||
{
|
||||
private Icon[] iconArray;
|
||||
|
||||
protected BlockCrops(int par1)
|
||||
{
|
||||
super(par1);
|
||||
this.setTickRandomly(true);
|
||||
float var2 = 0.5F;
|
||||
this.setBlockBounds(0.5F - var2, 0.0F, 0.5F - var2, 0.5F + var2, 0.25F, 0.5F + var2);
|
||||
this.setCreativeTab((CreativeTabs)null);
|
||||
this.setHardness(0.0F);
|
||||
this.setStepSound(soundGrassFootstep);
|
||||
this.disableStats();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets passed in the blockID of the block below and supposed to return true if its allowed to grow on the type of
|
||||
* blockID passed in. Args: blockID
|
||||
*/
|
||||
protected boolean canThisPlantGrowOnThisBlockID(int par1)
|
||||
{
|
||||
return par1 == Block.tilledField.blockID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticks the block if it's been scheduled
|
||||
*/
|
||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
super.updateTick(par1World, par2, par3, par4, par5Random);
|
||||
|
||||
if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9)
|
||||
{
|
||||
int var6 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
if (var6 < 7)
|
||||
{
|
||||
float var7 = this.getGrowthRate(par1World, par2, par3, par4);
|
||||
|
||||
if (par5Random.nextInt((int)(25.0F / var7) + 1) == 0)
|
||||
{
|
||||
++var6;
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply bonemeal to the crops.
|
||||
*/
|
||||
public void fertilize(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = par1World.getBlockMetadata(par2, par3, par4) + MathHelper.getRandomIntegerInRange(par1World.rand, 2, 5);
|
||||
|
||||
if (var5 > 7)
|
||||
{
|
||||
var5 = 7;
|
||||
}
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var5, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the growth rate for the crop. Setup to encourage rows by halving growth rate if there is diagonals, crops on
|
||||
* different sides that aren't opposing, and by adding growth for every crop next to this one (and for crop below
|
||||
* this one). Args: x, y, z
|
||||
*/
|
||||
private float getGrowthRate(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
float var5 = 1.0F;
|
||||
int var6 = par1World.getBlockId(par2, par3, par4 - 1);
|
||||
int var7 = par1World.getBlockId(par2, par3, par4 + 1);
|
||||
int var8 = par1World.getBlockId(par2 - 1, par3, par4);
|
||||
int var9 = par1World.getBlockId(par2 + 1, par3, par4);
|
||||
int var10 = par1World.getBlockId(par2 - 1, par3, par4 - 1);
|
||||
int var11 = par1World.getBlockId(par2 + 1, par3, par4 - 1);
|
||||
int var12 = par1World.getBlockId(par2 + 1, par3, par4 + 1);
|
||||
int var13 = par1World.getBlockId(par2 - 1, par3, par4 + 1);
|
||||
boolean var14 = var8 == this.blockID || var9 == this.blockID;
|
||||
boolean var15 = var6 == this.blockID || var7 == this.blockID;
|
||||
boolean var16 = var10 == this.blockID || var11 == this.blockID || var12 == this.blockID || var13 == this.blockID;
|
||||
|
||||
for (int var17 = par2 - 1; var17 <= par2 + 1; ++var17)
|
||||
{
|
||||
for (int var18 = par4 - 1; var18 <= par4 + 1; ++var18)
|
||||
{
|
||||
int var19 = par1World.getBlockId(var17, par3 - 1, var18);
|
||||
float var20 = 0.0F;
|
||||
|
||||
if (var19 == Block.tilledField.blockID)
|
||||
{
|
||||
var20 = 1.0F;
|
||||
|
||||
if (par1World.getBlockMetadata(var17, par3 - 1, var18) > 0)
|
||||
{
|
||||
var20 = 3.0F;
|
||||
}
|
||||
}
|
||||
|
||||
if (var17 != par2 || var18 != par4)
|
||||
{
|
||||
var20 /= 4.0F;
|
||||
}
|
||||
|
||||
var5 += var20;
|
||||
}
|
||||
}
|
||||
|
||||
if (var16 || var14 && var15)
|
||||
{
|
||||
var5 /= 2.0F;
|
||||
}
|
||||
|
||||
return var5;
|
||||
}
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
if (par2 < 0 || par2 > 7)
|
||||
{
|
||||
par2 = 7;
|
||||
}
|
||||
|
||||
return this.iconArray[par2];
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
public int getRenderType()
|
||||
{
|
||||
return 6;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a seed ItemStack for this crop.
|
||||
*/
|
||||
protected int getSeedItem()
|
||||
{
|
||||
return Item.seeds.itemID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a crop produce ItemStack for this crop.
|
||||
*/
|
||||
protected int getCropItem()
|
||||
{
|
||||
return Item.wheat.itemID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops the block items with a specified chance of dropping the specified items
|
||||
*/
|
||||
public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7)
|
||||
{
|
||||
super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, 0);
|
||||
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
if (par5 >= 7)
|
||||
{
|
||||
int var8 = 3 + par7;
|
||||
|
||||
for (int var9 = 0; var9 < var8; ++var9)
|
||||
{
|
||||
if (par1World.rand.nextInt(15) <= par5)
|
||||
{
|
||||
this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(this.getSeedItem(), 1, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the items to drop on destruction.
|
||||
*/
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return par1 == 7 ? this.getCropItem() : this.getSeedItem();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quantity of items to drop on block destruction.
|
||||
*/
|
||||
public int quantityDropped(Random par1Random)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
|
||||
*/
|
||||
public int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return this.getSeedItem();
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.iconArray = new Icon[8];
|
||||
|
||||
for (int var2 = 0; var2 < this.iconArray.length; ++var2)
|
||||
{
|
||||
this.iconArray[var2] = par1IconRegister.registerIcon(this.getTextureName() + "_stage_" + var2);
|
||||
}
|
||||
}
|
||||
}
|
||||
136
src/main/java/net/minecraft/src/BlockDaylightDetector.java
Normal file
136
src/main/java/net/minecraft/src/BlockDaylightDetector.java
Normal file
@@ -0,0 +1,136 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockDaylightDetector extends BlockContainer
|
||||
{
|
||||
private Icon[] iconArray = new Icon[2];
|
||||
|
||||
public BlockDaylightDetector(int par1)
|
||||
{
|
||||
super(par1, Material.wood);
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.375F, 1.0F);
|
||||
this.setCreativeTab(CreativeTabs.tabRedstone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the blocks bounds based on its current state. Args: world, x, y, z
|
||||
*/
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.375F, 1.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the block is emitting indirect/weak redstone power on the specified side. If isBlockNormalCube
|
||||
* returns true, standard redstone propagation rules will apply instead and this will not be called. Args: World, X,
|
||||
* Y, Z, side. Note that the side is reversed - eg it is 1 (up) when checking the bottom of the block.
|
||||
*/
|
||||
public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return par1IBlockAccess.getBlockMetadata(par2, par3, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticks the block if it's been scheduled
|
||||
*/
|
||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {}
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
||||
* their own) Args: x, y, z, neighbor blockID
|
||||
*/
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {}
|
||||
|
||||
/**
|
||||
* Called whenever the block is added into the world. Args: world, x, y, z
|
||||
*/
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4) {}
|
||||
|
||||
public void updateLightLevel(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if (!par1World.provider.hasNoSky)
|
||||
{
|
||||
int var5 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
int var6 = par1World.getSavedLightValue(EnumSkyBlock.Sky, par2, par3, par4) - par1World.skylightSubtracted;
|
||||
float var7 = par1World.getCelestialAngleRadians(1.0F);
|
||||
|
||||
if (var7 < (float)Math.PI)
|
||||
{
|
||||
var7 += (0.0F - var7) * 0.2F;
|
||||
}
|
||||
else
|
||||
{
|
||||
var7 += (((float)Math.PI * 2F) - var7) * 0.2F;
|
||||
}
|
||||
|
||||
var6 = Math.round((float)var6 * MathHelper.cos(var7));
|
||||
|
||||
if (var6 < 0)
|
||||
{
|
||||
var6 = 0;
|
||||
}
|
||||
|
||||
if (var6 > 15)
|
||||
{
|
||||
var6 = 15;
|
||||
}
|
||||
|
||||
if (var5 != var6)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can this block provide power. Only wire currently seems to have this change based on its state.
|
||||
*/
|
||||
public boolean canProvidePower()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||
*/
|
||||
public TileEntity createNewTileEntity(World par1World)
|
||||
{
|
||||
return new TileEntityDaylightDetector();
|
||||
}
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return par1 == 1 ? this.iconArray[0] : this.iconArray[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.iconArray[0] = par1IconRegister.registerIcon(this.getTextureName() + "_top");
|
||||
this.iconArray[1] = par1IconRegister.registerIcon(this.getTextureName() + "_side");
|
||||
}
|
||||
}
|
||||
47
src/main/java/net/minecraft/src/BlockDeadBush.java
Normal file
47
src/main/java/net/minecraft/src/BlockDeadBush.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockDeadBush extends BlockFlower
|
||||
{
|
||||
protected BlockDeadBush(int par1)
|
||||
{
|
||||
super(par1, Material.vine);
|
||||
float var2 = 0.4F;
|
||||
this.setBlockBounds(0.5F - var2, 0.0F, 0.5F - var2, 0.5F + var2, 0.8F, 0.5F + var2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets passed in the blockID of the block below and supposed to return true if its allowed to grow on the type of
|
||||
* blockID passed in. Args: blockID
|
||||
*/
|
||||
protected boolean canThisPlantGrowOnThisBlockID(int par1)
|
||||
{
|
||||
return par1 == Block.sand.blockID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the items to drop on destruction.
|
||||
*/
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the player destroys a block with an item that can harvest it. (i, j, k) are the coordinates of the
|
||||
* block and l is the block's subtype/damage.
|
||||
*/
|
||||
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
if (!par1World.isRemote && par2EntityPlayer.getCurrentEquippedItem() != null && par2EntityPlayer.getCurrentEquippedItem().itemID == Item.shears.itemID)
|
||||
{
|
||||
par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1);
|
||||
this.dropBlockAsItem_do(par1World, par3, par4, par5, new ItemStack(Block.deadBush, 1, par6));
|
||||
}
|
||||
else
|
||||
{
|
||||
super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
|
||||
}
|
||||
}
|
||||
}
|
||||
178
src/main/java/net/minecraft/src/BlockDetectorRail.java
Normal file
178
src/main/java/net/minecraft/src/BlockDetectorRail.java
Normal file
@@ -0,0 +1,178 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockDetectorRail extends BlockRailBase
|
||||
{
|
||||
private Icon[] iconArray;
|
||||
|
||||
public BlockDetectorRail(int par1)
|
||||
{
|
||||
super(par1, true);
|
||||
this.setTickRandomly(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* How many world ticks before ticking
|
||||
*/
|
||||
public int tickRate(World par1World)
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can this block provide power. Only wire currently seems to have this change based on its state.
|
||||
*/
|
||||
public boolean canProvidePower()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity
|
||||
*/
|
||||
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
int var6 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
if ((var6 & 8) == 0)
|
||||
{
|
||||
this.setStateIfMinecartInteractsWithRail(par1World, par2, par3, par4, var6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticks the block if it's been scheduled
|
||||
*/
|
||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
int var6 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
if ((var6 & 8) != 0)
|
||||
{
|
||||
this.setStateIfMinecartInteractsWithRail(par1World, par2, par3, par4, var6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the block is emitting indirect/weak redstone power on the specified side. If isBlockNormalCube
|
||||
* returns true, standard redstone propagation rules will apply instead and this will not be called. Args: World, X,
|
||||
* Y, Z, side. Note that the side is reversed - eg it is 1 (up) when checking the bottom of the block.
|
||||
*/
|
||||
public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return (par1IBlockAccess.getBlockMetadata(par2, par3, par4) & 8) != 0 ? 15 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the block is emitting direct/strong redstone power on the specified side. Args: World, X, Y, Z,
|
||||
* side. Note that the side is reversed - eg it is 1 (up) when checking the bottom of the block.
|
||||
*/
|
||||
public int isProvidingStrongPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return (par1IBlockAccess.getBlockMetadata(par2, par3, par4) & 8) == 0 ? 0 : (par5 == 1 ? 15 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the detector rail power state if a minecart enter, stays or leave the block.
|
||||
*/
|
||||
private void setStateIfMinecartInteractsWithRail(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
boolean var6 = (par5 & 8) != 0;
|
||||
boolean var7 = false;
|
||||
float var8 = 0.125F;
|
||||
List var9 = par1World.getEntitiesWithinAABB(EntityMinecart.class, AxisAlignedBB.getAABBPool().getAABB((double)((float)par2 + var8), (double)par3, (double)((float)par4 + var8), (double)((float)(par2 + 1) - var8), (double)((float)(par3 + 1) - var8), (double)((float)(par4 + 1) - var8)));
|
||||
|
||||
if (!var9.isEmpty())
|
||||
{
|
||||
var7 = true;
|
||||
}
|
||||
|
||||
if (var7 && !var6)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, par5 | 8, 3);
|
||||
par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this.blockID);
|
||||
par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this.blockID);
|
||||
par1World.markBlockRangeForRenderUpdate(par2, par3, par4, par2, par3, par4);
|
||||
}
|
||||
|
||||
if (!var7 && var6)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, par5 & 7, 3);
|
||||
par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this.blockID);
|
||||
par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this.blockID);
|
||||
par1World.markBlockRangeForRenderUpdate(par2, par3, par4, par2, par3, par4);
|
||||
}
|
||||
|
||||
if (var7)
|
||||
{
|
||||
par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate(par1World));
|
||||
}
|
||||
|
||||
par1World.func_96440_m(par2, par3, par4, this.blockID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever the block is added into the world. Args: world, x, y, z
|
||||
*/
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
super.onBlockAdded(par1World, par2, par3, par4);
|
||||
this.setStateIfMinecartInteractsWithRail(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4));
|
||||
}
|
||||
|
||||
/**
|
||||
* If this returns true, then comparators facing away from this block will use the value from
|
||||
* getComparatorInputOverride instead of the actual redstone signal strength.
|
||||
*/
|
||||
public boolean hasComparatorInputOverride()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* If hasComparatorInputOverride returns true, the return value from this is used instead of the redstone signal
|
||||
* strength when this block inputs to a comparator.
|
||||
*/
|
||||
public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if ((par1World.getBlockMetadata(par2, par3, par4) & 8) > 0)
|
||||
{
|
||||
float var6 = 0.125F;
|
||||
List var7 = par1World.selectEntitiesWithinAABB(EntityMinecart.class, AxisAlignedBB.getAABBPool().getAABB((double)((float)par2 + var6), (double)par3, (double)((float)par4 + var6), (double)((float)(par2 + 1) - var6), (double)((float)(par3 + 1) - var6), (double)((float)(par4 + 1) - var6)), IEntitySelector.selectInventories);
|
||||
|
||||
if (var7.size() > 0)
|
||||
{
|
||||
return Container.calcRedstoneFromInventory((IInventory)var7.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.iconArray = new Icon[2];
|
||||
this.iconArray[0] = par1IconRegister.registerIcon(this.getTextureName());
|
||||
this.iconArray[1] = par1IconRegister.registerIcon(this.getTextureName() + "_powered");
|
||||
}
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return (par2 & 8) != 0 ? this.iconArray[1] : this.iconArray[0];
|
||||
}
|
||||
}
|
||||
17
src/main/java/net/minecraft/src/BlockDirectional.java
Normal file
17
src/main/java/net/minecraft/src/BlockDirectional.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public abstract class BlockDirectional extends Block
|
||||
{
|
||||
protected BlockDirectional(int par1, Material par2Material)
|
||||
{
|
||||
super(par1, par2Material);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the orentation value from the specified metadata
|
||||
*/
|
||||
public static int getDirection(int par0)
|
||||
{
|
||||
return par0 & 3;
|
||||
}
|
||||
}
|
||||
10
src/main/java/net/minecraft/src/BlockDirt.java
Normal file
10
src/main/java/net/minecraft/src/BlockDirt.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class BlockDirt extends Block
|
||||
{
|
||||
protected BlockDirt(int par1)
|
||||
{
|
||||
super(par1, Material.ground);
|
||||
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||
}
|
||||
}
|
||||
291
src/main/java/net/minecraft/src/BlockDispenser.java
Normal file
291
src/main/java/net/minecraft/src/BlockDispenser.java
Normal file
@@ -0,0 +1,291 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockDispenser extends BlockContainer
|
||||
{
|
||||
/** Registry for all dispense behaviors. */
|
||||
public static final IRegistry dispenseBehaviorRegistry = new RegistryDefaulted(new BehaviorDefaultDispenseItem());
|
||||
protected Random random = new Random();
|
||||
protected Icon furnaceTopIcon;
|
||||
protected Icon furnaceFrontIcon;
|
||||
protected Icon field_96473_e;
|
||||
|
||||
protected BlockDispenser(int par1)
|
||||
{
|
||||
super(par1, Material.rock);
|
||||
this.setCreativeTab(CreativeTabs.tabRedstone);
|
||||
}
|
||||
|
||||
/**
|
||||
* How many world ticks before ticking
|
||||
*/
|
||||
public int tickRate(World par1World)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever the block is added into the world. Args: world, x, y, z
|
||||
*/
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
super.onBlockAdded(par1World, par2, par3, par4);
|
||||
this.setDispenserDefaultDirection(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* sets Dispenser block direction so that the front faces an non-opaque block; chooses west to be direction if all
|
||||
* surrounding blocks are opaque.
|
||||
*/
|
||||
private void setDispenserDefaultDirection(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
int var5 = par1World.getBlockId(par2, par3, par4 - 1);
|
||||
int var6 = par1World.getBlockId(par2, par3, par4 + 1);
|
||||
int var7 = par1World.getBlockId(par2 - 1, par3, par4);
|
||||
int var8 = par1World.getBlockId(par2 + 1, par3, par4);
|
||||
byte var9 = 3;
|
||||
|
||||
if (Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var6])
|
||||
{
|
||||
var9 = 3;
|
||||
}
|
||||
|
||||
if (Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var5])
|
||||
{
|
||||
var9 = 2;
|
||||
}
|
||||
|
||||
if (Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var8])
|
||||
{
|
||||
var9 = 5;
|
||||
}
|
||||
|
||||
if (Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var7])
|
||||
{
|
||||
var9 = 4;
|
||||
}
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var9, 2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
int var3 = par2 & 7;
|
||||
return par1 == var3 ? (var3 != 1 && var3 != 0 ? this.furnaceFrontIcon : this.field_96473_e) : (var3 != 1 && var3 != 0 ? (par1 != 1 && par1 != 0 ? this.blockIcon : this.furnaceTopIcon) : this.furnaceTopIcon);
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon("furnace_side");
|
||||
this.furnaceTopIcon = par1IconRegister.registerIcon("furnace_top");
|
||||
this.furnaceFrontIcon = par1IconRegister.registerIcon(this.getTextureName() + "_front_horizontal");
|
||||
this.field_96473_e = par1IconRegister.registerIcon(this.getTextureName() + "_front_vertical");
|
||||
}
|
||||
|
||||
/**
|
||||
* Called upon block activation (right click on the block.)
|
||||
*/
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if (par1World.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
TileEntityDispenser var10 = (TileEntityDispenser)par1World.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
if (var10 != null)
|
||||
{
|
||||
par5EntityPlayer.displayGUIDispenser(var10);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected void dispense(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
BlockSourceImpl var5 = new BlockSourceImpl(par1World, par2, par3, par4);
|
||||
TileEntityDispenser var6 = (TileEntityDispenser)var5.getBlockTileEntity();
|
||||
|
||||
if (var6 != null)
|
||||
{
|
||||
int var7 = var6.getRandomStackFromInventory();
|
||||
|
||||
if (var7 < 0)
|
||||
{
|
||||
par1World.playAuxSFX(1001, par2, par3, par4, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack var8 = var6.getStackInSlot(var7);
|
||||
IBehaviorDispenseItem var9 = this.getBehaviorForItemStack(var8);
|
||||
|
||||
if (var9 != IBehaviorDispenseItem.itemDispenseBehaviorProvider)
|
||||
{
|
||||
ItemStack var10 = var9.dispense(var5, var8);
|
||||
var6.setInventorySlotContents(var7, var10.stackSize == 0 ? null : var10);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the behavior for the given ItemStack.
|
||||
*/
|
||||
protected IBehaviorDispenseItem getBehaviorForItemStack(ItemStack par1ItemStack)
|
||||
{
|
||||
return (IBehaviorDispenseItem)dispenseBehaviorRegistry.getObject(par1ItemStack.getItem());
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
||||
* their own) Args: x, y, z, neighbor blockID
|
||||
*/
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
boolean var6 = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4) || par1World.isBlockIndirectlyGettingPowered(par2, par3 + 1, par4);
|
||||
int var7 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
boolean var8 = (var7 & 8) != 0;
|
||||
|
||||
if (var6 && !var8)
|
||||
{
|
||||
par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate(par1World));
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var7 | 8, 4);
|
||||
}
|
||||
else if (!var6 && var8)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var7 & -9, 4);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticks the block if it's been scheduled
|
||||
*/
|
||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
this.dispense(par1World, par2, par3, par4);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||
*/
|
||||
public TileEntity createNewTileEntity(World par1World)
|
||||
{
|
||||
return new TileEntityDispenser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is placed in the world.
|
||||
*/
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
|
||||
{
|
||||
int var7 = BlockPistonBase.determineOrientation(par1World, par2, par3, par4, par5EntityLivingBase);
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var7, 2);
|
||||
|
||||
if (par6ItemStack.hasDisplayName())
|
||||
{
|
||||
((TileEntityDispenser)par1World.getBlockTileEntity(par2, par3, par4)).setCustomName(par6ItemStack.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on server worlds only when the block has been replaced by a different block ID, or the same block with a
|
||||
* different metadata value, but before the new metadata value is set. Args: World, x, y, z, old block ID, old
|
||||
* metadata
|
||||
*/
|
||||
public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
TileEntityDispenser var7 = (TileEntityDispenser)par1World.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
if (var7 != null)
|
||||
{
|
||||
for (int var8 = 0; var8 < var7.getSizeInventory(); ++var8)
|
||||
{
|
||||
ItemStack var9 = var7.getStackInSlot(var8);
|
||||
|
||||
if (var9 != null)
|
||||
{
|
||||
float var10 = this.random.nextFloat() * 0.8F + 0.1F;
|
||||
float var11 = this.random.nextFloat() * 0.8F + 0.1F;
|
||||
float var12 = this.random.nextFloat() * 0.8F + 0.1F;
|
||||
|
||||
while (var9.stackSize > 0)
|
||||
{
|
||||
int var13 = this.random.nextInt(21) + 10;
|
||||
|
||||
if (var13 > var9.stackSize)
|
||||
{
|
||||
var13 = var9.stackSize;
|
||||
}
|
||||
|
||||
var9.stackSize -= var13;
|
||||
EntityItem var14 = new EntityItem(par1World, (double)((float)par2 + var10), (double)((float)par3 + var11), (double)((float)par4 + var12), new ItemStack(var9.itemID, var13, var9.getItemDamage()));
|
||||
|
||||
if (var9.hasTagCompound())
|
||||
{
|
||||
var14.getEntityItem().setTagCompound((NBTTagCompound)var9.getTagCompound().copy());
|
||||
}
|
||||
|
||||
float var15 = 0.05F;
|
||||
var14.motionX = (double)((float)this.random.nextGaussian() * var15);
|
||||
var14.motionY = (double)((float)this.random.nextGaussian() * var15 + 0.2F);
|
||||
var14.motionZ = (double)((float)this.random.nextGaussian() * var15);
|
||||
par1World.spawnEntityInWorld(var14);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
par1World.func_96440_m(par2, par3, par4, par5);
|
||||
}
|
||||
|
||||
super.breakBlock(par1World, par2, par3, par4, par5, par6);
|
||||
}
|
||||
|
||||
public static IPosition getIPositionFromBlockSource(IBlockSource par0IBlockSource)
|
||||
{
|
||||
EnumFacing var1 = getFacing(par0IBlockSource.getBlockMetadata());
|
||||
double var2 = par0IBlockSource.getX() + 0.7D * (double)var1.getFrontOffsetX();
|
||||
double var4 = par0IBlockSource.getY() + 0.7D * (double)var1.getFrontOffsetY();
|
||||
double var6 = par0IBlockSource.getZ() + 0.7D * (double)var1.getFrontOffsetZ();
|
||||
return new PositionImpl(var2, var4, var6);
|
||||
}
|
||||
|
||||
public static EnumFacing getFacing(int par0)
|
||||
{
|
||||
return EnumFacing.getFront(par0 & 7);
|
||||
}
|
||||
|
||||
/**
|
||||
* If this returns true, then comparators facing away from this block will use the value from
|
||||
* getComparatorInputOverride instead of the actual redstone signal strength.
|
||||
*/
|
||||
public boolean hasComparatorInputOverride()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* If hasComparatorInputOverride returns true, the return value from this is used instead of the redstone signal
|
||||
* strength when this block inputs to a comparator.
|
||||
*/
|
||||
public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return Container.calcRedstoneFromInventory((IInventory)par1World.getBlockTileEntity(par2, par3, par4));
|
||||
}
|
||||
}
|
||||
460
src/main/java/net/minecraft/src/BlockDoor.java
Normal file
460
src/main/java/net/minecraft/src/BlockDoor.java
Normal file
@@ -0,0 +1,460 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockDoor extends Block
|
||||
{
|
||||
private Icon[] field_111044_a;
|
||||
private Icon[] field_111043_b;
|
||||
|
||||
protected BlockDoor(int par1, Material par2Material)
|
||||
{
|
||||
super(par1, par2Material);
|
||||
float var3 = 0.5F;
|
||||
float var4 = 1.0F;
|
||||
this.setBlockBounds(0.5F - var3, 0.0F, 0.5F - var3, 0.5F + var3, var4, 0.5F + var3);
|
||||
}
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return this.field_111043_b[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
|
||||
*/
|
||||
public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if (par5 != 1 && par5 != 0)
|
||||
{
|
||||
int var6 = this.getFullMetadata(par1IBlockAccess, par2, par3, par4);
|
||||
int var7 = var6 & 3;
|
||||
boolean var8 = (var6 & 4) != 0;
|
||||
boolean var9 = false;
|
||||
boolean var10 = (var6 & 8) != 0;
|
||||
|
||||
if (var8)
|
||||
{
|
||||
if (var7 == 0 && par5 == 2)
|
||||
{
|
||||
var9 = !var9;
|
||||
}
|
||||
else if (var7 == 1 && par5 == 5)
|
||||
{
|
||||
var9 = !var9;
|
||||
}
|
||||
else if (var7 == 2 && par5 == 3)
|
||||
{
|
||||
var9 = !var9;
|
||||
}
|
||||
else if (var7 == 3 && par5 == 4)
|
||||
{
|
||||
var9 = !var9;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (var7 == 0 && par5 == 5)
|
||||
{
|
||||
var9 = !var9;
|
||||
}
|
||||
else if (var7 == 1 && par5 == 3)
|
||||
{
|
||||
var9 = !var9;
|
||||
}
|
||||
else if (var7 == 2 && par5 == 4)
|
||||
{
|
||||
var9 = !var9;
|
||||
}
|
||||
else if (var7 == 3 && par5 == 2)
|
||||
{
|
||||
var9 = !var9;
|
||||
}
|
||||
|
||||
if ((var6 & 16) != 0)
|
||||
{
|
||||
var9 = !var9;
|
||||
}
|
||||
}
|
||||
|
||||
return var10 ? this.field_111044_a[var9 ? 1 : 0] : this.field_111043_b[var9 ? 1 : 0];
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.field_111043_b[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.field_111044_a = new Icon[2];
|
||||
this.field_111043_b = new Icon[2];
|
||||
this.field_111044_a[0] = par1IconRegister.registerIcon(this.getTextureName() + "_upper");
|
||||
this.field_111043_b[0] = par1IconRegister.registerIcon(this.getTextureName() + "_lower");
|
||||
this.field_111044_a[1] = new IconFlipped(this.field_111044_a[0], true, false);
|
||||
this.field_111043_b[1] = new IconFlipped(this.field_111043_b[0], true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean getBlocksMovement(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = this.getFullMetadata(par1IBlockAccess, par2, par3, par4);
|
||||
return (var5 & 4) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
public int getRenderType()
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bounding box of the wired rectangular prism to render.
|
||||
*/
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
this.setBlockBoundsBasedOnState(par1World, par2, par3, par4);
|
||||
return super.getSelectedBoundingBoxFromPool(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
|
||||
* cleared to be reused)
|
||||
*/
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
this.setBlockBoundsBasedOnState(par1World, par2, par3, par4);
|
||||
return super.getCollisionBoundingBoxFromPool(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the blocks bounds based on its current state. Args: world, x, y, z
|
||||
*/
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
this.setDoorRotation(this.getFullMetadata(par1IBlockAccess, par2, par3, par4));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 0, 1, 2 or 3 depending on where the hinge is.
|
||||
*/
|
||||
public int getDoorOrientation(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
return this.getFullMetadata(par1IBlockAccess, par2, par3, par4) & 3;
|
||||
}
|
||||
|
||||
public boolean isDoorOpen(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
return (this.getFullMetadata(par1IBlockAccess, par2, par3, par4) & 4) != 0;
|
||||
}
|
||||
|
||||
private void setDoorRotation(int par1)
|
||||
{
|
||||
float var2 = 0.1875F;
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F);
|
||||
int var3 = par1 & 3;
|
||||
boolean var4 = (par1 & 4) != 0;
|
||||
boolean var5 = (par1 & 16) != 0;
|
||||
|
||||
if (var3 == 0)
|
||||
{
|
||||
if (var4)
|
||||
{
|
||||
if (!var5)
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, var2);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 1.0F - var2, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, var2, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else if (var3 == 1)
|
||||
{
|
||||
if (var4)
|
||||
{
|
||||
if (!var5)
|
||||
{
|
||||
this.setBlockBounds(1.0F - var2, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, var2, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, var2);
|
||||
}
|
||||
}
|
||||
else if (var3 == 2)
|
||||
{
|
||||
if (var4)
|
||||
{
|
||||
if (!var5)
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 1.0F - var2, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, var2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(1.0F - var2, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else if (var3 == 3)
|
||||
{
|
||||
if (var4)
|
||||
{
|
||||
if (!var5)
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, var2, 1.0F, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(1.0F - var2, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 1.0F - var2, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is clicked by a player. Args: x, y, z, entityPlayer
|
||||
*/
|
||||
public void onBlockClicked(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) {}
|
||||
|
||||
/**
|
||||
* Called upon block activation (right click on the block.)
|
||||
*/
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if (this.blockMaterial == Material.iron)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int var10 = this.getFullMetadata(par1World, par2, par3, par4);
|
||||
int var11 = var10 & 7;
|
||||
var11 ^= 4;
|
||||
|
||||
if ((var10 & 8) == 0)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var11, 2);
|
||||
par1World.markBlockRangeForRenderUpdate(par2, par3, par4, par2, par3, par4);
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3 - 1, par4, var11, 2);
|
||||
par1World.markBlockRangeForRenderUpdate(par2, par3 - 1, par4, par2, par3, par4);
|
||||
}
|
||||
|
||||
par1World.playAuxSFXAtEntity(par5EntityPlayer, 1003, par2, par3, par4, 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A function to open a door.
|
||||
*/
|
||||
public void onPoweredBlockChange(World par1World, int par2, int par3, int par4, boolean par5)
|
||||
{
|
||||
int var6 = this.getFullMetadata(par1World, par2, par3, par4);
|
||||
boolean var7 = (var6 & 4) != 0;
|
||||
|
||||
if (var7 != par5)
|
||||
{
|
||||
int var8 = var6 & 7;
|
||||
var8 ^= 4;
|
||||
|
||||
if ((var6 & 8) == 0)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var8, 2);
|
||||
par1World.markBlockRangeForRenderUpdate(par2, par3, par4, par2, par3, par4);
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3 - 1, par4, var8, 2);
|
||||
par1World.markBlockRangeForRenderUpdate(par2, par3 - 1, par4, par2, par3, par4);
|
||||
}
|
||||
|
||||
par1World.playAuxSFXAtEntity((EntityPlayer)null, 1003, par2, par3, par4, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
||||
* their own) Args: x, y, z, neighbor blockID
|
||||
*/
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
int var6 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
if ((var6 & 8) == 0)
|
||||
{
|
||||
boolean var7 = false;
|
||||
|
||||
if (par1World.getBlockId(par2, par3 + 1, par4) != this.blockID)
|
||||
{
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
var7 = true;
|
||||
}
|
||||
|
||||
if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4))
|
||||
{
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
var7 = true;
|
||||
|
||||
if (par1World.getBlockId(par2, par3 + 1, par4) == this.blockID)
|
||||
{
|
||||
par1World.setBlockToAir(par2, par3 + 1, par4);
|
||||
}
|
||||
}
|
||||
|
||||
if (var7)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, var6, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean var8 = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4) || par1World.isBlockIndirectlyGettingPowered(par2, par3 + 1, par4);
|
||||
|
||||
if ((var8 || par5 > 0 && Block.blocksList[par5].canProvidePower()) && par5 != this.blockID)
|
||||
{
|
||||
this.onPoweredBlockChange(par1World, par2, par3, par4, var8);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (par1World.getBlockId(par2, par3 - 1, par4) != this.blockID)
|
||||
{
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
}
|
||||
|
||||
if (par5 > 0 && par5 != this.blockID)
|
||||
{
|
||||
this.onNeighborBlockChange(par1World, par2, par3 - 1, par4, par5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the items to drop on destruction.
|
||||
*/
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return (par1 & 8) != 0 ? 0 : (this.blockMaterial == Material.iron ? Item.doorIron.itemID : Item.doorWood.itemID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ray traces through the blocks collision from start vector to end vector returning a ray trace hit. Args: world,
|
||||
* x, y, z, startVec, endVec
|
||||
*/
|
||||
public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3)
|
||||
{
|
||||
this.setBlockBoundsBasedOnState(par1World, par2, par3, par4);
|
||||
return super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
|
||||
*/
|
||||
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return par3 >= 255 ? false : par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) && super.canPlaceBlockAt(par1World, par2, par3, par4) && super.canPlaceBlockAt(par1World, par2, par3 + 1, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mobility information of the block, 0 = free, 1 = can't push but can move over, 2 = total immobility
|
||||
* and stop pistons
|
||||
*/
|
||||
public int getMobilityFlag()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the full metadata value created by combining the metadata of both blocks the door takes up.
|
||||
*/
|
||||
public int getFullMetadata(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
|
||||
boolean var6 = (var5 & 8) != 0;
|
||||
int var7;
|
||||
int var8;
|
||||
|
||||
if (var6)
|
||||
{
|
||||
var7 = par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4);
|
||||
var8 = var5;
|
||||
}
|
||||
else
|
||||
{
|
||||
var7 = var5;
|
||||
var8 = par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4);
|
||||
}
|
||||
|
||||
boolean var9 = (var8 & 1) != 0;
|
||||
return var7 & 7 | (var6 ? 8 : 0) | (var9 ? 16 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
|
||||
*/
|
||||
public int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return this.blockMaterial == Material.iron ? Item.doorIron.itemID : Item.doorWood.itemID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is attempted to be harvested
|
||||
*/
|
||||
public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer)
|
||||
{
|
||||
if (par6EntityPlayer.capabilities.isCreativeMode && (par5 & 8) != 0 && par1World.getBlockId(par2, par3 - 1, par4) == this.blockID)
|
||||
{
|
||||
par1World.setBlockToAir(par2, par3 - 1, par4);
|
||||
}
|
||||
}
|
||||
}
|
||||
178
src/main/java/net/minecraft/src/BlockDragonEgg.java
Normal file
178
src/main/java/net/minecraft/src/BlockDragonEgg.java
Normal file
@@ -0,0 +1,178 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockDragonEgg extends Block
|
||||
{
|
||||
public BlockDragonEgg(int par1)
|
||||
{
|
||||
super(par1, Material.dragonEgg);
|
||||
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 1.0F, 0.9375F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever the block is added into the world. Args: world, x, y, z
|
||||
*/
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate(par1World));
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
||||
* their own) Args: x, y, z, neighbor blockID
|
||||
*/
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate(par1World));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticks the block if it's been scheduled
|
||||
*/
|
||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
this.fallIfPossible(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the dragon egg can fall down, and if so, makes it fall.
|
||||
*/
|
||||
private void fallIfPossible(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if (BlockSand.canFallBelow(par1World, par2, par3 - 1, par4) && par3 >= 0)
|
||||
{
|
||||
byte var5 = 32;
|
||||
|
||||
if (!BlockSand.fallInstantly && par1World.checkChunksExist(par2 - var5, par3 - var5, par4 - var5, par2 + var5, par3 + var5, par4 + var5))
|
||||
{
|
||||
EntityFallingSand var6 = new EntityFallingSand(par1World, (double)((float)par2 + 0.5F), (double)((float)par3 + 0.5F), (double)((float)par4 + 0.5F), this.blockID);
|
||||
par1World.spawnEntityInWorld(var6);
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
|
||||
while (BlockSand.canFallBelow(par1World, par2, par3 - 1, par4) && par3 > 0)
|
||||
{
|
||||
--par3;
|
||||
}
|
||||
|
||||
if (par3 > 0)
|
||||
{
|
||||
par1World.setBlock(par2, par3, par4, this.blockID, 0, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called upon block activation (right click on the block.)
|
||||
*/
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
this.teleportNearby(par1World, par2, par3, par4);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is clicked by a player. Args: x, y, z, entityPlayer
|
||||
*/
|
||||
public void onBlockClicked(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
|
||||
{
|
||||
this.teleportNearby(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Teleports the dragon egg somewhere else in a 31x19x31 area centered on the egg.
|
||||
*/
|
||||
private void teleportNearby(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if (par1World.getBlockId(par2, par3, par4) == this.blockID)
|
||||
{
|
||||
for (int var5 = 0; var5 < 1000; ++var5)
|
||||
{
|
||||
int var6 = par2 + par1World.rand.nextInt(16) - par1World.rand.nextInt(16);
|
||||
int var7 = par3 + par1World.rand.nextInt(8) - par1World.rand.nextInt(8);
|
||||
int var8 = par4 + par1World.rand.nextInt(16) - par1World.rand.nextInt(16);
|
||||
|
||||
if (par1World.getBlockId(var6, var7, var8) == 0)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
par1World.setBlock(var6, var7, var8, this.blockID, par1World.getBlockMetadata(par2, par3, par4), 2);
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
}
|
||||
else
|
||||
{
|
||||
short var9 = 128;
|
||||
|
||||
for (int var10 = 0; var10 < var9; ++var10)
|
||||
{
|
||||
double var11 = par1World.rand.nextDouble();
|
||||
float var13 = (par1World.rand.nextFloat() - 0.5F) * 0.2F;
|
||||
float var14 = (par1World.rand.nextFloat() - 0.5F) * 0.2F;
|
||||
float var15 = (par1World.rand.nextFloat() - 0.5F) * 0.2F;
|
||||
double var16 = (double)var6 + (double)(par2 - var6) * var11 + (par1World.rand.nextDouble() - 0.5D) * 1.0D + 0.5D;
|
||||
double var18 = (double)var7 + (double)(par3 - var7) * var11 + par1World.rand.nextDouble() * 1.0D - 0.5D;
|
||||
double var20 = (double)var8 + (double)(par4 - var8) * var11 + (par1World.rand.nextDouble() - 0.5D) * 1.0D + 0.5D;
|
||||
par1World.spawnParticle("portal", var16, var18, var20, (double)var13, (double)var14, (double)var15);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* How many world ticks before ticking
|
||||
*/
|
||||
public int tickRate(World par1World)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
|
||||
* coordinates. Args: blockAccess, x, y, z, side
|
||||
*/
|
||||
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
public int getRenderType()
|
||||
{
|
||||
return 27;
|
||||
}
|
||||
|
||||
/**
|
||||
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
|
||||
*/
|
||||
public int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
92
src/main/java/net/minecraft/src/BlockDropper.java
Normal file
92
src/main/java/net/minecraft/src/BlockDropper.java
Normal file
@@ -0,0 +1,92 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class BlockDropper extends BlockDispenser
|
||||
{
|
||||
private final IBehaviorDispenseItem dropperDefaultBehaviour = new BehaviorDefaultDispenseItem();
|
||||
|
||||
protected BlockDropper(int par1)
|
||||
{
|
||||
super(par1);
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon("furnace_side");
|
||||
this.furnaceTopIcon = par1IconRegister.registerIcon("furnace_top");
|
||||
this.furnaceFrontIcon = par1IconRegister.registerIcon(this.getTextureName() + "_front_horizontal");
|
||||
this.field_96473_e = par1IconRegister.registerIcon(this.getTextureName() + "_front_vertical");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the behavior for the given ItemStack.
|
||||
*/
|
||||
protected IBehaviorDispenseItem getBehaviorForItemStack(ItemStack par1ItemStack)
|
||||
{
|
||||
return this.dropperDefaultBehaviour;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||
*/
|
||||
public TileEntity createNewTileEntity(World par1World)
|
||||
{
|
||||
return new TileEntityDropper();
|
||||
}
|
||||
|
||||
protected void dispense(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
BlockSourceImpl var5 = new BlockSourceImpl(par1World, par2, par3, par4);
|
||||
TileEntityDispenser var6 = (TileEntityDispenser)var5.getBlockTileEntity();
|
||||
|
||||
if (var6 != null)
|
||||
{
|
||||
int var7 = var6.getRandomStackFromInventory();
|
||||
|
||||
if (var7 < 0)
|
||||
{
|
||||
par1World.playAuxSFX(1001, par2, par3, par4, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack var8 = var6.getStackInSlot(var7);
|
||||
int var9 = par1World.getBlockMetadata(par2, par3, par4) & 7;
|
||||
IInventory var10 = TileEntityHopper.getInventoryAtLocation(par1World, (double)(par2 + Facing.offsetsXForSide[var9]), (double)(par3 + Facing.offsetsYForSide[var9]), (double)(par4 + Facing.offsetsZForSide[var9]));
|
||||
ItemStack var11;
|
||||
|
||||
if (var10 != null)
|
||||
{
|
||||
var11 = TileEntityHopper.insertStack(var10, var8.copy().splitStack(1), Facing.oppositeSide[var9]);
|
||||
|
||||
if (var11 == null)
|
||||
{
|
||||
var11 = var8.copy();
|
||||
|
||||
if (--var11.stackSize == 0)
|
||||
{
|
||||
var11 = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var11 = var8.copy();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var11 = this.dropperDefaultBehaviour.dispense(var5, var8);
|
||||
|
||||
if (var11 != null && var11.stackSize == 0)
|
||||
{
|
||||
var11 = null;
|
||||
}
|
||||
}
|
||||
|
||||
var6.setInventorySlotContents(var7, var11);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
126
src/main/java/net/minecraft/src/BlockEnchantmentTable.java
Normal file
126
src/main/java/net/minecraft/src/BlockEnchantmentTable.java
Normal file
@@ -0,0 +1,126 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockEnchantmentTable extends BlockContainer
|
||||
{
|
||||
private Icon field_94461_a;
|
||||
private Icon field_94460_b;
|
||||
|
||||
protected BlockEnchantmentTable(int par1)
|
||||
{
|
||||
super(par1, Material.rock);
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.75F, 1.0F);
|
||||
this.setLightOpacity(0);
|
||||
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* A randomly called display update to be able to add particles or other items for display
|
||||
*/
|
||||
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
super.randomDisplayTick(par1World, par2, par3, par4, par5Random);
|
||||
|
||||
for (int var6 = par2 - 2; var6 <= par2 + 2; ++var6)
|
||||
{
|
||||
for (int var7 = par4 - 2; var7 <= par4 + 2; ++var7)
|
||||
{
|
||||
if (var6 > par2 - 2 && var6 < par2 + 2 && var7 == par4 - 1)
|
||||
{
|
||||
var7 = par4 + 2;
|
||||
}
|
||||
|
||||
if (par5Random.nextInt(16) == 0)
|
||||
{
|
||||
for (int var8 = par3; var8 <= par3 + 1; ++var8)
|
||||
{
|
||||
if (par1World.getBlockId(var6, var8, var7) == Block.bookShelf.blockID)
|
||||
{
|
||||
if (!par1World.isAirBlock((var6 - par2) / 2 + par2, var8, (var7 - par4) / 2 + par4))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
par1World.spawnParticle("enchantmenttable", (double)par2 + 0.5D, (double)par3 + 2.0D, (double)par4 + 0.5D, (double)((float)(var6 - par2) + par5Random.nextFloat()) - 0.5D, (double)((float)(var8 - par3) - par5Random.nextFloat() - 1.0F), (double)((float)(var7 - par4) + par5Random.nextFloat()) - 0.5D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return par1 == 0 ? this.field_94460_b : (par1 == 1 ? this.field_94461_a : this.blockIcon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||
*/
|
||||
public TileEntity createNewTileEntity(World par1World)
|
||||
{
|
||||
return new TileEntityEnchantmentTable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called upon block activation (right click on the block.)
|
||||
*/
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if (par1World.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
TileEntityEnchantmentTable var10 = (TileEntityEnchantmentTable)par1World.getBlockTileEntity(par2, par3, par4);
|
||||
par5EntityPlayer.displayGUIEnchantment(par2, par3, par4, var10.func_94135_b() ? var10.func_94133_a() : null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is placed in the world.
|
||||
*/
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
|
||||
{
|
||||
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
|
||||
|
||||
if (par6ItemStack.hasDisplayName())
|
||||
{
|
||||
((TileEntityEnchantmentTable)par1World.getBlockTileEntity(par2, par3, par4)).func_94134_a(par6ItemStack.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(this.getTextureName() + "_" + "side");
|
||||
this.field_94461_a = par1IconRegister.registerIcon(this.getTextureName() + "_" + "top");
|
||||
this.field_94460_b = par1IconRegister.registerIcon(this.getTextureName() + "_" + "bottom");
|
||||
}
|
||||
}
|
||||
139
src/main/java/net/minecraft/src/BlockEndPortal.java
Normal file
139
src/main/java/net/minecraft/src/BlockEndPortal.java
Normal file
@@ -0,0 +1,139 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockEndPortal extends BlockContainer
|
||||
{
|
||||
/**
|
||||
* true if the enderdragon has been killed - allows end portal blocks to be created in the end
|
||||
*/
|
||||
public static boolean bossDefeated;
|
||||
|
||||
protected BlockEndPortal(int par1, Material par2Material)
|
||||
{
|
||||
super(par1, par2Material);
|
||||
this.setLightValue(1.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||
*/
|
||||
public TileEntity createNewTileEntity(World par1World)
|
||||
{
|
||||
return new TileEntityEndPortal();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the blocks bounds based on its current state. Args: world, x, y, z
|
||||
*/
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
float var5 = 0.0625F;
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, var5, 1.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
|
||||
* coordinates. Args: blockAccess, x, y, z, side
|
||||
*/
|
||||
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return par5 != 0 ? false : super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the list if they intersect the
|
||||
* mask.) Parameters: World, X, Y, Z, mask, list, colliding entity
|
||||
*/
|
||||
public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) {}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quantity of items to drop on block destruction.
|
||||
*/
|
||||
public int quantityDropped(Random par1Random)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity
|
||||
*/
|
||||
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
|
||||
{
|
||||
if (par5Entity.ridingEntity == null && par5Entity.riddenByEntity == null && !par1World.isRemote)
|
||||
{
|
||||
par5Entity.travelToDimension(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A randomly called display update to be able to add particles or other items for display
|
||||
*/
|
||||
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
double var6 = (double)((float)par2 + par5Random.nextFloat());
|
||||
double var8 = (double)((float)par3 + 0.8F);
|
||||
double var10 = (double)((float)par4 + par5Random.nextFloat());
|
||||
double var12 = 0.0D;
|
||||
double var14 = 0.0D;
|
||||
double var16 = 0.0D;
|
||||
par1World.spawnParticle("smoke", var6, var8, var10, var12, var14, var16);
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
public int getRenderType()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever the block is added into the world. Args: world, x, y, z
|
||||
*/
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if (!bossDefeated)
|
||||
{
|
||||
if (par1World.provider.dimensionId != 0)
|
||||
{
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
|
||||
*/
|
||||
public int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon("portal");
|
||||
}
|
||||
}
|
||||
127
src/main/java/net/minecraft/src/BlockEndPortalFrame.java
Normal file
127
src/main/java/net/minecraft/src/BlockEndPortalFrame.java
Normal file
@@ -0,0 +1,127 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockEndPortalFrame extends Block
|
||||
{
|
||||
private Icon field_94400_a;
|
||||
private Icon field_94399_b;
|
||||
|
||||
public BlockEndPortalFrame(int par1)
|
||||
{
|
||||
super(par1, Material.rock);
|
||||
}
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return par1 == 1 ? this.field_94400_a : (par1 == 0 ? Block.whiteStone.getBlockTextureFromSide(par1) : this.blockIcon);
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(this.getTextureName() + "_side");
|
||||
this.field_94400_a = par1IconRegister.registerIcon(this.getTextureName() + "_top");
|
||||
this.field_94399_b = par1IconRegister.registerIcon(this.getTextureName() + "_eye");
|
||||
}
|
||||
|
||||
public Icon func_94398_p()
|
||||
{
|
||||
return this.field_94399_b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
public int getRenderType()
|
||||
{
|
||||
return 26;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the block's bounds for rendering it as an item
|
||||
*/
|
||||
public void setBlockBoundsForItemRender()
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.8125F, 1.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the list if they intersect the
|
||||
* mask.) Parameters: World, X, Y, Z, mask, list, colliding entity
|
||||
*/
|
||||
public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.8125F, 1.0F);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
int var8 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
if (isEnderEyeInserted(var8))
|
||||
{
|
||||
this.setBlockBounds(0.3125F, 0.8125F, 0.3125F, 0.6875F, 1.0F, 0.6875F);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
}
|
||||
|
||||
this.setBlockBoundsForItemRender();
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if an ender eye has been inserted into the frame block. parameters: metadata
|
||||
*/
|
||||
public static boolean isEnderEyeInserted(int par0)
|
||||
{
|
||||
return (par0 & 4) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the items to drop on destruction.
|
||||
*/
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is placed in the world.
|
||||
*/
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
|
||||
{
|
||||
int var7 = ((MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) + 2) % 4;
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var7, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* If this returns true, then comparators facing away from this block will use the value from
|
||||
* getComparatorInputOverride instead of the actual redstone signal strength.
|
||||
*/
|
||||
public boolean hasComparatorInputOverride()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* If hasComparatorInputOverride returns true, the return value from this is used instead of the redstone signal
|
||||
* strength when this block inputs to a comparator.
|
||||
*/
|
||||
public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
int var6 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
return isEnderEyeInserted(var6) ? 15 : 0;
|
||||
}
|
||||
}
|
||||
167
src/main/java/net/minecraft/src/BlockEnderChest.java
Normal file
167
src/main/java/net/minecraft/src/BlockEnderChest.java
Normal file
@@ -0,0 +1,167 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockEnderChest extends BlockContainer
|
||||
{
|
||||
protected BlockEnderChest(int par1)
|
||||
{
|
||||
super(par1, Material.rock);
|
||||
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
public int getRenderType()
|
||||
{
|
||||
return 22;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the items to drop on destruction.
|
||||
*/
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return Block.obsidian.blockID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quantity of items to drop on block destruction.
|
||||
*/
|
||||
public int quantityDropped(Random par1Random)
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if a player with Silk Touch can harvest this block directly, and not its normal drops.
|
||||
*/
|
||||
protected boolean canSilkHarvest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is placed in the world.
|
||||
*/
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
|
||||
{
|
||||
byte var7 = 0;
|
||||
int var8 = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
|
||||
if (var8 == 0)
|
||||
{
|
||||
var7 = 2;
|
||||
}
|
||||
|
||||
if (var8 == 1)
|
||||
{
|
||||
var7 = 5;
|
||||
}
|
||||
|
||||
if (var8 == 2)
|
||||
{
|
||||
var7 = 3;
|
||||
}
|
||||
|
||||
if (var8 == 3)
|
||||
{
|
||||
var7 = 4;
|
||||
}
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var7, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called upon block activation (right click on the block.)
|
||||
*/
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
InventoryEnderChest var10 = par5EntityPlayer.getInventoryEnderChest();
|
||||
TileEntityEnderChest var11 = (TileEntityEnderChest)par1World.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
if (var10 != null && var11 != null)
|
||||
{
|
||||
if (par1World.isBlockNormalCube(par2, par3 + 1, par4))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (par1World.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
var10.setAssociatedChest(var11);
|
||||
par5EntityPlayer.displayGUIChest(var10);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
||||
*/
|
||||
public TileEntity createNewTileEntity(World par1World)
|
||||
{
|
||||
return new TileEntityEnderChest();
|
||||
}
|
||||
|
||||
/**
|
||||
* A randomly called display update to be able to add particles or other items for display
|
||||
*/
|
||||
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
for (int var6 = 0; var6 < 3; ++var6)
|
||||
{
|
||||
double var10000 = (double)((float)par2 + par5Random.nextFloat());
|
||||
double var9 = (double)((float)par3 + par5Random.nextFloat());
|
||||
var10000 = (double)((float)par4 + par5Random.nextFloat());
|
||||
double var13 = 0.0D;
|
||||
double var15 = 0.0D;
|
||||
double var17 = 0.0D;
|
||||
int var19 = par5Random.nextInt(2) * 2 - 1;
|
||||
int var20 = par5Random.nextInt(2) * 2 - 1;
|
||||
var13 = ((double)par5Random.nextFloat() - 0.5D) * 0.125D;
|
||||
var15 = ((double)par5Random.nextFloat() - 0.5D) * 0.125D;
|
||||
var17 = ((double)par5Random.nextFloat() - 0.5D) * 0.125D;
|
||||
double var11 = (double)par4 + 0.5D + 0.25D * (double)var20;
|
||||
var17 = (double)(par5Random.nextFloat() * 1.0F * (float)var20);
|
||||
double var7 = (double)par2 + 0.5D + 0.25D * (double)var19;
|
||||
var13 = (double)(par5Random.nextFloat() * 1.0F * (float)var19);
|
||||
par1World.spawnParticle("portal", var7, var9, var11, var13, var15, var17);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon("obsidian");
|
||||
}
|
||||
}
|
||||
91
src/main/java/net/minecraft/src/BlockEventData.java
Normal file
91
src/main/java/net/minecraft/src/BlockEventData.java
Normal file
@@ -0,0 +1,91 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class BlockEventData
|
||||
{
|
||||
private int coordX;
|
||||
private int coordY;
|
||||
private int coordZ;
|
||||
private int blockID;
|
||||
|
||||
/** Different for each blockID */
|
||||
private int eventID;
|
||||
|
||||
/** Different for each blockID, eventID */
|
||||
private int eventParameter;
|
||||
|
||||
public BlockEventData(int par1, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
this.coordX = par1;
|
||||
this.coordY = par2;
|
||||
this.coordZ = par3;
|
||||
this.eventID = par5;
|
||||
this.eventParameter = par6;
|
||||
this.blockID = par4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the X coordinate.
|
||||
*/
|
||||
public int getX()
|
||||
{
|
||||
return this.coordX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Y coordinate.
|
||||
*/
|
||||
public int getY()
|
||||
{
|
||||
return this.coordY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Z coordinate.
|
||||
*/
|
||||
public int getZ()
|
||||
{
|
||||
return this.coordZ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Event ID (different for each BlockID)
|
||||
*/
|
||||
public int getEventID()
|
||||
{
|
||||
return this.eventID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Event Parameter (different for each BlockID,EventID)
|
||||
*/
|
||||
public int getEventParameter()
|
||||
{
|
||||
return this.eventParameter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the BlockID for this BlockEventData
|
||||
*/
|
||||
public int getBlockID()
|
||||
{
|
||||
return this.blockID;
|
||||
}
|
||||
|
||||
public boolean equals(Object par1Obj)
|
||||
{
|
||||
if (!(par1Obj instanceof BlockEventData))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockEventData var2 = (BlockEventData)par1Obj;
|
||||
return this.coordX == var2.coordX && this.coordY == var2.coordY && this.coordZ == var2.coordZ && this.eventID == var2.eventID && this.eventParameter == var2.eventParameter && this.blockID == var2.blockID;
|
||||
}
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "TE(" + this.coordX + "," + this.coordY + "," + this.coordZ + ")," + this.eventID + "," + this.eventParameter + "," + this.blockID;
|
||||
}
|
||||
}
|
||||
177
src/main/java/net/minecraft/src/BlockFarmland.java
Normal file
177
src/main/java/net/minecraft/src/BlockFarmland.java
Normal file
@@ -0,0 +1,177 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockFarmland extends Block
|
||||
{
|
||||
private Icon field_94441_a;
|
||||
private Icon field_94440_b;
|
||||
|
||||
protected BlockFarmland(int par1)
|
||||
{
|
||||
super(par1, Material.ground);
|
||||
this.setTickRandomly(true);
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.9375F, 1.0F);
|
||||
this.setLightOpacity(255);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
|
||||
* cleared to be reused)
|
||||
*/
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return AxisAlignedBB.getAABBPool().getAABB((double)(par2 + 0), (double)(par3 + 0), (double)(par4 + 0), (double)(par2 + 1), (double)(par3 + 1), (double)(par4 + 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return par1 == 1 ? (par2 > 0 ? this.field_94441_a : this.field_94440_b) : Block.dirt.getBlockTextureFromSide(par1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticks the block if it's been scheduled
|
||||
*/
|
||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
if (!this.isWaterNearby(par1World, par2, par3, par4) && !par1World.canLightningStrikeAt(par2, par3 + 1, par4))
|
||||
{
|
||||
int var6 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
if (var6 > 0)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6 - 1, 2);
|
||||
}
|
||||
else if (!this.isCropsNearby(par1World, par2, par3, par4))
|
||||
{
|
||||
par1World.setBlock(par2, par3, par4, Block.dirt.blockID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 7, 2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Block's chance to react to an entity falling on it.
|
||||
*/
|
||||
public void onFallenUpon(World par1World, int par2, int par3, int par4, Entity par5Entity, float par6)
|
||||
{
|
||||
if (!par1World.isRemote && par1World.rand.nextFloat() < par6 - 0.5F)
|
||||
{
|
||||
if (!(par5Entity instanceof EntityPlayer) && !par1World.getGameRules().getGameRuleBooleanValue("mobGriefing"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
par1World.setBlock(par2, par3, par4, Block.dirt.blockID);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns true if there is at least one cropblock nearby (x-1 to x+1, y+1, z-1 to z+1)
|
||||
*/
|
||||
private boolean isCropsNearby(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
byte var5 = 0;
|
||||
|
||||
for (int var6 = par2 - var5; var6 <= par2 + var5; ++var6)
|
||||
{
|
||||
for (int var7 = par4 - var5; var7 <= par4 + var5; ++var7)
|
||||
{
|
||||
int var8 = par1World.getBlockId(var6, par3 + 1, var7);
|
||||
|
||||
if (var8 == Block.crops.blockID || var8 == Block.melonStem.blockID || var8 == Block.pumpkinStem.blockID || var8 == Block.potato.blockID || var8 == Block.carrot.blockID)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns true if there's water nearby (x-4 to x+4, y to y+1, k-4 to k+4)
|
||||
*/
|
||||
private boolean isWaterNearby(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
for (int var5 = par2 - 4; var5 <= par2 + 4; ++var5)
|
||||
{
|
||||
for (int var6 = par3; var6 <= par3 + 1; ++var6)
|
||||
{
|
||||
for (int var7 = par4 - 4; var7 <= par4 + 4; ++var7)
|
||||
{
|
||||
if (par1World.getBlockMaterial(var5, var6, var7) == Material.water)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
||||
* their own) Args: x, y, z, neighbor blockID
|
||||
*/
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
|
||||
Material var6 = par1World.getBlockMaterial(par2, par3 + 1, par4);
|
||||
|
||||
if (var6.isSolid())
|
||||
{
|
||||
par1World.setBlock(par2, par3, par4, Block.dirt.blockID);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the items to drop on destruction.
|
||||
*/
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return Block.dirt.idDropped(0, par2Random, par3);
|
||||
}
|
||||
|
||||
/**
|
||||
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
|
||||
*/
|
||||
public int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return Block.dirt.blockID;
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.field_94441_a = par1IconRegister.registerIcon(this.getTextureName() + "_wet");
|
||||
this.field_94440_b = par1IconRegister.registerIcon(this.getTextureName() + "_dry");
|
||||
}
|
||||
}
|
||||
194
src/main/java/net/minecraft/src/BlockFence.java
Normal file
194
src/main/java/net/minecraft/src/BlockFence.java
Normal file
@@ -0,0 +1,194 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlockFence extends Block
|
||||
{
|
||||
private final String field_94464_a;
|
||||
|
||||
public BlockFence(int par1, String par2Str, Material par3Material)
|
||||
{
|
||||
super(par1, par3Material);
|
||||
this.field_94464_a = par2Str;
|
||||
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the list if they intersect the
|
||||
* mask.) Parameters: World, X, Y, Z, mask, list, colliding entity
|
||||
*/
|
||||
public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
|
||||
{
|
||||
boolean var8 = this.canConnectFenceTo(par1World, par2, par3, par4 - 1);
|
||||
boolean var9 = this.canConnectFenceTo(par1World, par2, par3, par4 + 1);
|
||||
boolean var10 = this.canConnectFenceTo(par1World, par2 - 1, par3, par4);
|
||||
boolean var11 = this.canConnectFenceTo(par1World, par2 + 1, par3, par4);
|
||||
float var12 = 0.375F;
|
||||
float var13 = 0.625F;
|
||||
float var14 = 0.375F;
|
||||
float var15 = 0.625F;
|
||||
|
||||
if (var8)
|
||||
{
|
||||
var14 = 0.0F;
|
||||
}
|
||||
|
||||
if (var9)
|
||||
{
|
||||
var15 = 1.0F;
|
||||
}
|
||||
|
||||
if (var8 || var9)
|
||||
{
|
||||
this.setBlockBounds(var12, 0.0F, var14, var13, 1.5F, var15);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
}
|
||||
|
||||
var14 = 0.375F;
|
||||
var15 = 0.625F;
|
||||
|
||||
if (var10)
|
||||
{
|
||||
var12 = 0.0F;
|
||||
}
|
||||
|
||||
if (var11)
|
||||
{
|
||||
var13 = 1.0F;
|
||||
}
|
||||
|
||||
if (var10 || var11 || !var8 && !var9)
|
||||
{
|
||||
this.setBlockBounds(var12, 0.0F, var14, var13, 1.5F, var15);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
}
|
||||
|
||||
if (var8)
|
||||
{
|
||||
var14 = 0.0F;
|
||||
}
|
||||
|
||||
if (var9)
|
||||
{
|
||||
var15 = 1.0F;
|
||||
}
|
||||
|
||||
this.setBlockBounds(var12, 0.0F, var14, var13, 1.0F, var15);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the blocks bounds based on its current state. Args: world, x, y, z
|
||||
*/
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
boolean var5 = this.canConnectFenceTo(par1IBlockAccess, par2, par3, par4 - 1);
|
||||
boolean var6 = this.canConnectFenceTo(par1IBlockAccess, par2, par3, par4 + 1);
|
||||
boolean var7 = this.canConnectFenceTo(par1IBlockAccess, par2 - 1, par3, par4);
|
||||
boolean var8 = this.canConnectFenceTo(par1IBlockAccess, par2 + 1, par3, par4);
|
||||
float var9 = 0.375F;
|
||||
float var10 = 0.625F;
|
||||
float var11 = 0.375F;
|
||||
float var12 = 0.625F;
|
||||
|
||||
if (var5)
|
||||
{
|
||||
var11 = 0.0F;
|
||||
}
|
||||
|
||||
if (var6)
|
||||
{
|
||||
var12 = 1.0F;
|
||||
}
|
||||
|
||||
if (var7)
|
||||
{
|
||||
var9 = 0.0F;
|
||||
}
|
||||
|
||||
if (var8)
|
||||
{
|
||||
var10 = 1.0F;
|
||||
}
|
||||
|
||||
this.setBlockBounds(var9, 0.0F, var11, var10, 1.0F, var12);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean getBlocksMovement(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
public int getRenderType()
|
||||
{
|
||||
return 11;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the specified block can be connected by a fence
|
||||
*/
|
||||
public boolean canConnectFenceTo(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = par1IBlockAccess.getBlockId(par2, par3, par4);
|
||||
|
||||
if (var5 != this.blockID && var5 != Block.fenceGate.blockID)
|
||||
{
|
||||
Block var6 = Block.blocksList[var5];
|
||||
return var6 != null && var6.blockMaterial.isOpaque() && var6.renderAsNormalBlock() ? var6.blockMaterial != Material.pumpkin : false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isIdAFence(int par0)
|
||||
{
|
||||
return par0 == Block.fence.blockID || par0 == Block.netherFence.blockID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
|
||||
* coordinates. Args: blockAccess, x, y, z, side
|
||||
*/
|
||||
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(this.field_94464_a);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called upon block activation (right click on the block.)
|
||||
*/
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
return par1World.isRemote ? true : ItemLeash.func_135066_a(par5EntityPlayer, par1World, par2, par3, par4);
|
||||
}
|
||||
}
|
||||
170
src/main/java/net/minecraft/src/BlockFenceGate.java
Normal file
170
src/main/java/net/minecraft/src/BlockFenceGate.java
Normal file
@@ -0,0 +1,170 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public class BlockFenceGate extends BlockDirectional
|
||||
{
|
||||
public BlockFenceGate(int par1)
|
||||
{
|
||||
super(par1, Material.wood);
|
||||
this.setCreativeTab(CreativeTabs.tabRedstone);
|
||||
}
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return Block.planks.getBlockTextureFromSide(par1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
|
||||
*/
|
||||
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return !par1World.getBlockMaterial(par2, par3 - 1, par4).isSolid() ? false : super.canPlaceBlockAt(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
|
||||
* cleared to be reused)
|
||||
*/
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
return isFenceGateOpen(var5) ? null : (var5 != 2 && var5 != 0 ? AxisAlignedBB.getAABBPool().getAABB((double)((float)par2 + 0.375F), (double)par3, (double)par4, (double)((float)par2 + 0.625F), (double)((float)par3 + 1.5F), (double)(par4 + 1)) : AxisAlignedBB.getAABBPool().getAABB((double)par2, (double)par3, (double)((float)par4 + 0.375F), (double)(par2 + 1), (double)((float)par3 + 1.5F), (double)((float)par4 + 0.625F)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the blocks bounds based on its current state. Args: world, x, y, z
|
||||
*/
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = getDirection(par1IBlockAccess.getBlockMetadata(par2, par3, par4));
|
||||
|
||||
if (var5 != 2 && var5 != 0)
|
||||
{
|
||||
this.setBlockBounds(0.375F, 0.0F, 0.0F, 0.625F, 1.0F, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.375F, 1.0F, 1.0F, 0.625F);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean getBlocksMovement(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
return isFenceGateOpen(par1IBlockAccess.getBlockMetadata(par2, par3, par4));
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
public int getRenderType()
|
||||
{
|
||||
return 21;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is placed in the world.
|
||||
*/
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
|
||||
{
|
||||
int var7 = (MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) % 4;
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var7, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called upon block activation (right click on the block.)
|
||||
*/
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
int var10 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
if (isFenceGateOpen(var10))
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var10 & -5, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
int var11 = (MathHelper.floor_double((double)(par5EntityPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) % 4;
|
||||
int var12 = getDirection(var10);
|
||||
|
||||
if (var12 == (var11 + 2) % 4)
|
||||
{
|
||||
var10 = var11;
|
||||
}
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var10 | 4, 2);
|
||||
}
|
||||
|
||||
par1World.playAuxSFXAtEntity(par5EntityPlayer, 1003, par2, par3, par4, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
||||
* their own) Args: x, y, z, neighbor blockID
|
||||
*/
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
int var6 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
boolean var7 = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4);
|
||||
|
||||
if (var7 || par5 > 0 && Block.blocksList[par5].canProvidePower())
|
||||
{
|
||||
if (var7 && !isFenceGateOpen(var6))
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6 | 4, 2);
|
||||
par1World.playAuxSFXAtEntity((EntityPlayer)null, 1003, par2, par3, par4, 0);
|
||||
}
|
||||
else if (!var7 && isFenceGateOpen(var6))
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6 & -5, 2);
|
||||
par1World.playAuxSFXAtEntity((EntityPlayer)null, 1003, par2, par3, par4, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the fence gate is open according to its metadata.
|
||||
*/
|
||||
public static boolean isFenceGateOpen(int par0)
|
||||
{
|
||||
return (par0 & 4) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
|
||||
* coordinates. Args: blockAccess, x, y, z, side
|
||||
*/
|
||||
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons(IconRegister par1IconRegister) {}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user