Fix bug with custom Fluids. You can now drown in them!
This commit is contained in:
parent
4b64c15ae8
commit
461a30812b
5 changed files with 83 additions and 12 deletions
|
@ -451,4 +451,13 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
|
||||||
{
|
{
|
||||||
return FluidRegistry.getFluid(fluidName);
|
return FluidRegistry.getFluid(fluidName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getFilledPercentage(World world, int x, int y, int z)
|
||||||
|
{
|
||||||
|
int quantaRemaining = getQuantaValue(world, x, y, z) + 1;
|
||||||
|
float remaining = quantaRemaining / quantaPerBlockFloat;
|
||||||
|
if (remaining > 1) remaining = 1.0f;
|
||||||
|
return remaining * (density > 0 ? 1 : -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,4 +37,15 @@ public interface IFluidBlock
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
boolean canDrain(World world, int x, int y, int z);
|
boolean canDrain(World world, int x, int y, int z);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the amount of a single block is filled. Value between 0 and 1.
|
||||||
|
* 1 meaning the entire 1x1x1 cube is full, 0 meaning completely empty.
|
||||||
|
*
|
||||||
|
* If the return value is negative. It will be treated as filling the block
|
||||||
|
* from the top down instead of bottom up.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
float getFilledPercentage(World world, int x, int y, int z);
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1454,4 +1477,975 @@
|
@@ -1454,4 +1477,979 @@
|
||||||
canBlockGrass[0] = true;
|
canBlockGrass[0] = true;
|
||||||
StatList.initBreakableStats();
|
StatList.initBreakableStats();
|
||||||
}
|
}
|
||||||
|
@ -1142,4 +1142,8 @@
|
||||||
+ {
|
+ {
|
||||||
+ return false;
|
+ return false;
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
|
+ @Deprecated //Implemented here as we changed the IFluidBlock interface, and this allows us to do so without breaking exisitng mods.
|
||||||
|
+ // To be removed next MC version {1.6.3+}
|
||||||
|
+ public float getFilledPercentage(World world, int x, int y, int z){ return 1; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,3 +9,17 @@
|
||||||
l += (i2 & 16711680) >> 16;
|
l += (i2 & 16711680) >> 16;
|
||||||
i1 += (i2 & 65280) >> 8;
|
i1 += (i2 & 65280) >> 8;
|
||||||
j1 += i2 & 255;
|
j1 += i2 & 255;
|
||||||
|
@@ -81,6 +81,13 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
return (float)(par0 + 1) / 9.0F;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ @Deprecated //Implemented here for compatibility, need to change this when we make vanilla fluids use our fluid methods.
|
||||||
|
+ public float getFilledPercentage(IBlockAccess world, int x, int y, int z)
|
||||||
|
+ {
|
||||||
|
+ return 1 - BlockFluid.getFluidHeightPercent(world.getBlockMetadata(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
|
|
@ -1,17 +1,22 @@
|
||||||
--- ../src_base/minecraft/net/minecraft/entity/Entity.java
|
--- ../src_base/minecraft/net/minecraft/entity/Entity.java
|
||||||
+++ ../src_work/minecraft/net/minecraft/entity/Entity.java
|
+++ ../src_work/minecraft/net/minecraft/entity/Entity.java
|
||||||
@@ -1,7 +1,10 @@
|
@@ -1,10 +1,15 @@
|
||||||
package net.minecraft.entity;
|
package net.minecraft.entity;
|
||||||
|
|
||||||
+import cpw.mods.fml.common.FMLLog;
|
+import cpw.mods.fml.common.FMLLog;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
+
|
||||||
+import java.util.ArrayList;
|
+import java.util.ArrayList;
|
||||||
+import java.util.HashMap;
|
+import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -13,8 +16,13 @@
|
+
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockFluid;
|
||||||
|
import net.minecraft.block.StepSound;
|
||||||
|
@@ -13,8 +18,13 @@
|
||||||
import net.minecraft.crash.CrashReportCategory;
|
import net.minecraft.crash.CrashReportCategory;
|
||||||
import net.minecraft.enchantment.EnchantmentProtection;
|
import net.minecraft.enchantment.EnchantmentProtection;
|
||||||
import net.minecraft.entity.effect.EntityLightningBolt;
|
import net.minecraft.entity.effect.EntityLightningBolt;
|
||||||
|
@ -25,7 +30,7 @@
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagDouble;
|
import net.minecraft.nbt.NBTTagDouble;
|
||||||
@@ -26,12 +34,16 @@
|
@@ -26,12 +36,18 @@
|
||||||
import net.minecraft.util.DamageSource;
|
import net.minecraft.util.DamageSource;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
|
@ -39,10 +44,12 @@
|
||||||
+import net.minecraftforge.common.IExtendedEntityProperties;
|
+import net.minecraftforge.common.IExtendedEntityProperties;
|
||||||
+import net.minecraftforge.common.MinecraftForge;
|
+import net.minecraftforge.common.MinecraftForge;
|
||||||
+import net.minecraftforge.event.entity.EntityEvent;
|
+import net.minecraftforge.event.entity.EntityEvent;
|
||||||
|
+import net.minecraftforge.fluids.Fluid;
|
||||||
|
+import net.minecraftforge.fluids.IFluidBlock;
|
||||||
|
|
||||||
public abstract class Entity
|
public abstract class Entity
|
||||||
{
|
{
|
||||||
@@ -218,6 +230,13 @@
|
@@ -218,6 +234,13 @@
|
||||||
private boolean invulnerable;
|
private boolean invulnerable;
|
||||||
private UUID entityUniqueID;
|
private UUID entityUniqueID;
|
||||||
public EnumEntitySize myEntitySize;
|
public EnumEntitySize myEntitySize;
|
||||||
|
@ -56,7 +63,7 @@
|
||||||
|
|
||||||
public Entity(World par1World)
|
public Entity(World par1World)
|
||||||
{
|
{
|
||||||
@@ -245,6 +264,15 @@
|
@@ -245,6 +268,15 @@
|
||||||
this.dataWatcher.addObject(0, Byte.valueOf((byte)0));
|
this.dataWatcher.addObject(0, Byte.valueOf((byte)0));
|
||||||
this.dataWatcher.addObject(1, Short.valueOf((short)300));
|
this.dataWatcher.addObject(1, Short.valueOf((short)300));
|
||||||
this.entityInit();
|
this.entityInit();
|
||||||
|
@ -72,7 +79,33 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void entityInit();
|
protected abstract void entityInit();
|
||||||
@@ -1523,6 +1551,21 @@
|
@@ -1164,11 +1196,20 @@
|
||||||
|
int k = MathHelper.floor_double(this.posZ);
|
||||||
|
int l = this.worldObj.getBlockId(i, j, k);
|
||||||
|
|
||||||
|
- if (l != 0 && Block.blocksList[l].blockMaterial == par1Material)
|
||||||
|
- {
|
||||||
|
- float f = BlockFluid.getFluidHeightPercent(this.worldObj.getBlockMetadata(i, j, k)) - 0.11111111F;
|
||||||
|
- float f1 = (float)(j + 1) - f;
|
||||||
|
- return d0 < (double)f1;
|
||||||
|
+ Block block = Block.blocksList[l];
|
||||||
|
+ if (block != null && block.blockMaterial == par1Material)
|
||||||
|
+ {
|
||||||
|
+ double filled = block.getFilledPercentage(worldObj, i, j, k);
|
||||||
|
+ if (filled < 0)
|
||||||
|
+ {
|
||||||
|
+ filled *= -1;
|
||||||
|
+ //filled -= 0.11111111F; //Why this is needed.. not sure...
|
||||||
|
+ return d0 > (double)(j + (1 - filled));
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ return d0 < (double)(j + filled);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@@ -1523,6 +1564,21 @@
|
||||||
par1NBTTagCompound.setInteger("PortalCooldown", this.timeUntilPortal);
|
par1NBTTagCompound.setInteger("PortalCooldown", this.timeUntilPortal);
|
||||||
par1NBTTagCompound.setLong("UUIDMost", this.entityUniqueID.getMostSignificantBits());
|
par1NBTTagCompound.setLong("UUIDMost", this.entityUniqueID.getMostSignificantBits());
|
||||||
par1NBTTagCompound.setLong("UUIDLeast", this.entityUniqueID.getLeastSignificantBits());
|
par1NBTTagCompound.setLong("UUIDLeast", this.entityUniqueID.getLeastSignificantBits());
|
||||||
|
@ -94,7 +127,7 @@
|
||||||
this.writeEntityToNBT(par1NBTTagCompound);
|
this.writeEntityToNBT(par1NBTTagCompound);
|
||||||
|
|
||||||
if (this.ridingEntity != null)
|
if (this.ridingEntity != null)
|
||||||
@@ -1593,6 +1636,26 @@
|
@@ -1593,6 +1649,26 @@
|
||||||
|
|
||||||
this.setPosition(this.posX, this.posY, this.posZ);
|
this.setPosition(this.posX, this.posY, this.posZ);
|
||||||
this.setRotation(this.rotationYaw, this.rotationPitch);
|
this.setRotation(this.rotationYaw, this.rotationPitch);
|
||||||
|
@ -121,7 +154,7 @@
|
||||||
this.readEntityFromNBT(par1NBTTagCompound);
|
this.readEntityFromNBT(par1NBTTagCompound);
|
||||||
|
|
||||||
if (this.func_142008_O())
|
if (this.func_142008_O())
|
||||||
@@ -1705,7 +1768,14 @@
|
@@ -1705,7 +1781,14 @@
|
||||||
{
|
{
|
||||||
EntityItem entityitem = new EntityItem(this.worldObj, this.posX, this.posY + (double)par2, this.posZ, par1ItemStack);
|
EntityItem entityitem = new EntityItem(this.worldObj, this.posX, this.posY + (double)par2, this.posZ, par1ItemStack);
|
||||||
entityitem.delayBeforeCanPickup = 10;
|
entityitem.delayBeforeCanPickup = 10;
|
||||||
|
@ -137,7 +170,7 @@
|
||||||
return entityitem;
|
return entityitem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2001,7 +2071,7 @@
|
@@ -2001,7 +2084,7 @@
|
||||||
*/
|
*/
|
||||||
public boolean isRiding()
|
public boolean isRiding()
|
||||||
{
|
{
|
||||||
|
@ -146,7 +179,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2363,7 +2433,7 @@
|
@@ -2363,7 +2446,7 @@
|
||||||
|
|
||||||
public float func_82146_a(Explosion par1Explosion, World par2World, int par3, int par4, int par5, Block par6Block)
|
public float func_82146_a(Explosion par1Explosion, World par2World, int par3, int par4, int par5, Block par6Block)
|
||||||
{
|
{
|
||||||
|
@ -155,7 +188,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean func_96091_a(Explosion par1Explosion, World par2World, int par3, int par4, int par5, int par6, float par7)
|
public boolean func_96091_a(Explosion par1Explosion, World par2World, int par3, int par4, int par5, int par6, float par7)
|
||||||
@@ -2426,4 +2496,170 @@
|
@@ -2426,4 +2509,170 @@
|
||||||
{
|
{
|
||||||
return this.getEntityName();
|
return this.getEntityName();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue