Improved Monolith Jitter #130
@@ -424,9 +424,10 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initDoorTE(World world, int x, int y, int z)
|
public TileEntity initDoorTE(World world, int x, int y, int z)
|
||||||
{
|
{
|
||||||
TileEntity te = this.createNewTileEntity(world);
|
TileEntity te = this.createNewTileEntity(world);
|
||||||
world.setBlockTileEntity(x, y, z, te);
|
world.setBlockTileEntity(x, y, z, te);
|
||||||
|
return te;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package StevenDimDoors.mod_pocketDim.blocks;
|
package StevenDimDoors.mod_pocketDim.blocks;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public interface IDimDoor
|
public interface IDimDoor
|
||||||
@@ -11,5 +12,5 @@ public interface IDimDoor
|
|||||||
|
|
||||||
public int getDrops();
|
public int getDrops();
|
||||||
|
|
||||||
public void initDoorTE(World world, int x, int y, int z);
|
public TileEntity initDoorTE(World world, int x, int y, int z);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,9 +120,10 @@ public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntit
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initDoorTE(World world, int x, int y, int z)
|
public TileEntity initDoorTE(World world, int x, int y, int z)
|
||||||
{
|
{
|
||||||
TileEntity te = this.createNewTileEntity(world);
|
TileEntity te = this.createNewTileEntity(world);
|
||||||
world.setBlockTileEntity(x, y, z, te);
|
world.setBlockTileEntity(x, y, z, te);
|
||||||
|
return te;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,6 +25,7 @@ import net.minecraftforge.common.network.packet.DimensionRegisterPacket;
|
|||||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||||
|
import StevenDimDoors.mod_pocketDim.blocks.BaseDimDoor;
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||||
import StevenDimDoors.mod_pocketDim.items.BaseItemDoor;
|
import StevenDimDoors.mod_pocketDim.items.BaseItemDoor;
|
||||||
import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor;
|
import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor;
|
||||||
@@ -600,7 +601,9 @@ public class DDTeleporter
|
|||||||
}
|
}
|
||||||
|
|
||||||
BaseItemDoor.placeDoorBlock(destWorld, link.destination().getX(), link.destination().getY()-1, link.destination().getZ(),link.getDestinationOrientation(), door);
|
BaseItemDoor.placeDoorBlock(destWorld, link.destination().getX(), link.destination().getY()-1, link.destination().getZ(),link.getDestinationOrientation(), door);
|
||||||
TileEntity doorDestTE = startWorld.getBlockTileEntity(link.destination().getX(), link.destination().getY(), link.destination().getZ());
|
|
||||||
|
TileEntity doorDestTE = ((BaseDimDoor)door).initDoorTE(destWorld, link.destination().getX(), link.destination().getY(), link.destination().getZ());
|
||||||
|
|
||||||
|
|
||||||
if(doorDestTE instanceof TileEntityDimDoor)
|
if(doorDestTE instanceof TileEntityDimDoor)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -62,7 +62,12 @@ public abstract class DimLink
|
|||||||
}
|
}
|
||||||
public int getDestinationOrientation()
|
public int getDestinationOrientation()
|
||||||
{
|
{
|
||||||
return PocketManager.getLink(link.point.getX(), link.point.getY(), link.point.getZ(), link.point.getDimension()).link().orientation;
|
DimLink link = PocketManager.getLink(this.destination().getX(), this.destination().getY(), this.destination().getZ(), this.destination().getDimension());
|
||||||
|
if(link !=null)
|
||||||
|
{
|
||||||
|
return link.orientation();
|
||||||
|
}
|
||||||
|
return (this.orientation()+2)%4;
|
||||||
}
|
}
|
||||||
public boolean hasDestination()
|
public boolean hasDestination()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ public class ItemRiftSignature extends Item
|
|||||||
@Override
|
@Override
|
||||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||||
{
|
{
|
||||||
//TODO- recognize doors and intelligently place rifts on them.
|
|
||||||
// We must use onItemUseFirst() instead of onItemUse() because Minecraft checks
|
// We must use onItemUseFirst() instead of onItemUse() because Minecraft checks
|
||||||
// whether the user is in creative mode after calling onItemUse() and undoes any
|
// whether the user is in creative mode after calling onItemUse() and undoes any
|
||||||
// damage we might set to indicate the rift sig has been activated. Otherwise,
|
// damage we might set to indicate the rift sig has been activated. Otherwise,
|
||||||
|
|||||||
@@ -27,41 +27,37 @@ import StevenDimDoors.mod_pocketDim.world.PocketProvider;
|
|||||||
|
|
||||||
public class MobMonolith extends EntityFlying implements IMob
|
public class MobMonolith extends EntityFlying implements IMob
|
||||||
{
|
{
|
||||||
|
|
||||||
float soundTime = 0;
|
|
||||||
public int aggro = 0;
|
public int aggro = 0;
|
||||||
byte textureState = 0;
|
private float soundTime = 0;
|
||||||
float entityCollisionReduction = 100;
|
private byte textureState = 0;
|
||||||
float scaleFactor = 0;
|
private float scaleFactor = 0;
|
||||||
int aggroMax;
|
private int aggroMax;
|
||||||
int destX = 0; // unused fields?
|
|
||||||
int destY = 0;
|
|
||||||
int destZ = 0;
|
|
||||||
|
|
||||||
@Override
|
private static DDProperties properties = null;
|
||||||
protected void damageEntity(DamageSource par1DamageSource, float par2)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public MobMonolith(World par1World)
|
public MobMonolith(World par1World)
|
||||||
{
|
{
|
||||||
super(par1World);
|
super(par1World);
|
||||||
this.setSize(3F, 9.0F);
|
this.setSize(3F, 9.0F);
|
||||||
this.noClip=true;
|
this.noClip=true;
|
||||||
this.scaleFactor= (float) ((rand.nextDouble()/2)+1);
|
this.scaleFactor = (float) ((rand.nextDouble()/2)+1);
|
||||||
this.aggroMax=rand.nextInt(245)+200;
|
this.aggroMax = rand.nextInt(245)+200;
|
||||||
|
|
||||||
if (properties == null)
|
if (properties == null)
|
||||||
properties = DDProperties.instance();
|
properties = DDProperties.instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DDProperties properties = null;
|
@Override
|
||||||
|
protected void damageEntity(DamageSource par1DamageSource, float par2)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canDespawn()
|
public boolean canDespawn()
|
||||||
@@ -102,38 +98,38 @@ public class MobMonolith extends EntityFlying implements IMob
|
|||||||
this.dataWatcher.addObject(16, Byte.valueOf((byte)0));
|
this.dataWatcher.addObject(16, Byte.valueOf((byte)0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isClipping()
|
public boolean isClipping()
|
||||||
{
|
{
|
||||||
|
|
||||||
int i = MathHelper.floor_double(this.boundingBox.minX);
|
int i = MathHelper.floor_double(this.boundingBox.minX);
|
||||||
int j = MathHelper.floor_double(this.boundingBox.maxX + 1.0D);
|
int j = MathHelper.floor_double(this.boundingBox.maxX + 1.0D);
|
||||||
int k = MathHelper.floor_double(this.boundingBox.minY);
|
int k = MathHelper.floor_double(this.boundingBox.minY);
|
||||||
int l = MathHelper.floor_double(this.boundingBox.maxY + 1.0D);
|
int l = MathHelper.floor_double(this.boundingBox.maxY + 1.0D);
|
||||||
int i1 = MathHelper.floor_double(this.boundingBox.minZ);
|
int i1 = MathHelper.floor_double(this.boundingBox.minZ);
|
||||||
int j1 = MathHelper.floor_double(this.boundingBox.maxZ + 1.0D);
|
int j1 = MathHelper.floor_double(this.boundingBox.maxZ + 1.0D);
|
||||||
|
|
||||||
for (int k1 = i; k1 < j; ++k1)
|
for (int k1 = i; k1 < j; ++k1)
|
||||||
{
|
{
|
||||||
for (int l1 = k; l1 < l; ++l1)
|
for (int l1 = k; l1 < l; ++l1)
|
||||||
{
|
{
|
||||||
for (int i2 = i1; i2 < j1; ++i2)
|
for (int i2 = i1; i2 < j1; ++i2)
|
||||||
{
|
{
|
||||||
if(!this.worldObj.isAirBlock(k1, l1, i2))
|
if(!this.worldObj.isAirBlock(k1, l1, i2))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean isEntityAlive()
|
public boolean isEntityAlive()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEntityUpdate()
|
public void onEntityUpdate()
|
||||||
@@ -245,13 +241,13 @@ public class MobMonolith extends EntityFlying implements IMob
|
|||||||
|
|
||||||
public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
|
public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
|
||||||
{
|
{
|
||||||
if(!(par1DamageSource == DamageSource.inWall))
|
if (par1DamageSource == DamageSource.inWall)
|
||||||
{
|
{
|
||||||
this.aggro=400;
|
this.posY = posY + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.posY=posY+1;
|
this.aggro = this.aggroMax;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.lwjgl.opengl.GL12;
|
|||||||
|
|
||||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||||
import StevenDimDoors.mod_pocketDim.ticking.MobMonolith;
|
import StevenDimDoors.mod_pocketDim.ticking.MobMonolith;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.OpenGlHelper;
|
import net.minecraft.client.renderer.OpenGlHelper;
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
import net.minecraft.client.renderer.entity.RenderLiving;
|
import net.minecraft.client.renderer.entity.RenderLiving;
|
||||||
@@ -32,78 +33,93 @@ public class RenderMobObelisk extends RenderLiving
|
|||||||
|
|
||||||
public void doRenderLiving(EntityLiving entity, double x, double y, double z, float par8, float par9)
|
public void doRenderLiving(EntityLiving entity, double x, double y, double z, float par8, float par9)
|
||||||
{
|
{
|
||||||
int noiseFactor = (int) (50-Math.log(MobMonolith.class.cast(entity).aggro));
|
final float minScaling = 0;
|
||||||
this.render(entity, x+entity.worldObj.rand.nextGaussian()/noiseFactor, y+entity.worldObj.rand.nextGaussian()/noiseFactor, z+entity.worldObj.rand.nextGaussian()/noiseFactor, par8, par9);
|
final float maxScaling = 0.1f;
|
||||||
|
final int maxAggroLevel = 500;
|
||||||
|
MobMonolith monolith = ((MobMonolith) entity);
|
||||||
|
|
||||||
|
// Use linear interpolation to scale how much jitter we want for our given aggro level
|
||||||
|
float aggroScaling = minScaling + monolith.aggro * (maxScaling - minScaling) / maxAggroLevel;
|
||||||
|
|
||||||
|
// Calculate jitter - include entity ID to give Monoliths individual jitters
|
||||||
|
float time = ((Minecraft.getSystemTime() + 0xF1234568 * monolith.entityId) % 200000) / 50.0F;
|
||||||
|
// We use random constants here on purpose just to get different wave forms
|
||||||
|
double xJitter = aggroScaling * Math.sin(1.1f * time) * Math.sin(0.8f * time);
|
||||||
|
double yJitter = aggroScaling * Math.sin(1.2f * time) * Math.sin(0.9f * time);
|
||||||
|
double zJitter = aggroScaling * Math.sin(1.3f * time) * Math.sin(0.7f * time);
|
||||||
|
|
||||||
|
// Render with jitter
|
||||||
|
this.render(entity, x + xJitter, y + yJitter, z + zJitter, par8, par9);
|
||||||
this.func_110827_b(entity, x, y, z, par8, par9);
|
this.func_110827_b(entity, x, y, z, par8, par9);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(EntityLiving par1EntityLivingBase, double x, double y, double z, float par8, float par9)
|
public void render(EntityLiving par1EntityLivingBase, double x, double y, double z, float par8, float par9)
|
||||||
{
|
{
|
||||||
if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre(par1EntityLivingBase, this))) return;
|
if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre(par1EntityLivingBase, this))) return;
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
this.mainModel.onGround = this.renderSwingProgress(par1EntityLivingBase, par9);
|
this.mainModel.onGround = this.renderSwingProgress(par1EntityLivingBase, par9);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
float interpolatedYaw = this.interpolateRotation(par1EntityLivingBase.prevRenderYawOffset, par1EntityLivingBase.renderYawOffset, par9);
|
float interpolatedYaw = this.interpolateRotation(par1EntityLivingBase.prevRenderYawOffset, par1EntityLivingBase.renderYawOffset, par9);
|
||||||
float interpolatedYawHead = this.interpolateRotation(par1EntityLivingBase.prevRotationYawHead, par1EntityLivingBase.rotationYawHead, par9);
|
float interpolatedYawHead = this.interpolateRotation(par1EntityLivingBase.prevRotationYawHead, par1EntityLivingBase.rotationYawHead, par9);
|
||||||
float rotation;
|
float rotation;
|
||||||
float pitch = par1EntityLivingBase.prevRotationPitch + (par1EntityLivingBase.rotationPitch - par1EntityLivingBase.prevRotationPitch) * par9;
|
float pitch = par1EntityLivingBase.prevRotationPitch + (par1EntityLivingBase.rotationPitch - par1EntityLivingBase.prevRotationPitch) * par9;
|
||||||
this.renderLivingAt(par1EntityLivingBase, x, y, z);
|
this.renderLivingAt(par1EntityLivingBase, x, y, z);
|
||||||
|
|
||||||
rotation = this.handleRotationFloat(par1EntityLivingBase, par9);
|
rotation = this.handleRotationFloat(par1EntityLivingBase, par9);
|
||||||
this.rotateCorpse(par1EntityLivingBase, rotation, interpolatedYaw, par9);
|
this.rotateCorpse(par1EntityLivingBase, rotation, interpolatedYaw, par9);
|
||||||
float f6 = 0.0625F;
|
float f6 = 0.0625F;
|
||||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||||
GL11.glScalef(-1.0F, -1.0F, 1.0F);
|
GL11.glScalef(-1.0F, -1.0F, 1.0F);
|
||||||
this.preRenderCallback(par1EntityLivingBase, par9);
|
this.preRenderCallback(par1EntityLivingBase, par9);
|
||||||
GL11.glTranslatef(0.0F, -24.0F * f6 - 0.0078125F, 0.0F);
|
GL11.glTranslatef(0.0F, -24.0F * f6 - 0.0078125F, 0.0F);
|
||||||
|
|
||||||
this.renderModel(par1EntityLivingBase, 0, 0, rotation, interpolatedYawHead - interpolatedYaw, pitch, f6);
|
this.renderModel(par1EntityLivingBase, 0, 0, rotation, interpolatedYawHead - interpolatedYaw, pitch, f6);
|
||||||
|
|
||||||
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||||
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||||
|
|
||||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||||
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
GL11.glDisable(GL11.GL_BLEND);
|
GL11.glDisable(GL11.GL_BLEND);
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Post(par1EntityLivingBase, this));
|
MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Post(par1EntityLivingBase, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private float interpolateRotation(float par1, float par2, float par3)
|
private float interpolateRotation(float par1, float par2, float par3)
|
||||||
{
|
{
|
||||||
float f3;
|
float f3;
|
||||||
|
|
||||||
for (f3 = par2 - par1; f3 < -180.0F; f3 += 360.0F)
|
for (f3 = par2 - par1; f3 < -180.0F; f3 += 360.0F)
|
||||||
{
|
{
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (f3 >= 180.0F)
|
while (f3 >= 180.0F)
|
||||||
{
|
{
|
||||||
f3 -= 360.0F;
|
f3 -= 360.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
return par1 + par3 * f3;
|
return par1 + par3 * f3;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected ResourceLocation getEntityTexture(Entity entity)
|
protected ResourceLocation getEntityTexture(Entity entity)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user