ForgePatch/forge/minecraft-fern.patch

637 lines
27 KiB
Diff

diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/Block.java ../src_work/minecraft/net/minecraft/src/Block.java
--- ../src_base/minecraft/net/minecraft/src/Block.java 2011-08-12 13:47:09.501407000 +0200
+++ ../src_work/minecraft/net/minecraft/src/Block.java 2011-08-12 13:55:57.161587800 +0200
@@ -637,6 +637,10 @@
public int getMobilityFlag() {
return this.blockMaterial.getMaterialMobility();
}
+
+ public boolean isLadder() {
+ return false;
+ }
static {
Item.itemsList[cloth.blockID] = (new ItemCloth(cloth.blockID - 256)).setItemName("cloth");
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/BlockLadder.java ../src_work/minecraft/net/minecraft/src/BlockLadder.java
--- ../src_base/minecraft/net/minecraft/src/BlockLadder.java 2011-08-12 13:47:09.859427000 +0200
+++ ../src_work/minecraft/net/minecraft/src/BlockLadder.java 2011-08-12 13:57:35.729225600 +0200
@@ -55,6 +55,10 @@
return super.getSelectedBoundingBoxFromPool(var1, var2, var3, var4);
}
+
+ public boolean isLadder() {
+ return true;
+ }
public boolean isOpaqueCube() {
return false;
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/BlockRedstoneWire.java ../src_work/minecraft/net/minecraft/src/BlockRedstoneWire.java
--- ../src_base/minecraft/net/minecraft/src/BlockRedstoneWire.java 2011-08-12 13:47:10.092441000 +0200
+++ ../src_work/minecraft/net/minecraft/src/BlockRedstoneWire.java 2011-08-12 14:01:13.353673000 +0200
@@ -1,5 +1,6 @@
package net.minecraft.src;
+import net.minecraft.src.forge.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Random;
@@ -369,6 +370,9 @@
return true;
} else if(var5 == 0) {
return false;
+ } else if (Block.blocksList[var5] instanceof IConnectRedstone) {
+ IConnectRedstone icr = (IConnectRedstone) Block.blocksList[var5];
+ return icr.canConnectRedstone(var0, var1, var2, var3, var4);
} else if(Block.blocksList[var5].canProvidePower()) {
return true;
} else if(var5 != Block.redstoneRepeaterIdle.blockID && var5 != Block.redstoneRepeaterActive.blockID) {
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/Chunk.java ../src_work/minecraft/net/minecraft/src/Chunk.java
--- ../src_base/minecraft/net/minecraft/src/Chunk.java 2011-08-12 13:47:10.334455000 +0200
+++ ../src_work/minecraft/net/minecraft/src/Chunk.java 2011-08-12 14:07:37.321634700 +0200
@@ -1,5 +1,6 @@
package net.minecraft.src;
+import net.minecraft.src.forge.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -256,6 +257,12 @@
} else {
int var9 = this.xPosition * 16 + var1;
int var10 = this.zPosition * 16 + var3;
+
+ if (Block.blocksList[var8] instanceof IOverrideReplace) {
+ IOverrideReplace iovr = (IOverrideReplace) Block.blocksList[var8];
+ if (!iovr.canReplaceBlock(this.worldObj, var9, var2, var10, var4))
+ return iovr.getReplacedSuccess();
+ }
this.blocks[var1 << 11 | var3 << 7 | var2] = (byte)(var6 & 255);
if(var8 != 0 && !this.worldObj.multiplayerWorld) {
Block.blocksList[var8].onBlockRemoval(this.worldObj, var9, var2, var10);
@@ -295,6 +302,11 @@
} else {
int var8 = this.xPosition * 16 + var1;
int var9 = this.zPosition * 16 + var3;
+ if (Block.blocksList[var7] instanceof IOverrideReplace) {
+ IOverrideReplace iovr = (IOverrideReplace) Block.blocksList[var7];
+ if (!iovr.canReplaceBlock(this.worldObj, var8, var2, var9, var4))
+ return iovr.getReplacedSuccess();
+ }
this.blocks[var1 << 11 | var3 << 7 | var2] = (byte)(var5 & 255);
if(var7 != 0) {
Block.blocksList[var7].onBlockRemoval(this.worldObj, var8, var2, var9);
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/EffectRenderer.java ../src_work/minecraft/net/minecraft/src/EffectRenderer.java
--- ../src_base/minecraft/net/minecraft/src/EffectRenderer.java 2011-08-12 13:47:10.674474500 +0200
+++ ../src_work/minecraft/net/minecraft/src/EffectRenderer.java 2011-08-12 14:23:05.961749800 +0200
@@ -1,5 +1,6 @@
package net.minecraft.src;
+import net.minecraft.src.forge.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@@ -17,6 +18,7 @@
protected World worldObj;
private List[] fxLayers = new List[4];
+ private List effectList = new ArrayList();;
private RenderEngine renderer;
private Random rand = new Random();
@@ -53,6 +55,18 @@
}
}
}
+
+ for (int x = 0; x < effectList.size(); x++) {
+ BlockTextureParticles entry = (BlockTextureParticles) effectList.get(x);
+ for (int y = 0; y < entry.effects.size(); y++) {
+ EntityFX entityfx = (EntityFX) entry.effects.get(y);
+ if (entityfx.isDead) {
+ entry.effects.remove(y--);
+ }
+ }
+ if (effectList.size() == 0)
+ effectList.remove(x--);
+ }
}
@@ -87,12 +101,24 @@
for(int var11 = 0; var11 < this.fxLayers[var8].size(); ++var11) {
EntityFX var12 = (EntityFX)this.fxLayers[var8].get(var11);
+ if(var12 instanceof EntityDiggingFX) continue;
var12.renderParticle(var10, var2, var3, var7, var4, var5, var6);
}
var10.draw();
}
}
+ Tessellator tessellator = Tessellator.instance;
+ for (int x = 0; x < effectList.size(); x++) {
+ BlockTextureParticles entry = (BlockTextureParticles) effectList.get(x);
+ GL11.glBindTexture(3553 /* GL_TEXTURE_2D */, renderer.getTexture(entry.texture));
+ tessellator.startDrawingQuads();
+ for (int y = 0; y < entry.effects.size(); y++) {
+ EntityFX entityfx = (EntityFX) entry.effects.get(y);
+ entityfx.renderParticle(tessellator, var2, var3, var7, var4, var5, var6);
+ }
+ tessellator.draw();
+ }
}
@@ -115,6 +141,12 @@
for(int var2 = 0; var2 < 4; ++var2) {
this.fxLayers[var2].clear();
}
+
+ for (int x = 0; x < effectList.size(); x++) {
+ BlockTextureParticles entry = (BlockTextureParticles) effectList.get(x);
+ entry.effects.clear();
+ }
+ effectList.clear();
}
@@ -130,7 +162,9 @@
double var13 = (double)var2 + ((double)var9 + 0.5D) / (double)var7;
double var15 = (double)var3 + ((double)var10 + 0.5D) / (double)var7;
int var17 = this.rand.nextInt(6);
- this.addEffect((new EntityDiggingFX(this.worldObj, var11, var13, var15, var11 - (double)var1 - 0.5D, var13 - (double)var2 - 0.5D, var15 - (double)var3 - 0.5D, var6, var17, var5)).func_4041_a(var1, var2, var3));
+ EntityDiggingFX dig_effect = new EntityDiggingFX(this.worldObj, var11, var13, var15, var11 - (double)var1 - 0.5D, var13 - (double)var2 - 0.5D, var15 - (double)var3 - 0.5D, var6, var17, var5);
+ dig_effect.func_4041_a(var1, var2, var3);
+ this.addDigParticleEffect(dig_effect, var6);
}
}
}
@@ -169,10 +203,39 @@
if(var4 == 5) {
var8 = (double)var1 + var6.maxX + (double)var7;
}
-
- this.addEffect((new EntityDiggingFX(this.worldObj, var8, var10, var12, 0.0D, 0.0D, 0.0D, var6, var4, this.worldObj.getBlockMetadata(var1, var2, var3))).func_4041_a(var1, var2, var3).func_407_b(0.2F).func_405_d(0.6F));
- }
- }
+ EntityDiggingFX dig_effect = new EntityDiggingFX(this.worldObj, var8, var10, var12, 0.0D, 0.0D, 0.0D, var6, var4, this.worldObj.getBlockMetadata(var1, var2, var3));
+ dig_effect.func_4041_a(var1, var2, var3);
+ dig_effect.func_407_b(0.2F);
+ dig_effect.func_405_d(0.6F);
+ addDigParticleEffect(dig_effect, var6);
+ }
+ }
+
+ public void addDigParticleEffect(EntityDiggingFX dig_effect, Block block) {
+ boolean added = false;
+ String comp;
+
+ if (block instanceof ITextureProvider) {
+ comp = ((ITextureProvider) block).getTextureFile();
+ } else {
+ comp = "/terrain.png";
+ }
+ for (int x = 0; x < effectList.size(); x++) {
+ BlockTextureParticles entry = (BlockTextureParticles) effectList
+ .get(x);
+ if (entry.texture.equals(comp)) {
+ entry.effects.add(dig_effect);
+ added = true;
+ }
+ }
+ if (!added) {
+ BlockTextureParticles entry = new BlockTextureParticles();
+ entry.texture = comp;
+ entry.effects.add(dig_effect);
+ effectList.add(entry);
+ }
+ this.addEffect(dig_effect);
+ }
public String getStatistics() {
return "" + (this.fxLayers[0].size() + this.fxLayers[1].size() + this.fxLayers[2].size());
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/EntityLiving.java ../src_work/minecraft/net/minecraft/src/EntityLiving.java
--- ../src_base/minecraft/net/minecraft/src/EntityLiving.java 2011-08-12 13:47:11.117499000 +0200
+++ ../src_work/minecraft/net/minecraft/src/EntityLiving.java 2011-08-12 14:25:47.273976400 +0200
@@ -566,7 +566,9 @@
int var1 = MathHelper.floor_double(this.posX);
int var2 = MathHelper.floor_double(this.boundingBox.minY);
int var3 = MathHelper.floor_double(this.posZ);
- return this.worldObj.getBlockId(var1, var2, var3) == Block.ladder.blockID;
+ Block block=Block.blocksList[worldObj.getBlockId(var1, var2, var3)];
+ if(block==null) return false;
+ return block.isLadder();
}
public void writeEntityToNBT(NBTTagCompound var1) {
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/EntityPlayer.java ../src_work/minecraft/net/minecraft/src/EntityPlayer.java
--- ../src_base/minecraft/net/minecraft/src/EntityPlayer.java 2011-08-12 13:47:11.258507000 +0200
+++ ../src_work/minecraft/net/minecraft/src/EntityPlayer.java 2011-08-12 14:28:36.672665400 +0200
@@ -1,5 +1,6 @@
package net.minecraft.src;
+import net.minecraft.src.forge.ISpecialArmor;
import java.util.Iterator;
import java.util.List;
import net.minecraft.src.AchievementList;
@@ -460,6 +461,18 @@
}
protected void damageEntity(int var1) {
+ boolean doRegularComputation = true;
+ for (ItemStack stack : this.inventory.armorInventory) {
+ if (stack != null && stack.getItem() instanceof ISpecialArmor) {
+ ISpecialArmor armor = (ISpecialArmor) stack.getItem();
+ var1 = armor.adjustArmorDamage(var1);
+ doRegularComputation = doRegularComputation && armor.allowRegularComputation();
+ }
+ }
+
+ if (!doRegularComputation) {
+ super.damageEntity(var1);
+ }
int var2 = 25 - this.inventory.getTotalArmorValue();
int var3 = var1 * var2 + this.damageRemainder;
this.inventory.damageArmor(var1);
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/Explosion.java ../src_work/minecraft/net/minecraft/src/Explosion.java
--- ../src_base/minecraft/net/minecraft/src/Explosion.java 2011-08-12 13:47:11.653530000 +0200
+++ ../src_work/minecraft/net/minecraft/src/Explosion.java 2011-08-12 14:34:12.001845200 +0200
@@ -1,5 +1,6 @@
package net.minecraft.src;
+import net.minecraft.src.forge.ISpecialResistance;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -67,7 +68,17 @@
int var24 = MathHelper.floor_double(var19);
int var25 = this.worldObj.getBlockId(var22, var23, var24);
if(var25 > 0) {
- var14 -= (Block.blocksList[var25].getExplosionResistance(this.exploder) + 0.3F) * var21;
+ if (Block.blocksList[var25] instanceof ISpecialResistance) {
+ ISpecialResistance isr = (ISpecialResistance) Block.blocksList[var25];
+ var14 -= (isr.getSpecialExplosionResistance(
+ this.worldObj, var22, var23, var24, this.explosionX,
+ this.explosionY, this.explosionZ, this.exploder) + 0.3F)
+ * var21;
+ } else {
+ var14 -= (Block.blocksList[var25]
+ .getExplosionResistance(this.exploder) + 0.3F)
+ * var21;
+ }
}
if(var14 > 0.0F) {
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/ItemBucket.java ../src_work/minecraft/net/minecraft/src/ItemBucket.java
--- ../src_base/minecraft/net/minecraft/src/ItemBucket.java 2011-08-12 13:47:12.457576000 +0200
+++ ../src_work/minecraft/net/minecraft/src/ItemBucket.java 2011-08-12 14:37:03.833673400 +0200
@@ -1,5 +1,6 @@
package net.minecraft.src;
+import net.minecraft.src.forge.MinecraftForge;
import net.minecraft.src.Block;
import net.minecraft.src.EntityCow;
import net.minecraft.src.EntityPlayer;
@@ -52,6 +53,13 @@
}
if(this.isFull == 0) {
+ ItemStack customBucket = MinecraftForge.fillCustomBucket(var2,
+ var25, var26, var27);
+
+ if (customBucket != null) {
+ return customBucket;
+ }
+
if(var2.getBlockMaterial(var25, var26, var27) == Material.water && var2.getBlockMetadata(var25, var26, var27) == 0) {
var2.setBlockWithNotify(var25, var26, var27, 0);
return new ItemStack(Item.bucketWater);
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/ItemPickaxe.java ../src_work/minecraft/net/minecraft/src/ItemPickaxe.java
--- ../src_base/minecraft/net/minecraft/src/ItemPickaxe.java 2011-08-12 13:47:12.719591000 +0200
+++ ../src_work/minecraft/net/minecraft/src/ItemPickaxe.java 2011-08-12 14:40:12.313453800 +0200
@@ -1,5 +1,6 @@
package net.minecraft.src;
+import net.minecraft.src.forge.MinecraftForge;
import net.minecraft.src.Block;
import net.minecraft.src.EnumToolMaterial;
import net.minecraft.src.ItemTool;
@@ -15,6 +16,7 @@
}
public boolean canHarvestBlock(Block var1) {
+ if (MinecraftForge.canHarvestBlock(this, var1)) return true;
return var1 == Block.obsidian?this.toolMaterial.getHarvestLevel() == 3:(var1 != Block.blockDiamond && var1 != Block.oreDiamond?(var1 != Block.blockGold && var1 != Block.oreGold?(var1 != Block.blockSteel && var1 != Block.oreIron?(var1 != Block.blockLapis && var1 != Block.oreLapis?(var1 != Block.oreRedstone && var1 != Block.oreRedstoneGlowing?(var1.blockMaterial == Material.rock?true:var1.blockMaterial == Material.iron):this.toolMaterial.getHarvestLevel() >= 2):this.toolMaterial.getHarvestLevel() >= 1):this.toolMaterial.getHarvestLevel() >= 1):this.toolMaterial.getHarvestLevel() >= 2):this.toolMaterial.getHarvestLevel() >= 2);
}
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/ItemRenderer.java ../src_work/minecraft/net/minecraft/src/ItemRenderer.java
--- ../src_base/minecraft/net/minecraft/src/ItemRenderer.java 2011-08-12 13:47:12.779594900 +0200
+++ ../src_work/minecraft/net/minecraft/src/ItemRenderer.java 2011-08-12 15:46:50.977164300 +0200
@@ -1,5 +1,6 @@
package net.minecraft.src;
+import net.minecraft.src.forge.ForgeHooksClient;
import net.minecraft.client.Minecraft;
import net.minecraft.src.Block;
import net.minecraft.src.EntityLiving;
@@ -38,12 +39,15 @@
GL11.glPushMatrix();
if(var2.itemID < 256 && RenderBlocks.renderItemIn3d(Block.blocksList[var2.itemID].getRenderType())) {
GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, this.mc.renderEngine.getTexture("/terrain.png"));
+ ForgeHooksClient.overrideTexture (Block.blocksList[var2.itemID]);
this.renderBlocksInstance.renderBlockOnInventory(Block.blocksList[var2.itemID], var2.getItemDamage(), var1.getEntityBrightness(1.0F));
} else {
if(var2.itemID < 256) {
GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, this.mc.renderEngine.getTexture("/terrain.png"));
+ ForgeHooksClient.overrideTexture (Block.blocksList[var2.itemID]);
} else {
GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, this.mc.renderEngine.getTexture("/gui/items.png"));
+ ForgeHooksClient.overrideTexture (Item.itemsList[var2.itemID]);
}
Tessellator var3 = Tessellator.instance;
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/ItemTool.java ../src_work/minecraft/net/minecraft/src/ItemTool.java
--- ../src_base/minecraft/net/minecraft/src/ItemTool.java 2011-08-12 13:47:12.875600000 +0200
+++ ../src_work/minecraft/net/minecraft/src/ItemTool.java 2011-08-12 14:44:44.057996700 +0200
@@ -1,5 +1,7 @@
package net.minecraft.src;
+import java.util.Arrays;
+
import net.minecraft.src.Block;
import net.minecraft.src.Entity;
import net.minecraft.src.EntityLiving;
@@ -52,4 +54,11 @@
public boolean isFull3D() {
return true;
}
+
+ public void addBlockEffectiveAgainst (Block block) {
+ blocksEffectiveAgainst = Arrays.copyOf(blocksEffectiveAgainst,
+ blocksEffectiveAgainst.length + 1);
+
+ blocksEffectiveAgainst [blocksEffectiveAgainst.length-1] = block;
+ }
}
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/MovingObjectPosition.java ../src_work/minecraft/net/minecraft/src/MovingObjectPosition.java
--- ../src_base/minecraft/net/minecraft/src/MovingObjectPosition.java 2011-08-12 13:47:13.829654000 +0200
+++ ../src_work/minecraft/net/minecraft/src/MovingObjectPosition.java 2011-08-12 14:45:53.427964400 +0200
@@ -13,6 +13,9 @@
public int sideHit;
public Vec3D hitVec;
public Entity entityHit;
+
+ // Added for RedPower subblocks.
+ public int subHit=0;
public MovingObjectPosition(int var1, int var2, int var3, int var4, Vec3D var5) {
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/PlayerController.java ../src_work/minecraft/net/minecraft/src/PlayerController.java
--- ../src_base/minecraft/net/minecraft/src/PlayerController.java 2011-08-12 13:47:14.822711000 +0200
+++ ../src_work/minecraft/net/minecraft/src/PlayerController.java 2011-08-12 14:48:25.809680200 +0200
@@ -1,5 +1,6 @@
package net.minecraft.src;
+import net.minecraft.src.forge.*;
import net.minecraft.client.Minecraft;
import net.minecraft.src.Block;
import net.minecraft.src.Entity;
@@ -74,6 +75,12 @@
public void func_6473_b(EntityPlayer var1) {}
public boolean sendPlaceBlock(EntityPlayer var1, World var2, ItemStack var3, int var4, int var5, int var6, int var7) {
+ if (var3 != null && var3.getItem() instanceof IUseItemFirst) {
+ IUseItemFirst iuif = (IUseItemFirst) var3.getItem();
+ if (iuif.onItemUseFirst(var3, var1, var2, var4, var5, var6, var7)) {
+ return true;
+ }
+ }
int var8 = var2.getBlockId(var4, var5, var6);
return var8 > 0 && Block.blocksList[var8].blockActivated(var2, var4, var5, var6, var1)?true:(var3 == null?false:var3.useItem(var1, var2, var4, var5, var6, var7));
}
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/RenderItem.java ../src_work/minecraft/net/minecraft/src/RenderItem.java
--- ../src_base/minecraft/net/minecraft/src/RenderItem.java 2011-08-12 13:47:15.680760800 +0200
+++ ../src_work/minecraft/net/minecraft/src/RenderItem.java 2011-08-12 14:54:24.801213300 +0200
@@ -1,5 +1,6 @@
package net.minecraft.src;
+import net.minecraft.src.forge.ForgeHooksClient;
import java.util.Random;
import net.minecraft.src.Block;
import net.minecraft.src.Entity;
@@ -53,6 +54,7 @@
if(var10.itemID < 256 && RenderBlocks.renderItemIn3d(Block.blocksList[var10.itemID].getRenderType())) {
GL11.glRotatef(var12, 0.0F, 1.0F, 0.0F);
this.loadTexture("/terrain.png");
+ ForgeHooksClient.overrideTexture(Block.blocksList[var10.itemID]);
float var29 = 0.25F;
if(!Block.blocksList[var10.itemID].renderAsNormalBlock() && var10.itemID != Block.stairSingle.blockID && Block.blocksList[var10.itemID].getRenderType() != 16) {
var29 = 0.5F;
@@ -77,8 +79,10 @@
int var14 = var10.getIconIndex();
if(var10.itemID < 256) {
this.loadTexture("/terrain.png");
+ ForgeHooksClient.overrideTexture(Block.blocksList[var10.itemID]);
} else {
this.loadTexture("/gui/items.png");
+ ForgeHooksClient.overrideTexture(Item.itemsList[var10.itemID]);
}
Tessellator var15 = Tessellator.instance;
@@ -131,6 +135,7 @@
float var11;
if(var3 < 256 && RenderBlocks.renderItemIn3d(Block.blocksList[var3].getRenderType())) {
var2.bindTexture(var2.getTexture("/terrain.png"));
+ ForgeHooksClient.overrideTexture (Block.blocksList[var3]);
Block var14 = Block.blocksList[var3];
GL11.glPushMatrix();
GL11.glTranslatef((float)(var6 - 2), (float)(var7 + 3), -3.0F);
@@ -156,8 +161,10 @@
GL11.glDisable(2896 /*GL_LIGHTING*/);
if(var3 < 256) {
var2.bindTexture(var2.getTexture("/terrain.png"));
+ ForgeHooksClient.overrideTexture (Block.blocksList[var3]);
} else {
var2.bindTexture(var2.getTexture("/gui/items.png"));
+ ForgeHooksClient.overrideTexture (Item.itemsList[var3]);
}
int var8 = Item.itemsList[var3].getColorFromDamage(var4);
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/Tessellator.java ../src_work/minecraft/net/minecraft/src/Tessellator.java
--- ../src_base/minecraft/net/minecraft/src/Tessellator.java 2011-08-12 13:47:16.233792400 +0200
+++ ../src_work/minecraft/net/minecraft/src/Tessellator.java 2011-08-12 15:40:09.194183600 +0200
@@ -1,5 +1,6 @@
package net.minecraft.src;
+import java.util.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
@@ -13,9 +14,6 @@
private static boolean convertQuadsToTriangles = true;
private static boolean tryVBO = false;
- private ByteBuffer byteBuffer;
- private IntBuffer intBuffer;
- private FloatBuffer floatBuffer;
private int[] rawBuffer;
private int vertexCount = 0;
private double textureU;
@@ -28,31 +26,33 @@
private int addedVertices = 0;
private boolean isColorDisabled = false;
private int drawMode;
- private double xOffset;
- private double yOffset;
- private double zOffset;
+ public double xOffset;
+ public double yOffset;
+ public double zOffset;
private int normal;
- public static final Tessellator instance = new Tessellator(2097152);
private boolean isDrawing = false;
- private boolean useVBO = false;
- private IntBuffer vertexBuffers;
+ private static boolean useVBO = false;
private int vboIndex = 0;
- private int vboCount = 10;
private int bufferSize;
-
-
- private Tessellator(int var1) {
- this.bufferSize = var1;
- this.byteBuffer = GLAllocation.createDirectByteBuffer(var1 * 4);
- this.intBuffer = this.byteBuffer.asIntBuffer();
- this.floatBuffer = this.byteBuffer.asFloatBuffer();
- this.rawBuffer = new int[var1];
- this.useVBO = tryVBO && GLContext.getCapabilities().GL_ARB_vertex_buffer_object;
- if(this.useVBO) {
- this.vertexBuffers = GLAllocation.createDirectIntBuffer(this.vboCount);
- ARBVertexBufferObject.glGenBuffersARB(this.vertexBuffers);
- }
-
+ public int instanceNo;
+ static int instanceTotal=0;
+
+ private int rawBufferSize;
+ private static int vboCount;
+ private static IntBuffer vertexBuffers;
+ private static int nativeBufferSize;
+ private static int trivertsInBuffer;
+ private static ByteBuffer byteBuffer;
+ private static IntBuffer intBuffer;
+ private static FloatBuffer floatBuffer;
+ public static Tessellator instance;
+ public static Tessellator firstInstance;
+
+
+ public Tessellator() {
+ this.instanceNo=instanceTotal++;
+ this.rawBuffer=null;
+ this.rawBufferSize=0;
}
public void draw() {
@@ -61,10 +61,19 @@
} else {
this.isDrawing = false;
if(this.vertexCount > 0) {
- this.intBuffer.clear();
- this.intBuffer.put(this.rawBuffer, 0, this.rawBufferIndex);
- this.byteBuffer.position(0);
- this.byteBuffer.limit(this.rawBufferIndex * 4);
+ int offs=0;
+ while(offs < vertexCount) {
+ int vtc;
+ if(drawMode == 7 && convertQuadsToTriangles) {
+ vtc=Math.min(vertexCount-offs,trivertsInBuffer);
+ } else {
+ vtc=Math.min(vertexCount-offs,nativeBufferSize>>5);
+ }
+ this.intBuffer.clear();
+ this.intBuffer.put(this.rawBuffer, offs*8, vtc*8);
+ this.byteBuffer.position(0);
+ this.byteBuffer.limit(vtc*32);
+ offs+=vtc;
if(this.useVBO) {
this.vboIndex = (this.vboIndex + 1) % this.vboCount;
ARBVertexBufferObject.glBindBufferARB('\u8892', this.vertexBuffers.get(this.vboIndex));
@@ -113,9 +122,9 @@
GL11.glEnableClientState('\u8074');
if(this.drawMode == 7 && convertQuadsToTriangles) {
- GL11.glDrawArrays(4, 0, this.vertexCount);
+ GL11.glDrawArrays(4, 0, vtc);
} else {
- GL11.glDrawArrays(this.drawMode, 0, this.vertexCount);
+ GL11.glDrawArrays(drawMode, 0, vtc);
}
GL11.glDisableClientState('\u8074');
@@ -131,9 +140,14 @@
GL11.glDisableClientState('\u8075');
}
}
+ if(this.rawBufferSize>0x20000 && this.rawBufferIndex<(this.rawBufferSize<<3)) {
+ this.rawBufferSize=0;
+ this.rawBuffer=null;
+ }
this.reset();
}
+ }
}
private void reset() {
@@ -229,6 +243,15 @@
}
public void addVertex(double var1, double var3, double var5) {
+ if(this.rawBufferIndex >= this.rawBufferSize-32) {
+ if(this.rawBufferSize==0) {
+ this.rawBufferSize=0x10000;
+ this.rawBuffer=new int[this.rawBufferSize];
+ } else {
+ this.rawBufferSize*=2;
+ this.rawBuffer=Arrays.copyOf(this.rawBuffer,this.rawBufferSize);
+ }
+ }
++this.addedVertices;
if(this.drawMode == 7 && convertQuadsToTriangles && this.addedVertices % 4 == 0) {
for(int var7 = 0; var7 < 2; ++var7) {
@@ -268,10 +291,6 @@
this.rawBuffer[this.rawBufferIndex + 2] = Float.floatToRawIntBits((float)(var5 + this.zOffset));
this.rawBufferIndex += 8;
++this.vertexCount;
- if(this.vertexCount % 4 == 0 && this.rawBufferIndex >= this.bufferSize - 32) {
- this.draw();
- this.isDrawing = true;
- }
}
@@ -316,5 +335,23 @@
this.yOffset += (double)var2;
this.zOffset += (double)var3;
}
+
+ static {
+ instance=new Tessellator();
+ firstInstance=instance;
+
+ nativeBufferSize = 0x200000;
+ trivertsInBuffer = (nativeBufferSize/48)*6;
+ byteBuffer = GLAllocation.createDirectByteBuffer(nativeBufferSize * 4);
+ intBuffer = byteBuffer.asIntBuffer();
+ floatBuffer = byteBuffer.asFloatBuffer();
+ useVBO = tryVBO && GLContext.getCapabilities().GL_ARB_vertex_buffer_object;
+ vboCount = 10;
+ if(useVBO)
+ {
+ vertexBuffers = GLAllocation.createDirectIntBuffer(vboCount);
+ ARBVertexBufferObject.glGenBuffersARB(vertexBuffers);
+ }
+ }
}