Merge pull request #6 from Waterpicker/1.8.9

Did the bulk of Rendering and a few other things.
This commit is contained in:
Zixiken 2016-08-11 09:17:05 -04:00 committed by GitHub
commit 6818cf16f5
19 changed files with 743 additions and 1472 deletions

View file

@ -74,8 +74,8 @@ public class CommonProxy {
IBlockState state = world.getBlockState(pos); IBlockState state = world.getBlockState(pos);
TileEntityDimDoor dimTile = (TileEntityDimDoor) tile; TileEntityDimDoor dimTile = (TileEntityDimDoor) tile;
dimTile.openOrClosed = door.isDoorOnRift(world, pos) && door.isUpperDoorBlock(state); dimTile.openOrClosed = door.isDoorOnRift(world, pos) && door.isUpperDoorBlock(state);
dimTile.orientation = state.getValue(BlockDoor.FACING).rotateY().getHorizontalIndex(); dimTile.orientation = state.getValue(BlockDoor.FACING).rotateY();
if(state.getValue(BlockDoor.OPEN)) dimTile.orientation |= 4; //if(state.getValue(BlockDoor.OPEN)) dimTile.orientation |= 4;
dimTile.lockStatus = door.getLockStatus(world, pos); dimTile.lockStatus = door.getLockStatus(world, pos);
} }
} }

View file

@ -79,32 +79,24 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
return this; return this;
} }
public boolean isDoorOnRift(World world, BlockPos pos) public boolean isDoorOnRift(World world, BlockPos pos) {
{
return this.getLink(world, pos) != null; return this.getLink(world, pos) != null;
} }
public DimLink getLink(World world, BlockPos pos) public DimLink getLink(World world, BlockPos pos) {
{
DimLink link= PocketManager.getLink(pos, world.provider.getDimensionId()); DimLink link= PocketManager.getLink(pos, world.provider.getDimensionId());
if(link!=null) if(link!=null) {
{
return link; return link;
} }
if(isUpperDoorBlock(world.getBlockState(pos))) if(isUpperDoorBlock(world.getBlockState(pos))) {
{
link = PocketManager.getLink(pos.down(), world.provider.getDimensionId()); link = PocketManager.getLink(pos.down(), world.provider.getDimensionId());
if(link!=null) if(link!=null) {
{
return link; return link;
} }
} } else {
else
{
link = PocketManager.getLink(pos.up(), world.provider.getDimensionId()); link = PocketManager.getLink(pos.up(), world.provider.getDimensionId());
if(link != null) if(link != null) {
{
return link; return link;
} }
} }
@ -117,89 +109,56 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
} }
@Override @Override
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) {
{
this.setDoorRotation(worldIn.getBlockState(pos)); this.setDoorRotation(worldIn.getBlockState(pos));
} }
private void setDoorRotation(IBlockState state) private void setDoorRotation(IBlockState state) {
{
float var2 = 0.1875F; float var2 = 0.1875F;
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F); setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F);
int var3 = state.getValue(BlockDoor.FACING).rotateY().getHorizontalIndex(); int var3 = state.getValue(BlockDoor.FACING).rotateY().getHorizontalIndex();
boolean var4 = state.getValue(BlockDoor.OPEN); boolean var4 = state.getValue(BlockDoor.OPEN);
boolean var5 = state.getValue(BlockDoor.HINGE) == EnumHingePosition.LEFT; boolean var5 = state.getValue(BlockDoor.HINGE) == EnumHingePosition.LEFT;
if (var3 == 0) if (var3 == 0) {
{ if (var4) {
if (var4) if (!var5) {
{
if (!var5)
{
setBlockBounds(0.001F, 0.0F, 0.0F, 1.0F, 1.0F, var2); setBlockBounds(0.001F, 0.0F, 0.0F, 1.0F, 1.0F, var2);
} } else {
else
{
setBlockBounds(0.001F, 0.0F, 1.0F - var2, 1.0F, 1.0F, 1.0F); setBlockBounds(0.001F, 0.0F, 1.0F - var2, 1.0F, 1.0F, 1.0F);
} }
} } else {
else
{
setBlockBounds(0.0F, 0.0F, 0.0F, var2, 1.0F, 1.0F); setBlockBounds(0.0F, 0.0F, 0.0F, var2, 1.0F, 1.0F);
} }
} } else if (var3 == 1) {
else if (var3 == 1) if (var4) {
{ if (!var5) {
if (var4)
{
if (!var5)
{
setBlockBounds(1.0F - var2, 0.0F, 0.001F, 1.0F, 1.0F, 1.0F); setBlockBounds(1.0F - var2, 0.0F, 0.001F, 1.0F, 1.0F, 1.0F);
} } else {
else
{
setBlockBounds(0.0F, 0.0F, 0.001F, var2, 1.0F, 1.0F); setBlockBounds(0.0F, 0.0F, 0.001F, var2, 1.0F, 1.0F);
} }
} } else {
else
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, var2); setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, var2);
} }
} } else if (var3 == 2) {
else if (var3 == 2) if (var4) {
{ if (!var5) {
if (var4)
{
if (!var5)
{
setBlockBounds(0.0F, 0.0F, 1.0F - var2, .99F, 1.0F, 1.0F); setBlockBounds(0.0F, 0.0F, 1.0F - var2, .99F, 1.0F, 1.0F);
} } else {
else
{
setBlockBounds(0.0F, 0.0F, 0.0F, .99F, 1.0F, var2); setBlockBounds(0.0F, 0.0F, 0.0F, .99F, 1.0F, var2);
} }
} } else {
else
{
setBlockBounds(1.0F - var2, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); setBlockBounds(1.0F - var2, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
} }
} } else if (var3 == 3) {
else if (var3 == 3) if (var4) {
{ if (!var5) {
if (var4)
{
if (!var5)
{
setBlockBounds(0.0F, 0.0F, 0.0F, var2, 1.0F, 0.99F); setBlockBounds(0.0F, 0.0F, 0.0F, var2, 1.0F, 0.99F);
} } else {
else
{
setBlockBounds(1.0F - var2, 0.0F, 0.0F, 1.0F, 1.0F, 0.99F); setBlockBounds(1.0F - var2, 0.0F, 0.0F, 1.0F, 1.0F, 0.99F);
} }
} } else {
else
{
setBlockBounds(0.0F, 0.0F, 1.0F - var2, 1.0F, 1.0F, 1.0F); setBlockBounds(0.0F, 0.0F, 1.0F - var2, 1.0F, 1.0F, 1.0F);
} }
} }
@ -212,7 +171,6 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
*/ */
@Override @Override
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighbor) { public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighbor) {
if (isUpperDoorBlock(state)) { if (isUpperDoorBlock(state)) {
if (world.getBlockState(pos.down()) != this) if (world.getBlockState(pos.down()) != this)
world.setBlockToAir(pos); world.setBlockToAir(pos);

View file

@ -20,7 +20,6 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.Explosion; import net.minecraft.world.Explosion;
import net.minecraft.world.World; import net.minecraft.world.World;
import com.zixiken.dimdoors.client.PrivatePocketRender;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -65,10 +64,6 @@ public class BlockDimWall extends Block {
else return SUPER_EXPLOSION_RESISTANCE; else return SUPER_EXPLOSION_RESISTANCE;
} }
public int getRenderType() {
return PrivatePocketRender.renderID;
}
@Override @Override
public int damageDropped(IBlockState state) { public int damageDropped(IBlockState state) {
int metadata = state.getValue(TYPE); int metadata = state.getValue(TYPE);

View file

@ -2,17 +2,17 @@ package com.zixiken.dimdoors.client;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.config.DDProperties; import com.zixiken.dimdoors.config.DDProperties;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.ISound; import net.minecraft.client.audio.ISound;
import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.sound.PlaySoundEvent17; import net.minecraftforge.client.event.sound.PlaySoundEvent;
import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ClientOnlyHooks { public class ClientOnlyHooks {
private DDProperties properties; private DDProperties properties;
@ -21,18 +21,18 @@ public class ClientOnlyHooks {
public ClientOnlyHooks(DDProperties properties) { public ClientOnlyHooks(DDProperties properties) {
this.properties = properties; this.properties = properties;
this.limboMusic = PositionedSoundRecord.func_147673_a(new ResourceLocation(DimDoors.modid + ":creepy")); this.limboMusic = PositionedSoundRecord.create(new ResourceLocation(DimDoors.MODID + ":creepy"));
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@SubscribeEvent @SubscribeEvent
public void onSoundEffectResult(PlaySoundEvent17 event) public void onSoundEffectResult(PlaySoundEvent event)
{ {
ResourceLocation playingSound = event.sound.getPositionedSoundLocation(); ResourceLocation playingSound = event.sound.getSoundLocation();
if (playingSound != null && playingSound.getResourceDomain().equals("minecraft") && (playingSound.getResourcePath().equals("music.game") || playingSound.getResourcePath().equals("music.game.creative"))) { if (playingSound != null && playingSound.getResourceDomain().equals("minecraft") && (playingSound.getResourcePath().equals("music.game") || playingSound.getResourcePath().equals("music.game.creative"))) {
if (FMLClientHandler.instance().getClient().thePlayer.worldObj.provider.dimensionId == DimDoors.properties.LimboDimensionID) { if (FMLClientHandler.instance().getClient().thePlayer.worldObj.provider.getDimensionId() == DimDoors.properties.LimboDimensionID) {
ResourceLocation sound = new ResourceLocation(DimDoors.modid + ":creepy"); ResourceLocation sound = new ResourceLocation(DimDoors.MODID + ":creepy");
if (!Minecraft.getMinecraft().getSoundHandler().isSoundPlaying(limboMusic)) { if (!Minecraft.getMinecraft().getSoundHandler().isSoundPlaying(limboMusic)) {
event.result = limboMusic; event.result = limboMusic;
@ -45,7 +45,7 @@ public class ClientOnlyHooks {
@SubscribeEvent @SubscribeEvent
public void onWorldLoad(WorldEvent.Load event) { public void onWorldLoad(WorldEvent.Load event) {
if (event.world.provider.dimensionId == DimDoors.properties.LimboDimensionID && if (event.world.provider.getDimensionId() == DimDoors.properties.LimboDimensionID &&
event.world.isRemote && !Minecraft.getMinecraft().getSoundHandler().isSoundPlaying(limboMusic)) { event.world.isRemote && !Minecraft.getMinecraft().getSoundHandler().isSoundPlaying(limboMusic)) {
Minecraft.getMinecraft().getSoundHandler().playSound(limboMusic); Minecraft.getMinecraft().getSoundHandler().playSound(limboMusic);
} }

View file

@ -4,68 +4,42 @@ import com.zixiken.dimdoors.core.PocketManager;
import net.minecraft.client.particle.EffectRenderer; import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.particle.EntityFX; import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World; import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class ClosingRiftFX extends EntityFX public class ClosingRiftFX extends EntityFX
{ {
private int field_92049_a = 160; private int baseTextureIndex = 160;
private boolean field_92054_ax; private boolean trail;
private boolean field_92048_ay; private boolean twinkle;
private final EffectRenderer field_92047_az; private EffectRenderer effectRenderer;
private float field_92050_aA; private float fadeColourRed;
private float field_92051_aB; private float fadeColourGreen;
private float field_92052_aC; private float fadeColourBlue;
private boolean field_92053_aD; private boolean hasFadeColour;
public ClosingRiftFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, EffectRenderer par14EffectRenderer) public ClosingRiftFX(World world, double x, double y, double z, double motionX, double motionY, double motionZ, EffectRenderer effectRenderer) {
{
super(par1World, par2, par4, par6); super(world, x, y, z);
this.motionX = par8; this.motionX = motionX;
this.motionY = par10; this.motionY = motionY;
this.motionZ = par12; this.motionZ = motionZ;
this.field_92047_az = par14EffectRenderer; this.effectRenderer = effectRenderer;
this.particleScale *= .55F; this.particleScale *= .55F;
this.particleMaxAge = 30 + this.rand.nextInt(16); this.particleMaxAge = 30 + this.rand.nextInt(16);
this.noClip = true; this.noClip = true;
} }
public void func_92045_e(boolean par1)
{
this.field_92054_ax = par1;
}
public void func_92043_f(boolean par1)
{
this.field_92048_ay = par1;
}
public void func_92044_a(int par1)
{
float var2 = ((par1 & 16711680) >> 16) / 255.0F;
float var3 = ((par1 & 65280) >> 8) / 255.0F;
float var4 = ((par1 & 255) >> 0) / 255.0F;
float var5 = 1.0F;
this.setRBGColorF(var2 * var5, var3 * var5, var4 * var5);
}
public void func_92046_g(int par1)
{
this.field_92050_aA = ((par1 & 16711680) >> 16) / 255.0F;
this.field_92051_aB = ((par1 & 65280) >> 8) / 255.0F;
this.field_92052_aC = ((par1 & 255) >> 0) / 255.0F;
this.field_92053_aD = true;
}
/** /**
* returns the bounding box for this entity * returns the bounding box for this entity
*/ */
@Override @Override
public AxisAlignedBB getBoundingBox() public AxisAlignedBB getCollisionBoundingBox()
{ {
return null; return null;
} }
@ -74,116 +48,97 @@ public class ClosingRiftFX extends EntityFX
* Returns true if this entity should push and be pushed by other entities when colliding. * Returns true if this entity should push and be pushed by other entities when colliding.
*/ */
@Override @Override
public boolean canBePushed() public boolean canBePushed() {
{
return false; return false;
} }
@Override @Override
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) public void renderParticle(WorldRenderer worldRenderer, Entity entityIn, float partialTicks, float p_180434_4_, float p_180434_5_, float p_180434_6_, float p_180434_7_, float p_180434_8_) {
{ if (!this.twinkle || this.particleAge < this.particleMaxAge / 3 || (this.particleAge + this.particleMaxAge) / 3 % 2 == 0) {
if (!this.field_92048_ay || this.particleAge < this.particleMaxAge / 3 || (this.particleAge + this.particleMaxAge) / 3 % 2 == 0) this.doRenderParticle(worldRenderer, partialTicks, p_180434_4_, p_180434_5_, p_180434_6_, p_180434_7_, p_180434_8_);
{ }
this.doRenderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7);
}
} }
public void doRenderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) public void doRenderParticle(WorldRenderer worldRenderer, float par2, float par3, float par4, float par5, float par6, float par7) {
{ float var8 = super.particleTextureIndexX % 16 / 16.0F;
float var8 = super.particleTextureIndexX % 16 / 16.0F; float var9 = var8 + 0.0624375F;
float var9 = var8 + 0.0624375F; float var10 = this.particleTextureIndexX / 16 / 16.0F;
float var10 = this.particleTextureIndexX / 16 / 16.0F; float var11 = var10 + 0.0624375F;
float var11 = var10 + 0.0624375F; float var12 = 0.1F * this.particleScale;
float var12 = 0.1F * this.particleScale; float var13 = (float)(this.prevPosX + (this.posX - this.prevPosX) * par2 - interpPosX);
float var13 = (float)(this.prevPosX + (this.posX - this.prevPosX) * par2 - interpPosX); float var14 = (float)(this.prevPosY + (this.posY - this.prevPosY) * par2 - interpPosY);
float var14 = (float)(this.prevPosY + (this.posY - this.prevPosY) * par2 - interpPosY); float var15 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * par2 - interpPosZ);
float var15 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * par2 - interpPosZ); float var16 = 0.8F;
float var16 = 0.8F;
if (PocketManager.createDimensionData(worldObj).isPocketDimension()) if (PocketManager.createDimensionData(worldObj).isPocketDimension()) {
{ var16 = 0.4F;
var16 = 0.4F; }
}
par1Tessellator.setColorRGBA_F(this.particleRed * var16, this.particleGreen * var16, this.particleBlue * var16, (float) .7);
par1Tessellator.addVertexWithUV(var13 - par3 * var12 - par6 * var12, var14 - par4 * var12, var15 - par5 * var12 - par7 * var12, var9, var11); worldRenderer.pos(var13 - par3 * var12 - par6 * var12, var14 - par4 * var12, var15 - par5 * var12 - par7 * var12).tex(var9, var11).color(this.particleRed * var16, this.particleGreen * var16, this.particleBlue * var16, (float) .7).endVertex();
par1Tessellator.addVertexWithUV(var13 - par3 * var12 + par6 * var12, var14 + par4 * var12, var15 - par5 * var12 + par7 * var12, var9, var10); worldRenderer.pos(var13 - par3 * var12 + par6 * var12, var14 + par4 * var12, var15 - par5 * var12 + par7 * var12).tex(var9, var10).color(this.particleRed * var16, this.particleGreen * var16, this.particleBlue * var16, (float) .7).endVertex();
par1Tessellator.addVertexWithUV(var13 + par3 * var12 + par6 * var12, var14 + par4 * var12, var15 + par5 * var12 + par7 * var12, var8, var10); worldRenderer.pos(var13 + par3 * var12 + par6 * var12, var14 + par4 * var12, var15 + par5 * var12 + par7 * var12).tex(var8, var10).color(this.particleRed * var16, this.particleGreen * var16, this.particleBlue * var16, (float) .7).endVertex();
par1Tessellator.addVertexWithUV(var13 + par3 * var12 - par6 * var12, var14 - par4 * var12, var15 + par5 * var12 - par7 * var12, var8, var11); worldRenderer.pos(var13 + par3 * var12 - par6 * var12, var14 - par4 * var12, var15 + par5 * var12 - par7 * var12).tex(var8, var11).color(this.particleRed * var16, this.particleGreen * var16, this.particleBlue * var16, (float) .7).endVertex();
} }
/** /**
* Called to update the entity's position/logic. * Called to update the entity's position/logic.
*/ */
@Override @Override
public void onUpdate() public void onUpdate() {
{ this.prevPosX = this.posX;
this.prevPosX = this.posX; this.prevPosY = this.posY;
this.prevPosY = this.posY; this.prevPosZ = this.posZ;
this.prevPosZ = this.posZ;
if (this.particleAge++ >= this.particleMaxAge) if (this.particleAge++ >= this.particleMaxAge) {
{ this.setDead();
this.setDead(); } if (this.particleAge > this.particleMaxAge / 2) {
} this.setAlphaF(1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / this.particleMaxAge);
if (this.particleAge > this.particleMaxAge / 2) if (this.hasFadeColour) {
{ this.particleRed += (this.fadeColourRed - this.particleRed) * 0.2F;
this.setAlphaF(1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / this.particleMaxAge); this.particleGreen += (this.fadeColourGreen - this.particleGreen) * 0.2F;
this.particleBlue += (this.fadeColourBlue - this.particleBlue) * 0.2F;
}
}
if (this.field_92053_aD) this.setParticleTextureIndex(this.baseTextureIndex + (7 - this.particleAge * 8 / this.particleMaxAge));
{ // this.motionY -= 0.004D;
this.particleRed += (this.field_92050_aA - this.particleRed) * 0.2F; this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.particleGreen += (this.field_92051_aB - this.particleGreen) * 0.2F; this.motionX *= 0.9100000262260437D;
this.particleBlue += (this.field_92052_aC - this.particleBlue) * 0.2F; this.motionY *= 0.9100000262260437D;
} this.motionZ *= 0.9100000262260437D;
}
this.setParticleTextureIndex(this.field_92049_a + (7 - this.particleAge * 8 / this.particleMaxAge)); if (this.onGround) {
// this.motionY -= 0.004D; this.motionX *= 0.699999988079071D;
this.moveEntity(this.motionX, this.motionY, this.motionZ); this.motionZ *= 0.699999988079071D;}
this.motionX *= 0.9100000262260437D;
this.motionY *= 0.9100000262260437D;
this.motionZ *= 0.9100000262260437D;
if (this.onGround) if (this.trail && this.particleAge < this.particleMaxAge / 2 && (this.particleAge + this.particleMaxAge) % 2 == 0) {
{ ClosingRiftFX var1 = new ClosingRiftFX(this.worldObj, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, this.effectRenderer);
this.motionX *= 0.699999988079071D; var1.setRBGColorF(this.particleRed, this.particleGreen, this.particleBlue);
this.motionZ *= 0.699999988079071D; var1.particleAge = var1.particleMaxAge / 2;
}
if (this.field_92054_ax && this.particleAge < this.particleMaxAge / 2 && (this.particleAge + this.particleMaxAge) % 2 == 0) if (this.hasFadeColour) {
{ var1.hasFadeColour = true;
ClosingRiftFX var1 = new ClosingRiftFX(this.worldObj, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, this.field_92047_az); var1.fadeColourRed = this.fadeColourRed;
var1.setRBGColorF(this.particleRed, this.particleGreen, this.particleBlue); var1.fadeColourGreen = this.fadeColourGreen;
var1.particleAge = var1.particleMaxAge / 2; var1.fadeColourBlue = this.fadeColourBlue;
}
if (this.field_92053_aD) var1.twinkle = this.twinkle;
{ this.effectRenderer.addEffect(var1);
var1.field_92053_aD = true; }
var1.field_92050_aA = this.field_92050_aA; }
var1.field_92051_aB = this.field_92051_aB;
var1.field_92052_aC = this.field_92052_aC;
}
var1.field_92048_ay = this.field_92048_ay; @Override
this.field_92047_az.addEffect(var1); public int getBrightnessForRender(float par1) {
}
}
@Override
public int getBrightnessForRender(float par1)
{
return 15728880; return 15728880;
} }
/** /**
* Gets how bright this entity is. * Gets how bright this entity is.
*/ */
@Override @Override
public float getBrightness(float par1) public float getBrightness(float par1) {
{ return 1.0F;
return 1.0F; }
}
} }

View file

@ -4,196 +4,17 @@ import com.zixiken.dimdoors.core.PocketManager;
import net.minecraft.client.particle.EffectRenderer; import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.particle.EntityFirework; import net.minecraft.client.particle.EntityFirework;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class GoggleRiftFX extends EntityFirework.SparkFX public class GoggleRiftFX extends EntityFirework.SparkFX {
{ public GoggleRiftFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, EffectRenderer par14EffectRenderer) {
private int field_92049_a = 160;
private boolean field_92054_ax;
private boolean field_92048_ay;
private final EffectRenderer field_92047_az;
private float field_92050_aA;
private float field_92051_aB;
private float field_92052_aC;
private boolean field_92053_aD;
public GoggleRiftFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, EffectRenderer par14EffectRenderer)
{
super(par1World, par2, par4, par6, par12, par12, par12, par14EffectRenderer); super(par1World, par2, par4, par6, par12, par12, par12, par14EffectRenderer);
this.motionX = par8;
this.motionY = par10;
this.motionZ = par12;
this.field_92047_az = par14EffectRenderer;
this.particleScale *= 0.75F;
this.particleMaxAge = 40 + this.rand.nextInt(26); this.particleMaxAge = 40 + this.rand.nextInt(26);
this.noClip = true; this.noClip = true;
} }
}
public void func_92045_e(boolean par1)
{
this.field_92054_ax = par1;
}
public void func_92043_f(boolean par1)
{
this.field_92048_ay = par1;
}
public void func_92044_a(int par1)
{
float var2 = ((par1 & 16711680) >> 16) / 255.0F;
float var3 = ((par1 & 65280) >> 8) / 255.0F;
float var4 = ((par1 & 255) >> 0) / 255.0F;
float var5 = 1.0F;
this.setRBGColorF(var2 * var5, var3 * var5, var4 * var5);
}
public void func_92046_g(int par1)
{
this.field_92050_aA = ((par1 & 16711680) >> 16) / 255.0F;
this.field_92051_aB = ((par1 & 65280) >> 8) / 255.0F;
this.field_92052_aC = ((par1 & 255) >> 0) / 255.0F;
this.field_92053_aD = true;
}
/**
* returns the bounding box for this entity
*/
@Override
public AxisAlignedBB getBoundingBox()
{
return null;
}
/**
* Returns true if this entity should push and be pushed by other entities when colliding.
*/
@Override
public boolean canBePushed()
{
return false;
}
@Override
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
{
if (!this.field_92048_ay || this.particleAge < this.particleMaxAge / 3 || (this.particleAge + this.particleMaxAge) / 3 % 2 == 0)
{
this.doRenderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7);
}
}
public void doRenderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
{
float f6 = this.particleTextureIndexX / 16.0F;
float f7 = f6 + 0.0624375F;
float f8 = this.particleTextureIndexY / 16.0F;
float f9 = f8 + 0.0624375F;
float f10 = 0.1F * this.particleScale;
if (this.particleIcon != null)
{
f6 = this.particleIcon.getMinU();
f7 = this.particleIcon.getMaxU();
f8 = this.particleIcon.getMinV();
f9 = this.particleIcon.getMaxV();
}
float f11 = (float)(this.prevPosX + (this.posX - this.prevPosX) * par2 - interpPosX);
float f12 = (float)(this.prevPosY + (this.posY - this.prevPosY) * par2 - interpPosY);
float f13 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * par2 - interpPosZ);
float f14 = 0F;
if (PocketManager.createDimensionData(worldObj).isPocketDimension())
{
f14 = 0.7F;
}
par1Tessellator.setColorRGBA_F(this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, (float) .7);
par1Tessellator.addVertexWithUV(f11 - par3 * f10 - par6 * f10, f12 - par4 * f10, f13 - par5 * f10 - par7 * f10, f7, f9);
par1Tessellator.addVertexWithUV(f11 - par3 * f10 + par6 * f10, f12 + par4 * f10, f13 - par5 * f10 + par7 * f10, f7, f8);
par1Tessellator.addVertexWithUV(f11 + par3 * f10 + par6 * f10, f12 + par4 * f10, f13 + par5 * f10 + par7 * f10, f6, f8);
par1Tessellator.addVertexWithUV(f11 + par3 * f10 - par6 * f10, f12 - par4 * f10, f13 + par5 * f10 - par7 * f10, f6, f9);
}
/**
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate()
{
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if (this.particleAge++ >= this.particleMaxAge)
{
this.setDead();
}
if (this.particleAge > this.particleMaxAge / 2)
{
this.setAlphaF(1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / this.particleMaxAge);
if (this.field_92053_aD)
{
this.particleRed += (this.field_92050_aA - this.particleRed) * 0.2F;
this.particleGreen += (this.field_92051_aB - this.particleGreen) * 0.2F;
this.particleBlue += (this.field_92052_aC - this.particleBlue) * 0.2F;
}
}
this.setParticleTextureIndex(this.field_92049_a + (7 - this.particleAge * 8 / this.particleMaxAge));
// this.motionY -= 0.004D;
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.9100000262260437D;
this.motionY *= 0.9100000262260437D;
this.motionZ *= 0.9100000262260437D;
if (this.onGround)
{
this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D;
}
if (this.field_92054_ax && this.particleAge < this.particleMaxAge / 2 && (this.particleAge + this.particleMaxAge) % 2 == 0)
{
GoggleRiftFX var1 = new GoggleRiftFX(this.worldObj, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, this.field_92047_az);
var1.setRBGColorF(this.particleRed, this.particleGreen, this.particleBlue);
var1.particleAge = var1.particleMaxAge / 2;
if (this.field_92053_aD)
{
var1.field_92053_aD = true;
var1.field_92050_aA = this.field_92050_aA;
var1.field_92051_aB = this.field_92051_aB;
var1.field_92052_aC = this.field_92052_aC;
}
var1.field_92048_ay = this.field_92048_ay;
this.field_92047_az.addEffect(var1);
}
}
@Override
public int getBrightnessForRender(float par1)
{
return 15728880;
}
/**
* Gets how bright this entity is.
*/
@Override
public float getBrightness(float par1)
{
return 1.0F;
}
}

View file

@ -4,51 +4,34 @@
// Keep in mind that you still need to fill in some blanks // Keep in mind that you still need to fill in some blanks
// - ZeuX // - ZeuX
package com.zixiken.dimdoors.client; package com.zixiken.dimdoors.client;
import java.util.Random; import java.util.Random;
import com.zixiken.dimdoors.ticking.MobMonolith; import com.zixiken.dimdoors.ticking.MobMonolith;
import net.minecraft.client.renderer.GlStateManager;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
public class ModelMobObelisk extends ModelBase public class ModelMobObelisk extends ModelBase {
{ //fields
//fields
ModelRenderer wholemonolith; ModelRenderer wholemonolith;
Random rand = new Random(); Random rand = new Random();
public ModelMobObelisk() {
textureWidth = 256;
textureHeight = 256;
wholemonolith = new ModelRenderer(this, 0, 0);
wholemonolith.addBox(-48/2F,-108F/1.3F, -12/2F, 48, 108, 12);
}
public ModelMobObelisk() @Override
{ public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) {
textureWidth = 256;
textureHeight = 256;
wholemonolith = new ModelRenderer(this, 0, 0);
wholemonolith.addBox(-48/2F,-108F/1.3F, -12/2F, 48, 108, 12);
}
@Override
public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7)
{
this.setRotationAngles(0, 0, 0, 0, 0,0, par1Entity); this.setRotationAngles(0, 0, 0, 0, 0,0, par1Entity);
GlStateManager.scale(((MobMonolith) par1Entity).getRenderSizeModifier(), ((MobMonolith) par1Entity).getRenderSizeModifier(), ((MobMonolith) par1Entity).getRenderSizeModifier());
GL11.glScalef(((MobMonolith) par1Entity).getRenderSizeModifier(), ((MobMonolith) par1Entity).getRenderSizeModifier(), ((MobMonolith) par1Entity).getRenderSizeModifier());
wholemonolith.render(par7); wholemonolith.render(par7);
} }
} }

View file

@ -1,159 +0,0 @@
package com.zixiken.dimdoors.client;
import net.minecraft.util.IIcon;
import org.lwjgl.opengl.GL11;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
public class PrivatePocketRender implements ISimpleBlockRenderingHandler
{
public static int renderID;
public PrivatePocketRender(int renderID)
{
PrivatePocketRender.renderID = renderID;
}
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
{
Tessellator tessellator = Tessellator.instance;
float f2;
float f3;
int k;
block.setBlockBoundsForItemRender();
renderer.setRenderBoundsFromBlock(block);
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, -1.0F, 0.0F);
renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 0, metadata));
tessellator.draw();
if (renderer.useInventoryTint)
{
k = block.getRenderColor(metadata);
f2 = (float)(k >> 16 & 255) / 255.0F;
f3 = (float)(k >> 8 & 255) / 255.0F;
float f7 = (float)(k & 255) / 255.0F;
//GL11.glColor4f(f2 * par3, f3 * par3, f7 * par3, 1.0F);
}
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 1, metadata));
tessellator.draw();
if (renderer.useInventoryTint)
{
// GL11.glColor4f(par3, par3, par3, 1.0F);
}
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, -1.0F);
renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 2, metadata));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, 1.0F);
renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 3, metadata));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 4, metadata));
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(1.0F, 0.0F, 0.0F);
renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 5, metadata));
tessellator.draw();
GL11.glTranslatef(0.5F, 0.5F, 0.5F); }
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
{
Tessellator tessellator = Tessellator.instance;
boolean flag = false;
IIcon icon = renderer.getBlockIcon(block, world, x, y, z, 2);
tessellator.setColorOpaque_F(1F, 1F, 1F);
if (renderer.renderAllFaces || block.shouldSideBeRendered(world, x, y - 1, z, 0))
{
renderer.renderFaceYNeg(block, (double)x, (double)y, (double)z, icon);
flag = true;
}
tessellator.setColorOpaque_F(1F, 1F, 1F);
if (renderer.renderAllFaces || block.shouldSideBeRendered(world, x, y + 1, z, 1))
{
renderer.renderFaceYPos(block, (double)x, (double)y, (double)z, icon);
flag = true;
}
tessellator.setColorOpaque_F(1F, 1F, 1F);
if (renderer.renderAllFaces || block.shouldSideBeRendered(world, x, y, z - 1, 2))
{
renderer.renderFaceZNeg(block, (double)x, (double)y, (double)z, icon);
flag = true;
}
tessellator.setColorOpaque_F(1F, 1F, 1F);
if (renderer.renderAllFaces || block.shouldSideBeRendered(world, x, y, z + 1, 3))
{
renderer.renderFaceZPos(block, (double)x, (double)y, (double)z, icon);
flag = true;
}
tessellator.setColorOpaque_F(1F, 1F, 1F);
if (renderer.renderAllFaces || block.shouldSideBeRendered(world, x - 1, y, z, 4))
{
renderer.renderFaceXNeg(block, (double)x, (double)y, (double)z, icon);
flag = true;
}
tessellator.setColorOpaque_F(1F, 1F, 1F);
if (renderer.renderAllFaces || block.shouldSideBeRendered(world, x + 1, y, z, 5))
{
renderer.renderFaceXPos(block, (double)x, (double)y, (double)z, icon);
flag = true;
}
return flag;
}
@Override
public boolean shouldRender3DInInventory(int data)
{
// TODO Auto-generated method stub
return true;
}
@Override
public int getRenderId()
{
// TODO Auto-generated method stub
return renderID;
}
}

View file

@ -9,31 +9,29 @@ import java.util.Random;
import com.zixiken.dimdoors.config.DDProperties; import com.zixiken.dimdoors.config.DDProperties;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.tileentities.TileEntityDimDoor; import com.zixiken.dimdoors.tileentities.TileEntityDimDoor;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL11.*;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class RenderDimDoor extends TileEntitySpecialRenderer<TileEntityDimDoor> public class RenderDimDoor extends TileEntitySpecialRenderer<TileEntityDimDoor>
{ {
private FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16); private FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16);
private ResourceLocation warpPath= new ResourceLocation(DimDoors.modid + ":textures/other/WARP.png"); private ResourceLocation warpPath= new ResourceLocation(DimDoors.MODID + ":textures/other/WARP.png");
private ResourceLocation keyPath= new ResourceLocation(DimDoors.modid + ":textures/other/keyhole.png"); private ResourceLocation keyPath= new ResourceLocation(DimDoors.MODID + ":textures/other/keyhole.png");
private ResourceLocation KeyholeLight= new ResourceLocation(DimDoors.modid + ":textures/other/keyholeLight.png"); private ResourceLocation KeyholeLight= new ResourceLocation(DimDoors.MODID + ":textures/other/keyholeLight.png");
private ResourceLocation keyOutline= new ResourceLocation(DimDoors.modid + ":textures/other/keyOutline.png"); private ResourceLocation keyOutline= new ResourceLocation(DimDoors.MODID + ":textures/other/keyOutline.png");
private ResourceLocation keyOutlineLight= new ResourceLocation(DimDoors.modid + ":textures/other/keyOutlineLight.png"); private ResourceLocation keyOutlineLight= new ResourceLocation(DimDoors.MODID + ":textures/other/keyOutlineLight.png");
private static final int NETHER_DIMENSION_ID = -1; private static final int NETHER_DIMENSION_ID = -1;
@ -47,162 +45,122 @@ public class RenderDimDoor extends TileEntitySpecialRenderer<TileEntityDimDoor>
/** /**
* Renders the dimdoor. * Renders the dimdoor.
*/ */
public void renderDimDoorTileEntity(TileEntityDimDoor tile, double x, public void renderDimDoorTileEntity(TileEntityDimDoor tile, double x, double y, double z) {
double y, double z)
{
GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_LIGHTING);
Random rand = new Random(31100L); Random rand = new Random(31100L);
float var13 = 0.75F; float var13 = 0.75F;
for (int count = 0; count < 16; ++count) for (int count = 0; count < 16; ++count) {
{ GlStateManager.pushMatrix();
GL11.glPushMatrix();
float var15 = 16 - count; float var15 = 16 - count;
float var16 = 0.2625F; float var16 = 0.2625F;
float var17 = 1.0F / (var15 + .80F); float var17 = 1.0F / (var15 + .80F);
if (count == 0) this.bindTexture(warpPath);
{ GlStateManager.enableBlend();
this.bindTexture(warpPath);
// move files into assets/modid and change to new ResourceLocation(modid:/RIFT.png) if (count == 0) {
var17 = 0.1F; var17 = 0.1F;
var15 = 25.0F; var15 = 25.0F;
var16 = 0.125F; var16 = 0.125F;
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
} }
if (count == 1) if (count == 1) {
{
this.bindTexture(warpPath);
// move files into assets/modid and change to new ResourceLocation(modid:/WARP.png)
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
var16 = .5F; var16 = .5F;
GlStateManager.blendFunc(GL11.GL_ONE, GL11.GL_ONE);
} }
GL11.glTranslatef( GlStateManager.translate(Minecraft.getSystemTime() % 200000L / 200000.0F, 0, 0.0F);
Minecraft.getSystemTime() % 200000L / 200000.0F, GlStateManager.translate(0, Minecraft.getSystemTime() % 200000L / 200000.0F, 0.0F);
0, 0.0F); GlStateManager.translate(0, 0, Minecraft.getSystemTime() % 200000L / 200000.0F);
GL11.glTranslatef(0,
Minecraft.getSystemTime() % 200000L / 200000.0F,
0.0F);
GL11.glTranslatef(0, 0,
Minecraft.getSystemTime() % 200000L / 200000.0F);
GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_LINEAR);
GL11.GL_OBJECT_LINEAR); GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_LINEAR);
GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_LINEAR);
GL11.GL_OBJECT_LINEAR); GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_LINEAR);
GL11.glTexGeni(GL11.GL_R, GL11.GL_TEXTURE_GEN_MODE,
GL11.GL_OBJECT_LINEAR); EnumFacing orientation = EnumFacing.getHorizontal((tile.orientation.getHorizontalIndex() % 4) + 4);
GL11.glTexGeni(GL11.GL_Q, GL11.GL_TEXTURE_GEN_MODE,
GL11.GL_OBJECT_LINEAR); switch (orientation) {
switch ((tile.orientation % 4) + 4) case SOUTH:
{ GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
case 4: GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 1.0F, 0.0F));
GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE, GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F)); GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.15F));
GL11.glTexGen(GL11.GL_T, GL11.GL_OBJECT_PLANE, break;
this.getFloatBuffer(0.0F, 0.0F, 1.0F, 0.0F)); case WEST:
GL11.glTexGen(GL11.GL_R, GL11.GL_OBJECT_PLANE, GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F)); GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F));
GL11.glTexGen(GL11.GL_Q, GL11.GL_OBJECT_PLANE, GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.15F)); GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 1.0F, 0.15F));
break;
break; case NORTH:
case 5: GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 1.0F, 0.0F));
GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE, GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F)); GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(1.0F, 0.0F, 0.0F, -0.15F));
GL11.glTexGen(GL11.GL_T, GL11.GL_OBJECT_PLANE, break;
this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F)); case EAST:
GL11.glTexGen(GL11.GL_R, GL11.GL_OBJECT_PLANE, GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F)); GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F));
GL11.glTexGen(GL11.GL_Q, GL11.GL_OBJECT_PLANE, GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
this.getFloatBuffer(0.0F, 0.0F, 1.0F, 0.15F)); GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 1.0F, -0.15F));
break; break;
case 6: }
GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE,
this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F)); GlStateManager.enableTexGenCoord(GlStateManager.TexGen.S);
GL11.glTexGen(GL11.GL_T, GL11.GL_OBJECT_PLANE, GlStateManager.enableTexGenCoord(GlStateManager.TexGen.T);
this.getFloatBuffer(0.0F, 0.0F, 1.0F, 0.0F)); GlStateManager.enableTexGenCoord(GlStateManager.TexGen.R);
GL11.glTexGen(GL11.GL_R, GL11.GL_OBJECT_PLANE, GlStateManager.enableTexGenCoord(GlStateManager.TexGen.Q);
this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GL11.glTexGen(GL11.GL_Q, GL11.GL_OBJECT_PLANE, GlStateManager.popMatrix();
this.getFloatBuffer(1.0F, 0.0F, 0.0F, -0.15F));
GlStateManager.matrixMode(GL11.GL_TEXTURE);
break; GlStateManager.pushMatrix();
case 7: GlStateManager.loadIdentity();
GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE, GlStateManager.translate(0.0F, Minecraft.getSystemTime() % 200000L / 200000.0F * var15, 0.0F);
this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F)); GlStateManager.scale(var16, var16, var16);
GL11.glTexGen(GL11.GL_T, GL11.GL_OBJECT_PLANE, GlStateManager.translate(0.5F, 0.5F, 0.5F);
this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F)); GlStateManager.rotate((count * count * 4321 + count * 9) * 2.0F, 0.0F, 0.0F, 1.0F);
GL11.glTexGen(GL11.GL_R, GL11.GL_OBJECT_PLANE, GlStateManager.translate(0.5F, 0.5F, 0.5F);
this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GL11.glTexGen(GL11.GL_Q, GL11.GL_OBJECT_PLANE, Tessellator tessellator = Tessellator.getInstance();
this.getFloatBuffer(0.0F, 0.0F, 1.0F, -0.15F)); WorldRenderer worldRenderer = tessellator.getWorldRenderer();
break; worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
}
GL11.glEnable(GL11.GL_TEXTURE_GEN_S);
GL11.glEnable(GL11.GL_TEXTURE_GEN_T);
GL11.glEnable(GL11.GL_TEXTURE_GEN_R);
GL11.glEnable(GL11.GL_TEXTURE_GEN_Q);
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPushMatrix();
GL11.glLoadIdentity();
GL11.glTranslatef(0.0F,
Minecraft.getSystemTime() % 200000L / 200000.0F
* var15, 0.0F);
GL11.glScalef(var16, var16, var16);
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
GL11.glRotatef((count * count * 4321 + count * 9) * 2.0F,
0.0F, 0.0F, 1.0F);
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
GL11.glBegin(GL11.GL_QUADS);
float[] color = tile.getRenderColor(rand); float[] color = tile.getRenderColor(rand);
GL11.glColor4f(color[0] * var17, color[1] * var17, color[2] * var17, color[3]); GlStateManager.color(color[0] * var17, color[1] * var17, color[2] * var17, color[3]);
switch (tile.orientation) switch (tile.orientation) {
{ case SOUTH:
case 0: worldRenderer.pos(x + .01F, y - 1, z).endVertex();
worldRenderer.pos(x + .01, y - 1, z + 1.0D).endVertex();
GL11.glVertex3d(x + .01F, y - 1, z); worldRenderer.pos(x + .01, y + 1, z + 1.0D).endVertex();
GL11.glVertex3d(x + .01, y - 1, z + 1.0D); worldRenderer.pos(x + .01, y + 1, z).endVertex();
GL11.glVertex3d(x + .01, y + 1, z + 1.0D);
GL11.glVertex3d(x + .01, y + 1, z);
break; break;
case 1: case WEST:
GL11.glVertex3d(x, y + 1, z + .01); worldRenderer.pos(x, y + 1, z + .01).endVertex();
GL11.glVertex3d(x + 1, y + 1, z + .01); worldRenderer.pos(x + 1, y + 1, z + .01).endVertex();
GL11.glVertex3d(x + 1, y -1, z + .01); worldRenderer.pos(x + 1, y -1, z + .01).endVertex();
GL11.glVertex3d(x, y -1, z + .01); worldRenderer.pos(x, y -1, z + .01).endVertex();
break; break;
case 2: case NORTH:
GL11.glVertex3d(x + .99, y + 1, z); worldRenderer.pos(x + .99, y + 1, z).endVertex();
GL11.glVertex3d(x + .99, y + 1, z + 1.0D); worldRenderer.pos(x + .99, y + 1, z + 1.0D).endVertex();
GL11.glVertex3d(x + .99, y - 1, z + 1.0D); worldRenderer.pos(x + .99, y - 1, z + 1.0D).endVertex();
GL11.glVertex3d(x + .99, y - 1, z); worldRenderer.pos(x + .99, y - 1, z).endVertex();
break; break;
case 3: case EAST:
GL11.glVertex3d(x, y -1, z + .99); worldRenderer.pos(x, y -1, z + .99).endVertex();
GL11.glVertex3d(x + 1, y -1, z + .99); worldRenderer.pos(x + 1, y -1, z + .99).endVertex();
GL11.glVertex3d(x + 1, y + 1, z + .99); worldRenderer.pos(x + 1, y + 1, z + .99).endVertex();
GL11.glVertex3d(x, y + 1, z + .99); worldRenderer.pos(x, y + 1, z + .99).endVertex();
break; break;
case 4: /*case 4:
GL11.glVertex3d(x + .15F, y - 1 , z); GL11.glVertex3d(x + .15F, y - 1 , z);
GL11.glVertex3d(x + .15, y - 1, z + 1.0D); GL11.glVertex3d(x + .15, y - 1, z + 1.0D);
GL11.glVertex3d(x + .15, y + 1, z + 1.0D); GL11.glVertex3d(x + .15, y + 1, z + 1.0D);
@ -225,130 +183,112 @@ public class RenderDimDoor extends TileEntitySpecialRenderer<TileEntityDimDoor>
GL11.glVertex3d(x + 1, y - 1, z + .85); GL11.glVertex3d(x + 1, y - 1, z + .85);
GL11.glVertex3d(x + 1, y + 1, z + .85); GL11.glVertex3d(x + 1, y + 1, z + .85);
GL11.glVertex3d(x, y + 1, z + .85); GL11.glVertex3d(x, y + 1, z + .85);
break; break;*/
} }
tessellator.draw();
GL11.glEnd(); GlStateManager.popMatrix();
GlStateManager.matrixMode(GL11.GL_MODELVIEW);
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
} }
GL11.glDisable(GL11.GL_BLEND); GlStateManager.disableBlend();
GL11.glDisable(GL11.GL_TEXTURE_GEN_S); GlStateManager.disableTexGenCoord(GlStateManager.TexGen.S);
GL11.glDisable(GL11.GL_TEXTURE_GEN_T); GlStateManager.disableTexGenCoord(GlStateManager.TexGen.T);
GL11.glDisable(GL11.GL_TEXTURE_GEN_R); GlStateManager.disableTexGenCoord(GlStateManager.TexGen.R);
GL11.glDisable(GL11.GL_TEXTURE_GEN_Q); GlStateManager.disableTexGenCoord(GlStateManager.TexGen.Q);
GL11.glEnable(GL11.GL_LIGHTING); GlStateManager.enableLighting();
} }
private FloatBuffer getFloatBuffer(float par1, float par2, float par3, float par4) private FloatBuffer getFloatBuffer(float par1, float par2, float par3, float par4) {
{
buffer.clear(); buffer.clear();
buffer.put(par1).put(par2).put(par3).put(par4); buffer.put(par1).put(par2).put(par3).put(par4);
buffer.flip(); buffer.flip();
return buffer; return buffer;
} }
private void renderKeyHole(TileEntityDimDoor tile, double x, private void renderKeyHole(TileEntityDimDoor tile, double x, double y, double z, int i) {
double y, double z, int i) EnumFacing rotation = EnumFacing.getHorizontal((tile.orientation.getHorizontalIndex()+3)%4);
{
if(tile.orientation>3)
{
return;
}
int rotation = (tile.orientation+3)%4;
GL11.glPushMatrix(); GlStateManager.pushMatrix();
GL11.glTranslated(x,y,z); GlStateManager.translate(x,y,z);
x= ActiveRenderInfo.objectX; x = ActiveRenderInfo.getPosition().xCoord;
y = ActiveRenderInfo.objectY; y = ActiveRenderInfo.getPosition().yCoord;
z = ActiveRenderInfo.objectZ; z = ActiveRenderInfo.getPosition().zCoord;
GL11.glRotatef(180.0F - 90*rotation, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(180.0F - 90*rotation.getHorizontalIndex(), 0.0F, 1.0F, 0.0F);
//GL11.glRotatef((float)(-90 * rotation), 0.0F, 0.0F, 1.0F); //GL11.glRotatef((float)(-90 * rotation), 0.0F, 0.0F, 1.0F);
GL11.glTranslatef(0.007F, .25F, 0F); GlStateManager.translate(0.007F, .25F, 0F);
switch (rotation) switch (rotation) {
{ case SOUTH:
case 0:
GL11.glTranslatef(-0.5F, 0, -0.03F); GL11.glTranslatef(-0.5F, 0, -0.03F);
break; break;
case 1: case WEST:
GL11.glTranslatef(-.5F, 0F, .97F); GL11.glTranslatef(-.5F, 0F, .97F);
break; break;
case 2: case NORTH:
GL11.glTranslatef(.5F, 0F, .97F); GL11.glTranslatef(.5F, 0F, .97F);
break; break;
case 3: case EAST:
GL11.glTranslatef(0.5F, 0F, -0.03F); GL11.glTranslatef(0.5F, 0F, -0.03F);
} }
GL11.glDisable(GL_LIGHTING); GL11.glDisable(GL_LIGHTING);
Tessellator tessellator = Tessellator.instance;
GL11.glEnable(GL11.GL_BLEND);
if(i==1)
{
bindTexture(KeyholeLight);
GL11.glColor4d(1, 1, 1, .7);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_DST_COLOR);
}
else
{
bindTexture(keyPath);
glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA);
} GL11.glEnable(GL11.GL_BLEND);
GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
GL11.glScalef(0.00860625F, 0.00730625F, 0.0086625F);
GL11.glTranslatef(-65.0F, -107.0F, -3.0F);
GL11.glNormal3f(0.0F, 0.0F, -1.0F);
tessellator.startDrawingQuads();
byte b0 = 7;
tessellator.addVertexWithUV((double)(0 - b0), (double)(128 + b0), 0.0D, 0.0D, 1.0D);
tessellator.addVertexWithUV((double)(128 + b0), (double)(128 + b0), 0.0D, 1.0D, 1.0D);
tessellator.addVertexWithUV((double)(128 + b0), (double)(0 - b0), 0.0D, 1.0D, 0.0D);
tessellator.addVertexWithUV((double)(0 - b0), (double)(0 - b0), 0.0D, 0.0D, 0.0D);
tessellator.draw();
GL11.glTranslatef(0.0F, 0.0F, -1.0F);
GL11.glDisable(GL11.GL_BLEND);
if(i==1) {
GL11.glPopMatrix(); bindTexture(KeyholeLight);
GlStateManager.color(1, 1, 1, .7f);
GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_DST_COLOR);
} else {
bindTexture(keyPath);
GlStateManager.blendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA);
}
GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.scale(0.00860625F, 0.00730625F, 0.0086625F);
GlStateManager.translate(-65.0F, -107.0F, -3.0F);
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldRenderer = tessellator.getWorldRenderer();
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
byte b0 = 7;
worldRenderer.pos((double)(0 - b0), (double)(128 + b0), 0.0D).tex(0.0D, 1.0D).normal(0.0F, 0.0F, -1.0F).endVertex();
worldRenderer.pos((double)(128 + b0), (double)(128 + b0), 0.0D).tex(1.0D, 1.0D).normal(0.0F, 0.0F, -1.0F).endVertex();
worldRenderer.pos((double)(128 + b0), (double)(0 - b0), 0.0D).tex(1.0D, 0.0D).normal(0.0F, 0.0F, -1.0F).endVertex();
worldRenderer.pos((double)(0 - b0), (double)(0 - b0), 0.0D).tex(0.0D, 0.0D).normal(0.0F, 0.0F, -1.0F).endVertex();
tessellator.draw();
GlStateManager.translate(0.0F, 0.0F, -1.0F);
GlStateManager.disableBlend();
GlStateManager.popMatrix();
} }
@Override @Override
public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8) public void renderTileEntityAt(TileEntityDimDoor te, double x, double y, double z, float partialTicks, int destroyStage) {
{ if (properties.DoorRenderingEnabled) {
if (properties.DoorRenderingEnabled) TileEntityDimDoor tile = te;
{
TileEntityDimDoor tile = (TileEntityDimDoor) par1TileEntity; try {
try DimDoors.dimensionalDoor.updateAttachedTile(tile.getWorld(), tile.getPos());
{ } catch (Exception e) {
DimDoors.dimensionalDoor.updateAttachedTile(tile.getWorldObj(),
tile.xCoord, tile.yCoord, tile.zCoord);
}
catch (Exception e)
{
e.printStackTrace(); e.printStackTrace();
} }
if (tile.openOrClosed) if (tile.openOrClosed) {
{ renderDimDoorTileEntity((TileEntityDimDoor) te, x, y, z);
if(tile.lockStatus>=1) {
renderDimDoorTileEntity((TileEntityDimDoor) par1TileEntity, par2, par4, par6); for(int i = 0; i<1+tile.lockStatus; i++ ) {
if(tile.lockStatus>=1) this.renderKeyHole(tile, x, y, z, i);
{
for(int i = 0; i<1+tile.lockStatus; i++ )
{
this.renderKeyHole(tile, par2, par4, par6, i);
} }
} }

View file

@ -3,6 +3,7 @@ package com.zixiken.dimdoors.client;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.ticking.MobMonolith; import com.zixiken.dimdoors.ticking.MobMonolith;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderManager;
@ -12,12 +13,11 @@ import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.RenderLivingEvent; import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12; import org.lwjgl.opengl.GL12;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class RenderMobObelisk extends RenderLiving<MobMonolith> public class RenderMobObelisk extends RenderLiving<MobMonolith>
{ {
@ -25,15 +25,15 @@ public class RenderMobObelisk extends RenderLiving<MobMonolith>
public RenderMobObelisk(RenderManager manager) { public RenderMobObelisk(RenderManager manager) {
super(manager, new ModelMobObelisk(), 0.5F); super(manager, new ModelMobObelisk(), 0.5F);
this.obeliskModel = (ModelMobObelisk)this.mainModel; this.obeliskModel = (ModelMobObelisk) this.mainModel;
} }
@Override @Override
public void doRender(EntityLiving entity, double x, double y, double z, float par8, float par9) public void doRender(MobMonolith entity, double x, double y, double z, float par8, float par9)
{ {
final float minScaling = 0; final float minScaling = 0;
final float maxScaling = 0.1f; final float maxScaling = 0.1f;
MobMonolith monolith = ((MobMonolith) entity); MobMonolith monolith = (MobMonolith) entity;
float aggroScaling = 0; float aggroScaling = 0;
if (monolith.isDangerous()) { if (monolith.isDangerous()) {
@ -50,80 +50,74 @@ public class RenderMobObelisk extends RenderLiving<MobMonolith>
// Render with jitter // Render with jitter
this.render(entity, x + xJitter, y + yJitter, z + zJitter, par8, par9); this.render(entity, x + xJitter, y + yJitter, z + zJitter, par8, par9);
this.func_110827_b(entity, x, y, z, par8, par9); this.renderLeash(entity, x, y, z, par8, par9);
} }
public void render(EntityLiving par1EntityLivingBase, double x, double y, double z, float par8, float par9) public void render(MobMonolith entity, double x, double y, double z, float par8, float par9) {
{ if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre(entity, this, x, y, z))) return;
if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre(par1EntityLivingBase, this, x, y, z))) return; GlStateManager.pushMatrix();
GL11.glPushMatrix(); GlStateManager.disableCull();
GL11.glDisable(GL11.GL_CULL_FACE); GlStateManager.disableLighting();
GL11.glDisable(GL11.GL_LIGHTING); GlStateManager.disableBlend();
GL11.glEnable(GL11.GL_BLEND); GlStateManager.blendFunc(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);
try try {
{ float interpolatedYaw = interpolateRotation(entity.prevRenderYawOffset, entity.renderYawOffset, par9);
float interpolatedYaw = interpolateRotation(par1EntityLivingBase.prevRenderYawOffset, par1EntityLivingBase.renderYawOffset, par9); float interpolatedYawHead = interpolateRotation(entity.prevRotationYawHead, entity.rotationYawHead, par9);
float interpolatedYawHead = interpolateRotation(par1EntityLivingBase.prevRotationYawHead, par1EntityLivingBase.rotationYawHead, par9);
float rotation; float rotation;
float pitch = par1EntityLivingBase.prevRotationPitch + (par1EntityLivingBase.rotationPitch - par1EntityLivingBase.prevRotationPitch) * par9; float pitch = entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * par9;
this.renderLivingAt(par1EntityLivingBase, x, y, z); this.renderLivingAt(entity, x, y, z);
rotation = this.handleRotationFloat(par1EntityLivingBase, par9); rotation = this.handleRotationFloat(entity, par9);
this.rotateCorpse(par1EntityLivingBase, rotation, interpolatedYaw, par9); this.rotateCorpse(entity, rotation, interpolatedYaw, par9);
float f6 = 0.0625F; float f6 = 0.0625F;
GL11.glEnable(GL12.GL_RESCALE_NORMAL); GlStateManager.enableRescaleNormal();
GL11.glScalef(-1.0F, -1.0F, 1.0F); GlStateManager.scale(-1.0F, -1.0F, 1.0F);
this.preRenderCallback(par1EntityLivingBase, par9); this.preRenderCallback(entity, par9);
GL11.glRotatef(((MobMonolith)par1EntityLivingBase).pitchLevel , 1.0F, 0.0F, 0.0F); GlStateManager.rotate(((MobMonolith) entity).pitchLevel, 1.0F, 0.0F, 0.0F);
GL11.glTranslatef(0.0F, 24.0F * f6 - 0.0078125F, 0.0F); GlStateManager.translate(0.0F, 24.0F * f6 - 0.0078125F, 0.0F);
this.renderModel(par1EntityLivingBase, 0, 0, rotation, interpolatedYaw, pitch, f6); this.renderModel(entity, 0, 0, rotation, interpolatedYaw, pitch, f6);
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
GL11.glDisable(GL11.GL_TEXTURE_2D); GlStateManager.disableTexture2D();;
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
GL11.glDisable(GL12.GL_RESCALE_NORMAL); GlStateManager.disableRescaleNormal();
} } catch (Exception exception) {
catch (Exception exception)
{
exception.printStackTrace(); exception.printStackTrace();
} }
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
GL11.glEnable(GL11.GL_TEXTURE_2D); GlStateManager.enableTexture2D();
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
GL11.glEnable(GL11.GL_CULL_FACE); GlStateManager.enableCull();
GL11.glEnable(GL11.GL_LIGHTING); GlStateManager.enableLighting();
GL11.glDisable(GL11.GL_BLEND); GlStateManager.disableBlend();
GL11.glPopMatrix(); GlStateManager.popMatrix();
MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Post(par1EntityLivingBase, this, x, y, z));
MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Post(entity, this, x, y, z));
} }
private static float interpolateRotation(float par1, float par2, float par3) public float interpolateRotation(float par1, float par2, float par3) {
{
float f3 = par2 - par1; float f3 = par2 - par1;
while (f3 < -180.0f) while (f3 < -180.0f) {
{
f3 += 360.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(MobMonolith entity) {
{
MobMonolith monolith = (MobMonolith) entity; MobMonolith monolith = (MobMonolith) entity;
return new ResourceLocation(DimDoors.modid + ":textures/mobs/oldMonolith/Monolith" + monolith.getTextureState() + ".png"); return new ResourceLocation(DimDoors.MODID + ":textures/mobs/oldMonolith/Monolith" + monolith.getTextureState() + ".png");
} }
} }

View file

@ -3,28 +3,26 @@ package com.zixiken.dimdoors.client;
import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL11.*;
import com.zixiken.dimdoors.tileentities.TileEntityRift; import com.zixiken.dimdoors.tileentities.TileEntityRift;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class RenderRift extends TileEntitySpecialRenderer public class RenderRift extends TileEntitySpecialRenderer {
{
@Override @Override
public void renderTileEntityAt(TileEntity te, double xWorld, double yWorld, double zWorld, float f) public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTicks, int destroyStage) {
{
// prepare fb for drawing // prepare fb for drawing
GL11.glPushMatrix(); GL11.glPushMatrix();
// make the rift render on both sides, disable texture mapping and // make the rift render on both sides, disable texture mapping and
// lighting // lighting
GL11.glDisable(GL11.GL_CULL_FACE); GlStateManager.disableCull();
GL11.glDisable(GL_TEXTURE_2D); GlStateManager.disableTexture2D();
GL11.glDisable(GL_LIGHTING); GlStateManager.disableLighting();
GL11.glEnable(GL_BLEND); GlStateManager.enableBlend();
/** /**
* GL11.glLogicOp(GL11.GL_INVERT); * GL11.glLogicOp(GL11.GL_INVERT);
* GL11.glEnable(GL11.GL_COLOR_LOGIC_OP); * GL11.glEnable(GL11.GL_COLOR_LOGIC_OP);
@ -32,12 +30,12 @@ public class RenderRift extends TileEntitySpecialRenderer
TileEntityRift rift = (TileEntityRift) te; TileEntityRift rift = (TileEntityRift) te;
// draws the verticies corresponding to the passed it // draws the verticies corresponding to the passed it
GL11.glDisable(GL_BLEND);
// reenable all the stuff we disabled // reenable all the stuff we disabled
GL11.glEnable(GL11.GL_CULL_FACE); GlStateManager.disableBlend();
GL11.glEnable(GL11.GL_LIGHTING); GlStateManager.enableCull();
GL11.glEnable(GL_TEXTURE_2D); GlStateManager.enableLighting();
GlStateManager.enableTexture2D();
GL11.glPopMatrix(); GlStateManager.popMatrix();
} }
} }

View file

@ -8,168 +8,158 @@ import com.zixiken.dimdoors.blocks.TransTrapdoor;
import com.zixiken.dimdoors.config.DDProperties; import com.zixiken.dimdoors.config.DDProperties;
import com.zixiken.dimdoors.tileentities.TileEntityTransTrapdoor; import com.zixiken.dimdoors.tileentities.TileEntityTransTrapdoor;
import net.minecraft.block.BlockTrapDoor; import net.minecraft.block.BlockTrapDoor;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GLAllocation; import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class RenderTransTrapdoor extends TileEntitySpecialRenderer<TileEntityTransTrapdoor> { public class RenderTransTrapdoor extends TileEntitySpecialRenderer<TileEntityTransTrapdoor> {
private FloatBuffer field_76908_a = GLAllocation.createDirectFloatBuffer(16); private FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16);
private static DDProperties properties = null; private static DDProperties properties = null;
private ResourceLocation riftPath= new ResourceLocation(DimDoors.modid+":textures/other/RIFT.png"); private ResourceLocation riftPath= new ResourceLocation(DimDoors.MODID+":textures/other/RIFT.png");
private ResourceLocation warpPath= new ResourceLocation(DimDoors.modid+":textures/other/WARP.png"); private ResourceLocation warpPath= new ResourceLocation(DimDoors.MODID+":textures/other/WARP.png");
public RenderTransTrapdoor() public RenderTransTrapdoor() {
{
if (properties == null) if (properties == null)
properties = DDProperties.instance(); properties = DDProperties.instance();
} }
/** /**
* Renders the dimdoor. * Renders the dimdoor.
*/ */
public void renderTransTrapdoorTileEntity(TileEntityTransTrapdoor tile, double x, double y, double z, float par8) public void renderTransTrapdoorTileEntity(TileEntityTransTrapdoor tile, double x, double y, double z, float partialTicks) {
{ GlStateManager.disableLighting();
GL11.glDisable(GL11.GL_LIGHTING);
Random random = new Random(31100L); Random random = new Random(31100L);
int metadata = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord); IBlockState state = tile.getWorld().getBlockState(tile.getPos());
for (int count = 0; count < 16; ++count) for (int count = 0; count < 16; ++count) {
{ GlStateManager.pushMatrix();
GL11.glPushMatrix();
float var15 = 16 - count; float var15 = 16 - count;
float var16 = 0.2625F; float var16 = 0.2625F;
float var17 = 1.0F / (var15 + 1.0F); float var17 = 1.0F / (var15 + 1.0F);
if (count == 0) if (count == 0) {
{
this.bindTexture(riftPath); this.bindTexture(riftPath);
var17 = 0.1F; var17 = 0.1F;
var15 = 25.0F; var15 = 25.0F;
var16 = 0.125F; var16 = 0.125F;
GL11.glEnable(GL11.GL_BLEND); GlStateManager.enableBlend();
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
} }
if (count == 1) if (count == 1) {
{
this.bindTexture(warpPath); this.bindTexture(warpPath);
GL11.glEnable(GL11.GL_BLEND); GlStateManager.enableBlend();
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); GlStateManager.blendFunc(GL11.GL_ONE, GL11.GL_ONE);
var16 = .5F; var16 = .5F;
} }
GL11.glTranslatef( Minecraft.getSystemTime() % 200000L / 200000.0F,0, 0.0F); GlStateManager.translate(Minecraft.getSystemTime() % 200000L / 200000.0F,0, 0.0F);
GL11.glTranslatef(0, Minecraft.getSystemTime() % 200000L / 200000.0F, 0.0F); GlStateManager.translate(0, Minecraft.getSystemTime() % 200000L / 200000.0F, 0.0F);
GL11.glTranslatef(0,0, Minecraft.getSystemTime() % 200000L / 200000.0F); GlStateManager.translate(0,0, Minecraft.getSystemTime() % 200000L / 200000.0F);
GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_LINEAR);
GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_LINEAR);
GL11.glTexGeni(GL11.GL_R, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_LINEAR);
GL11.glTexGeni(GL11.GL_Q, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR); GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_EYE_LINEAR);
GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F)); GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F));
GL11.glTexGen(GL11.GL_T, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 1.0F, 0.0F)); GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 1.0F, 0.0F));
GL11.glTexGen(GL11.GL_R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F)); GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GL11.glTexGen(GL11.GL_Q, GL11.GL_EYE_PLANE, this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F)); GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_EYE_PLANE, this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.S);
GL11.glEnable(GL11.GL_TEXTURE_GEN_S); GlStateManager.enableTexGenCoord(GlStateManager.TexGen.T);
GL11.glEnable(GL11.GL_TEXTURE_GEN_T); GlStateManager.enableTexGenCoord(GlStateManager.TexGen.R);
GL11.glEnable(GL11.GL_TEXTURE_GEN_R); GlStateManager.enableTexGenCoord(GlStateManager.TexGen.Q);
GL11.glEnable(GL11.GL_TEXTURE_GEN_Q);
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPushMatrix();
GL11.glLoadIdentity();
GL11.glTranslatef(0.0F, Minecraft.getSystemTime() % 200000L / 200000.0F*var15, 0.0F);
GL11.glScalef(var16, var16, var16);
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
GL11.glRotatef((count * count * 4321 + count * 9) * 2.0F, 0.0F, 0.0F, 1.0F);
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
GL11.glBegin(GL11.GL_QUADS);
float var21 = random.nextFloat() * 0.5F + 0.1F;
float var22 = random.nextFloat() * 0.4F + 0.4F;
float var23 = random.nextFloat() * 0.6F + 0.5F;
if (count == 0) GlStateManager.popMatrix();
{
var23 = 1.0F; GlStateManager.matrixMode(GL11.GL_TEXTURE);
var22 = 1.0F; GlStateManager.pushMatrix();
GlStateManager.loadIdentity();
GlStateManager.translate(0.0F, Minecraft.getSystemTime() % 200000L / 200000.0F*var15, 0.0F);
GlStateManager.scale(var16, var16, var16);
GlStateManager.translate(0.5F, 0.5F, 0.5F);
GlStateManager.rotate((count * count * 4321 + count * 9) * 2.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.translate(0.5F, 0.5F, 0.5F);
float r = (random.nextFloat() * 0.5F + 0.1F) * var17;
float g = (random.nextFloat() * 0.4F + 0.4F) * var17;
float b = (random.nextFloat() * 0.6F + 0.5F) * var17;
if (count == 0) {
g = 1.0F;
b = 1.0F;
} }
GL11.glColor4d(var21 * var17, var22 * var17, var23 * var17, 1.0F);
if (TransTrapdoor.isTrapdoorSetLow(metadata)) Tessellator tessellator = Tessellator.getInstance();
{ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
if (BlockTrapDoor.func_150118_d(metadata)) worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
{
GL11.glVertex3d(x, y+0.2, z); if (TransTrapdoor.isTrapdoorSetLow(state)) {
GL11.glVertex3d(x, y+0.2, z+1); if (state.getValue(BlockTrapDoor.OPEN)) {
GL11.glVertex3d(x+1 , y+0.2 , z+1); worldrenderer.pos(x, y+0.2, z).color(r, g, b, 1.0F).endVertex();
GL11.glVertex3d(x+1 , y+0.2 , z); worldrenderer.pos(x, y+0.2, z+1).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x+1, y+0.2, z+1).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x+1, y+0.2, z).color(r, g, b, 1.0F).endVertex();
} else {
worldrenderer.pos(x, y+0.15, z).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x, y+0.15, z+1).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x+1, y+0.15, z+1).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x+1, y+0.15, z).color(r, g, b, 1.0F).endVertex();
} }
else } else {
{ if (state.getValue(BlockTrapDoor.OPEN)) {
GL11.glVertex3d(x, y+0.15, z); worldrenderer.pos(x, y+0.95, z).color(r, g, b, 1.0F).endVertex();
GL11.glVertex3d(x, y+0.15, z+1); worldrenderer.pos(x, y+0.95, z+1).color(r, g, b, 1.0F).endVertex();
GL11.glVertex3d(x+1 , y+0.15 , z+1); worldrenderer.pos(x+1, y+0.95, z+1).color(r, g, b, 1.0F).endVertex();
GL11.glVertex3d(x+1 , y+0.15 , z); worldrenderer.pos(x+1, y+0.95, z).color(r, g, b, 1.0F).endVertex();
} else {
worldrenderer.pos(x, y+0.85, z).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x, y+0.85, z+1).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x+1, y+0.85, z+1).color(r, g, b, 1.0F).endVertex();
worldrenderer.pos(x+1, y+0.85, z).color(r, g, b, 1.0F).endVertex();
} }
} }
else
{ tessellator.draw();
if (BlockTrapDoor.func_150118_d(metadata)) GlStateManager.popMatrix();
{ GlStateManager.matrixMode(GL11.GL_MODELVIEW);
GL11.glVertex3d(x, y+0.95, z);
GL11.glVertex3d(x, y+0.95, z+1);
GL11.glVertex3d(x+1 , y+0.95 , z+1);
GL11.glVertex3d(x+1 , y+0.95 , z);
}
else
{
GL11.glVertex3d(x, y+0.85, z);
GL11.glVertex3d(x, y+0.85, z+1);
GL11.glVertex3d(x+1 , y+0.85 , z+1);
GL11.glVertex3d(x+1 , y+0.85 , z);
}
}
GL11.glEnd();
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
} }
GL11.glDisable(GL11.GL_BLEND); GlStateManager.disableBlend();
GL11.glDisable(GL11.GL_TEXTURE_GEN_S); GlStateManager.disableTexGenCoord(GlStateManager.TexGen.S);
GL11.glDisable(GL11.GL_TEXTURE_GEN_T); GlStateManager.disableTexGenCoord(GlStateManager.TexGen.T);
GL11.glDisable(GL11.GL_TEXTURE_GEN_R); GlStateManager.disableTexGenCoord(GlStateManager.TexGen.R);
GL11.glDisable(GL11.GL_TEXTURE_GEN_Q); GlStateManager.disableTexGenCoord(GlStateManager.TexGen.Q);
GL11.glEnable(GL11.GL_LIGHTING); GlStateManager.disableLighting();
} }
private FloatBuffer getFloatBuffer(float par1, float par2, float par3, float par4) private FloatBuffer getFloatBuffer(float par1, float par2, float par3, float par4) {
{ this.buffer.clear();
this.field_76908_a.clear(); this.buffer.put(par1).put(par2).put(par3).put(par4);
this.field_76908_a.put(par1).put(par2).put(par3).put(par4); this.buffer.flip();
this.field_76908_a.flip(); return this.buffer;
return this.field_76908_a;
} }
@Override @Override
public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8) public void renderTileEntityAt(TileEntityTransTrapdoor te, double x, double y, double z, float partialTicks, int destroyStage) {
{ if (properties.DoorRenderingEnabled) {
if (properties.DoorRenderingEnabled) this.renderTransTrapdoorTileEntity(te, x, y, z, partialTicks);
{
this.renderTransTrapdoorTileEntity((TileEntityTransTrapdoor)par1TileEntity, par2, par4, par6, par8);
} }
} }
} }

View file

@ -4,69 +4,41 @@ import com.zixiken.dimdoors.core.PocketManager;
import net.minecraft.client.particle.EffectRenderer; import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.particle.EntityFX; import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World; import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class RiftFX extends EntityFX public class RiftFX extends EntityFX {
{ private int baseTextureIndex = 160;
private int field_92049_a = 160; private boolean trail;
private boolean field_92054_ax; private boolean twinkle;
private boolean field_92048_ay; private final EffectRenderer effectRenderer;
private final EffectRenderer field_92047_az; private float fadeColourRed;
private float field_92050_aA; private float fadeColourGreen;
private float field_92051_aB; private float fadeColourBlue;
private float field_92052_aC; private boolean hasFadeColour;
private boolean field_92053_aD;
public RiftFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, EffectRenderer par14EffectRenderer) public RiftFX(World world, double x, double y, double z, double motionX, double motionY, double motionZ, EffectRenderer effectRenderer) {
{ super(world, x, y, z);
this.motionX = motionX;
super(par1World, par2, par4, par6); this.motionY = motionY;
this.motionX = par8; this.motionZ = motionZ;
this.motionY = par10; this.effectRenderer = effectRenderer;
this.motionZ = par12;
this.field_92047_az = par14EffectRenderer;
this.particleScale *= 0.75F; this.particleScale *= 0.75F;
this.particleMaxAge = 40 + this.rand.nextInt(26); this.particleMaxAge = 40 + this.rand.nextInt(26);
this.noClip = true; this.noClip = true;
} }
public void func_92045_e(boolean par1)
{
this.field_92054_ax = par1;
}
public void func_92043_f(boolean par1)
{
this.field_92048_ay = par1;
}
public void func_92044_a(int par1)
{
float var2 = ((par1 & 16711680) >> 16) / 255.0F;
float var3 = ((par1 & 65280) >> 8) / 255.0F;
float var4 = ((par1 & 255) >> 0) / 255.0F;
float var5 = 1.0F;
this.setRBGColorF(var2 * var5, var3 * var5, var4 * var5);
}
public void func_92046_g(int par1)
{
this.field_92050_aA = ((par1 & 16711680) >> 16) / 255.0F;
this.field_92051_aB = ((par1 & 65280) >> 8) / 255.0F;
this.field_92052_aC = ((par1 & 255) >> 0) / 255.0F;
this.field_92053_aD = true;
}
/** /**
* returns the bounding box for this entity * returns the bounding box for this entity
*/ */
@Override @Override
public AxisAlignedBB getBoundingBox() public AxisAlignedBB getCollisionBoundingBox() {
{
return null; return null;
} }
@ -80,17 +52,13 @@ public class RiftFX extends EntityFX
} }
@Override @Override
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) public void renderParticle(WorldRenderer worldRenderer, Entity entity, float par2, float par3, float par4, float par5, float par6, float par7) {
{ if (!this.twinkle || this.particleAge < this.particleMaxAge / 3 || (this.particleAge + this.particleMaxAge) / 3 % 2 == 0) {
if (!this.field_92048_ay || this.particleAge < this.particleMaxAge / 3 || (this.particleAge + this.particleMaxAge) / 3 % 2 == 0) this.doRenderParticle(worldRenderer, par2, par3, par4, par5, par6, par7);
{
this.doRenderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7);
} }
} }
public void doRenderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) public void doRenderParticle(WorldRenderer worldRenderer, float par2, float par3, float par4, float par5, float par6, float par7)
{ {
float f6 = this.particleTextureIndexX / 16.0F; float f6 = this.particleTextureIndexX / 16.0F;
float f7 = f6 + 0.0624375F; float f7 = f6 + 0.0624375F;
@ -98,8 +66,7 @@ public class RiftFX extends EntityFX
float f9 = f8 + 0.0624375F; float f9 = f8 + 0.0624375F;
float f10 = 0.1F * this.particleScale; float f10 = 0.1F * this.particleScale;
if (this.particleIcon != null) if (this.particleIcon != null) {
{
f6 = this.particleIcon.getMinU(); f6 = this.particleIcon.getMinU();
f7 = this.particleIcon.getMaxU(); f7 = this.particleIcon.getMaxU();
f8 = this.particleIcon.getMinV(); f8 = this.particleIcon.getMinV();
@ -111,80 +78,70 @@ public class RiftFX extends EntityFX
float f13 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * par2 - interpPosZ); float f13 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * par2 - interpPosZ);
float f14 = 0F; float f14 = 0F;
if (PocketManager.createDimensionData(worldObj).isPocketDimension()) if (PocketManager.createDimensionData(worldObj).isPocketDimension()) {
{
f14 = 0.7F; f14 = 0.7F;
} }
par1Tessellator.setColorRGBA_F(this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, (float) .7); worldRenderer.pos(f11 - par3 * f10 - par6 * f10, f12 - par4 * f10, f13 - par5 * f10 - par7 * f10).tex(f7, f9).color(this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, (float) .7).endVertex();
par1Tessellator.addVertexWithUV(f11 - par3 * f10 - par6 * f10, f12 - par4 * f10, f13 - par5 * f10 - par7 * f10, f7, f9); worldRenderer.pos(f11 - par3 * f10 + par6 * f10, f12 + par4 * f10, f13 - par5 * f10 + par7 * f10).tex(f7, f8).color(this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, (float) .7).endVertex();
par1Tessellator.addVertexWithUV(f11 - par3 * f10 + par6 * f10, f12 + par4 * f10, f13 - par5 * f10 + par7 * f10, f7, f8); worldRenderer.pos(f11 + par3 * f10 + par6 * f10, f12 + par4 * f10, f13 + par5 * f10 + par7 * f10).tex(f6, f8).color(this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, (float) .7).endVertex();
par1Tessellator.addVertexWithUV(f11 + par3 * f10 + par6 * f10, f12 + par4 * f10, f13 + par5 * f10 + par7 * f10, f6, f8); worldRenderer.pos(f11 + par3 * f10 - par6 * f10, f12 - par4 * f10, f13 + par5 * f10 - par7 * f10).tex(f6, f9).color(this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, (float) .7).endVertex();
par1Tessellator.addVertexWithUV(f11 + par3 * f10 - par6 * f10, f12 - par4 * f10, f13 + par5 * f10 - par7 * f10, f6, f9);
} }
/** /**
* Called to update the entity's position/logic. * Called to update the entity's position/logic.
*/ */
@Override @Override
public void onUpdate() public void onUpdate() {
{
this.prevPosX = this.posX; this.prevPosX = this.posX;
this.prevPosY = this.posY; this.prevPosY = this.posY;
this.prevPosZ = this.posZ; this.prevPosZ = this.posZ;
if (this.particleAge++ >= this.particleMaxAge) if (this.particleAge++ >= this.particleMaxAge) {
{
this.setDead(); this.setDead();
} }
if (this.particleAge > this.particleMaxAge / 2) if (this.particleAge > this.particleMaxAge / 2) {
{
this.setAlphaF(1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / this.particleMaxAge); this.setAlphaF(1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / this.particleMaxAge);
if (this.field_92053_aD) if (this.hasFadeColour) {
{ this.particleRed += (this.fadeColourRed - this.particleRed) * 0.2F;
this.particleRed += (this.field_92050_aA - this.particleRed) * 0.2F; this.particleGreen += (this.fadeColourGreen - this.particleGreen) * 0.2F;
this.particleGreen += (this.field_92051_aB - this.particleGreen) * 0.2F; this.particleBlue += (this.fadeColourBlue - this.particleBlue) * 0.2F;
this.particleBlue += (this.field_92052_aC - this.particleBlue) * 0.2F;
} }
} }
this.setParticleTextureIndex(this.field_92049_a + (7 - this.particleAge * 8 / this.particleMaxAge)); this.setParticleTextureIndex(this.baseTextureIndex + (7 - this.particleAge * 8 / this.particleMaxAge));
// this.motionY -= 0.004D; // this.motionY -= 0.004D;
this.moveEntity(this.motionX, this.motionY, this.motionZ); this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.9100000262260437D; this.motionX *= 0.9100000262260437D;
this.motionY *= 0.9100000262260437D; this.motionY *= 0.9100000262260437D;
this.motionZ *= 0.9100000262260437D; this.motionZ *= 0.9100000262260437D;
if (this.onGround) if (this.onGround) {
{
this.motionX *= 0.699999988079071D; this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D; this.motionZ *= 0.699999988079071D;
} }
if (this.field_92054_ax && this.particleAge < this.particleMaxAge / 2 && (this.particleAge + this.particleMaxAge) % 2 == 0) if (this.trail && this.particleAge < this.particleMaxAge / 2 && (this.particleAge + this.particleMaxAge) % 2 == 0) {
{ RiftFX rift = new RiftFX(this.worldObj, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, this.effectRenderer);
RiftFX var1 = new RiftFX(this.worldObj, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, this.field_92047_az); rift.setRBGColorF(this.particleRed, this.particleGreen, this.particleBlue);
var1.setRBGColorF(this.particleRed, this.particleGreen, this.particleBlue); rift.particleAge = rift.particleMaxAge / 2;
var1.particleAge = var1.particleMaxAge / 2;
if (this.field_92053_aD) if (this.hasFadeColour) {
{ rift.hasFadeColour = true;
var1.field_92053_aD = true; rift.fadeColourRed = this.fadeColourRed;
var1.field_92050_aA = this.field_92050_aA; rift.fadeColourGreen = this.fadeColourGreen;
var1.field_92051_aB = this.field_92051_aB; rift.fadeColourBlue = this.fadeColourBlue;
var1.field_92052_aC = this.field_92052_aC;
} }
var1.field_92048_ay = this.field_92048_ay; rift.twinkle = this.twinkle;
this.field_92047_az.addEffect(var1); this.effectRenderer.addEffect(rift);
} }
} }
@Override @Override
public int getBrightnessForRender(float par1) public int getBrightnessForRender(float par1) {
{
return 15728880; return 15728880;
} }
@ -192,8 +149,7 @@ public class RiftFX extends EntityFX
* Gets how bright this entity is. * Gets how bright this entity is.
*/ */
@Override @Override
public float getBrightness(float par1) public float getBrightness(float par1) {
{
return 1.0F; return 1.0F;
} }
} }

View file

@ -1,24 +1,19 @@
package com.zixiken.dimdoors.client; package com.zixiken.dimdoors.client;
public class TESyncHandler public class TESyncHandler {
{ public void onServerChanges() {
public void onServerChanges()
{
} }
public void onClientChanges() public void onClientChanges() {
{
} }
public void onClientData() public void onClientData() {
{
} }
public void onServerData() public void onServerData() {
{
} }

View file

@ -2,6 +2,7 @@ package com.zixiken.dimdoors.commands;
import com.zixiken.dimdoors.helpers.DungeonHelper; import com.zixiken.dimdoors.helpers.DungeonHelper;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
public class CommandCreatePocket extends DDCommandBase { public class CommandCreatePocket extends DDCommandBase {
private static CommandCreatePocket instance = null; private static CommandCreatePocket instance = null;
@ -25,10 +26,9 @@ public class CommandCreatePocket extends DDCommandBase {
//Place a door leading to a pocket dimension where the player is standing. //Place a door leading to a pocket dimension where the player is standing.
//The pocket dimension will serve as a room for the player to build a dungeon. //The pocket dimension will serve as a room for the player to build a dungeon.
int x = (int) sender.posX; BlockPos pos = new BlockPos((int) sender.posX, (int) sender.posY, (int) sender.posZ);
int y = (int) sender.posY;
int z = (int) sender.posZ; DungeonHelper.instance().createCustomDungeonDoor(sender.worldObj, pos);
DungeonHelper.instance().createCustomDungeonDoor(sender.worldObj, x, y, z);
//Notify the player //Notify the player
sendChat(sender, "Created a door to a pocket dimension. Please build your dungeon there."); sendChat(sender, "Created a door to a pocket dimension. Please build your dungeon there.");

View file

@ -3,6 +3,7 @@ package com.zixiken.dimdoors.core;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Random; import java.util.Random;
import com.zixiken.dimdoors.helpers.EnumFacingHelper;
import com.zixiken.dimdoors.world.LimboProvider; import com.zixiken.dimdoors.world.LimboProvider;
import com.zixiken.dimdoors.blocks.BaseDimDoor; import com.zixiken.dimdoors.blocks.BaseDimDoor;
import com.zixiken.dimdoors.blocks.IDimDoor; import com.zixiken.dimdoors.blocks.IDimDoor;
@ -13,8 +14,6 @@ import com.zixiken.dimdoors.schematic.BlockRotator;
import com.zixiken.dimdoors.tileentities.TileEntityDimDoor; import com.zixiken.dimdoors.tileentities.TileEntityDimDoor;
import com.zixiken.dimdoors.util.Point4D; import com.zixiken.dimdoors.util.Point4D;
import com.zixiken.dimdoors.world.PocketBuilder; import com.zixiken.dimdoors.world.PocketBuilder;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor; import net.minecraft.block.BlockDoor;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@ -38,7 +37,7 @@ import net.minecraft.world.World;
import net.minecraft.world.WorldServer; import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
import com.zixiken.dimdoors.watcher.ClientDimData; import com.zixiken.dimdoors.watcher.ClientDimData;
import cpw.mods.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.FMLCommonHandler;
public class DDTeleporter { public class DDTeleporter {
private static final Random random = new Random(); private static final Random random = new Random();
@ -103,41 +102,34 @@ public class DDTeleporter {
return true; return true;
} }
private static void placeInPortal(Entity entity, WorldServer world, Point4D destination, DDProperties properties, boolean checkOrientation) private static void placeInPortal(Entity entity, WorldServer world, Point4D destination, DDProperties properties, boolean checkOrientation) {
{
int x = destination.getX(); int x = destination.getX();
int y = destination.getY(); int y = destination.getY();
int z = destination.getZ(); int z = destination.getZ();
EnumFacing orientation; EnumFacing orientation;
if (checkOrientation) if (checkOrientation) {
{
orientation = getDestinationOrientation(destination, properties); orientation = getDestinationOrientation(destination, properties);
entity.rotationYaw = (orientation.getIndex() * 90) + 90; entity.rotationYaw = (orientation.getIndex() * 90) + 90;
} } else {
else
{
// Teleport the entity to the precise destination point // Teleport the entity to the precise destination point
orientation = EnumFacing.SOUTH; orientation = EnumFacing.SOUTH;
} }
if (entity instanceof EntityPlayer) if (entity instanceof EntityPlayer) {
{
EntityPlayer player = (EntityPlayer) entity; EntityPlayer player = (EntityPlayer) entity;
if (checkDestination(world, destination, orientation)) if (checkDestination(world, destination, orientation)) {
{ switch (orientation) {
switch (orientation) case SOUTH:
{
case 0:
player.setPositionAndUpdate(x - 0.5, y - 1, z + 0.5); player.setPositionAndUpdate(x - 0.5, y - 1, z + 0.5);
break; break;
case 1: case WEST:
player.setPositionAndUpdate(x + 0.5, y - 1, z - 0.5); player.setPositionAndUpdate(x + 0.5, y - 1, z - 0.5);
break; break;
case 2: case NORTH:
player.setPositionAndUpdate(x + 1.5, y - 1, z + 0.5); player.setPositionAndUpdate(x + 1.5, y - 1, z + 0.5);
break; break;
case 3: case EAST:
player.setPositionAndUpdate(x + 0.5, y - 1, z + 1.5); player.setPositionAndUpdate(x + 0.5, y - 1, z + 1.5);
break; break;
default: default:
@ -148,30 +140,27 @@ public class DDTeleporter {
else { else {
player.setPositionAndUpdate(x + 0.5, y - 1, z + 0.5); player.setPositionAndUpdate(x + 0.5, y - 1, z + 0.5);
} }
} } else if (entity instanceof EntityMinecart) {
else if (entity instanceof EntityMinecart)
{
entity.motionX = 0; entity.motionX = 0;
entity.motionZ = 0; entity.motionZ = 0;
entity.motionY = 0; entity.motionY = 0;
switch (orientation) switch (orientation) {
{ case SOUTH:
case 0:
DDTeleporter.setEntityPosition(entity, x - 0.5, y, z + 0.5); DDTeleporter.setEntityPosition(entity, x - 0.5, y, z + 0.5);
entity.motionX = -0.39; entity.motionX = -0.39;
entity.worldObj.updateEntityWithOptionalForce(entity, false); entity.worldObj.updateEntityWithOptionalForce(entity, false);
break; break;
case 1: case WEST:
DDTeleporter.setEntityPosition(entity, x + 0.5, y, z - 0.5); DDTeleporter.setEntityPosition(entity, x + 0.5, y, z - 0.5);
entity.motionZ = -0.39; entity.motionZ = -0.39;
entity.worldObj.updateEntityWithOptionalForce(entity, false); entity.worldObj.updateEntityWithOptionalForce(entity, false);
break; break;
case 2: case NORTH:
DDTeleporter.setEntityPosition(entity, x + 1.5, y, z + 0.5); DDTeleporter.setEntityPosition(entity, x + 1.5, y, z + 0.5);
entity.motionX = 0.39; entity.motionX = 0.39;
entity.worldObj.updateEntityWithOptionalForce(entity, false); entity.worldObj.updateEntityWithOptionalForce(entity, false);
break; break;
case 3: case EAST:
DDTeleporter.setEntityPosition(entity, x + 0.5, y, z + 1.5); DDTeleporter.setEntityPosition(entity, x + 0.5, y, z + 1.5);
entity.motionZ = 0.39; entity.motionZ = 0.39;
entity.worldObj.updateEntityWithOptionalForce(entity, false); entity.worldObj.updateEntityWithOptionalForce(entity, false);
@ -181,21 +170,18 @@ public class DDTeleporter {
entity.worldObj.updateEntityWithOptionalForce(entity, false); entity.worldObj.updateEntityWithOptionalForce(entity, false);
break; break;
} }
} } else {
else switch (orientation) {
{ case SOUTH:
switch (orientation)
{
case 0:
setEntityPosition(entity, x - 0.5, y, z + 0.5); setEntityPosition(entity, x - 0.5, y, z + 0.5);
break; break;
case 1: case WEST:
setEntityPosition(entity, x + 0.5, y, z - 0.5); setEntityPosition(entity, x + 0.5, y, z - 0.5);
break; break;
case 2: case NORTH:
setEntityPosition(entity, x + 1.5, y, z + 0.5); setEntityPosition(entity, x + 1.5, y, z + 0.5);
break; break;
case 3: case EAST:
setEntityPosition(entity, x + 0.5, y, z + 1.5); setEntityPosition(entity, x + 0.5, y, z + 1.5);
break; break;
default: default:
@ -205,10 +191,9 @@ public class DDTeleporter {
} }
} }
private static void setEntityPosition(Entity entity, double x, double y, double z) private static void setEntityPosition(Entity entity, double x, double y, double z) {
{
entity.lastTickPosX = entity.prevPosX = entity.posX = x; entity.lastTickPosX = entity.prevPosX = entity.posX = x;
entity.lastTickPosY = entity.prevPosY = entity.posY = y + entity.yOffset; entity.lastTickPosY = entity.prevPosY = entity.posY = y + entity.getYOffset();
entity.lastTickPosZ = entity.prevPosZ = entity.posZ = z; entity.lastTickPosZ = entity.prevPosZ = entity.posZ = z;
entity.setPosition(x, y, z); entity.setPosition(x, y, z);
} }
@ -232,12 +217,9 @@ public class DDTeleporter {
} }
public static Entity teleportEntity(Entity entity, Point4D destination, boolean checkOrientation) { public static Entity teleportEntity(Entity entity, Point4D destination, boolean checkOrientation) {
if (entity == null) if (entity == null) {
{
throw new IllegalArgumentException("entity cannot be null."); throw new IllegalArgumentException("entity cannot be null.");
} } if (destination == null) {
if (destination == null)
{
throw new IllegalArgumentException("destination cannot be null."); throw new IllegalArgumentException("destination cannot be null.");
} }
//This beautiful teleport method is based off of xCompWiz's teleport function. //This beautiful teleport method is based off of xCompWiz's teleport function.
@ -248,15 +230,13 @@ public class DDTeleporter {
DDProperties properties = DDProperties.instance(); DDProperties properties = DDProperties.instance();
// Is something riding? Handle it first. // Is something riding? Handle it first.
if (entity.riddenByEntity != null) if (entity.riddenByEntity != null) {
{
return teleportEntity(entity.riddenByEntity, destination, checkOrientation); return teleportEntity(entity.riddenByEntity, destination, checkOrientation);
} }
// Are we riding something? Dismount and tell the mount to go first. // Are we riding something? Dismount and tell the mount to go first.
Entity cart = entity.ridingEntity; Entity cart = entity.ridingEntity;
if (cart != null) if (cart != null) {
{
entity.mountEntity(null); entity.mountEntity(null);
cart = teleportEntity(cart, destination, checkOrientation); cart = teleportEntity(cart, destination, checkOrientation);
// We keep track of both so we can remount them on the other side. // We keep track of both so we can remount them on the other side.
@ -264,13 +244,10 @@ public class DDTeleporter {
// Determine if our destination is in another realm. // Determine if our destination is in another realm.
boolean difDest = entity.dimension != destination.getDimension(); boolean difDest = entity.dimension != destination.getDimension();
if (difDest) if (difDest) {
{
// Destination isn't loaded? Then we need to load it. // Destination isn't loaded? Then we need to load it.
newWorld = PocketManager.loadDimension(destination.getDimension()); newWorld = PocketManager.loadDimension(destination.getDimension());
} } else {
else
{
newWorld = oldWorld; newWorld = oldWorld;
} }
@ -279,10 +256,8 @@ public class DDTeleporter {
// TODO Check to see if this is actually vital. // TODO Check to see if this is actually vital.
DDTeleporter.placeInPortal(entity, newWorld, destination, properties, checkOrientation); DDTeleporter.placeInPortal(entity, newWorld, destination, properties, checkOrientation);
if (difDest) // Are we moving our target to a new dimension? if (difDest) // Are we moving our target to a new dimension?{
{ if(player != null) // Are we working with a player?{
if(player != null) // Are we working with a player?
{
// We need to do all this special stuff to move a player between dimensions. // We need to do all this special stuff to move a player between dimensions.
//Give the client the dimensionData for the destination //Give the client the dimensionData for the destination
@ -294,7 +269,7 @@ public class DDTeleporter {
// Set the new dimension and inform the client that it's moving to a new world. // Set the new dimension and inform the client that it's moving to a new world.
player.dimension = destination.getDimension(); player.dimension = destination.getDimension();
player.playerNetServerHandler.sendPacket(new S07PacketRespawn(player.dimension, player.worldObj.difficultySetting, newWorld.getWorldInfo().getTerrainType(), player.theItemInWorldManager.getGameType())); player.playerNetServerHandler.sendPacket(new S07PacketRespawn(player.dimension, player.worldObj.getDifficulty(), newWorld.getWorldInfo().getTerrainType(), player.theItemInWorldManager.getGameType()));
// GreyMaria: Used the safe player entity remover before. // GreyMaria: Used the safe player entity remover before.
// This should fix an apparently unreported bug where // This should fix an apparently unreported bug where
@ -321,33 +296,32 @@ public class DDTeleporter {
} }
player.playerNetServerHandler.sendPacket(new S1FPacketSetExperience(player.experience, player.experienceTotal, player.experienceLevel)); player.playerNetServerHandler.sendPacket(new S1FPacketSetExperience(player.experience, player.experienceTotal, player.experienceLevel));
}
// Creates sanity by removing the entity from its old location's chunk entity list, if applicable. // Creates sanity by removing the entity from its old location's chunk entity list, if applicable.
int entX = entity.chunkCoordX; int entX = entity.chunkCoordX;
int entZ = entity.chunkCoordZ; int entZ = entity.chunkCoordZ;
if ((entity.addedToChunk) && (oldWorld.getChunkProvider().chunkExists(entX, entZ))) if ((entity.addedToChunk) && (oldWorld.getChunkProvider().chunkExists(entX, entZ))) {
{
oldWorld.getChunkFromChunkCoords(entX, entZ).removeEntity(entity); oldWorld.getChunkFromChunkCoords(entX, entZ).removeEntity(entity);
oldWorld.getChunkFromChunkCoords(entX, entZ).isModified = true; oldWorld.getChunkFromChunkCoords(entX, entZ).setModified(true);
} }
// Memory concerns. // Memory concerns.
oldWorld.onEntityRemoved(entity); oldWorld.onEntityRemoved(entity);
if (player == null) // Are we NOT working with a player? if (player == null) { // Are we NOT working with a player?
{
NBTTagCompound entityNBT = new NBTTagCompound(); NBTTagCompound entityNBT = new NBTTagCompound();
entity.isDead = false; entity.isDead = false;
entity.writeMountToNBT(entityNBT); entity.writeMountToNBT(entityNBT);
if(entityNBT.hasNoTags())
{ if(entityNBT.hasNoTags()) {
return entity; return entity;
} }
entity.isDead = true; entity.isDead = true;
entity = EntityList.createEntityFromNBT(entityNBT, newWorld); entity = EntityList.createEntityFromNBT(entityNBT, newWorld);
if (entity == null) if (entity == null) {
{
// TODO FIXME IMPLEMENT NULL CHECKS THAT ACTUALLY DO SOMETHING. // TODO FIXME IMPLEMENT NULL CHECKS THAT ACTUALLY DO SOMETHING.
/* /*
* shit ourselves in an organized fashion, preferably * shit ourselves in an organized fashion, preferably
@ -360,27 +334,25 @@ public class DDTeleporter {
// Finally, respawn the entity in its new home. // Finally, respawn the entity in its new home.
newWorld.spawnEntityInWorld(entity); newWorld.spawnEntityInWorld(entity);
entity.setWorld(newWorld); entity.setWorld(newWorld);
}
entity.worldObj.updateEntityWithOptionalForce(entity, false); entity.worldObj.updateEntityWithOptionalForce(entity, false);
// Hey, remember me? It's time to remount. // Hey, remember me? It's time to remount.
if (cart != null) if (cart != null) {
{
// Was there a player teleported? If there was, it's important that we update shit. // Was there a player teleported? If there was, it's important that we update shit.
if (player != null) if (player != null) {
{
entity.worldObj.updateEntityWithOptionalForce(entity, true); entity.worldObj.updateEntityWithOptionalForce(entity, true);
} }
entity.mountEntity(cart); entity.mountEntity(cart);
} }
// Did we teleport a player? Load the chunk for them. // Did we teleport a player? Load the chunk for them.
if (player != null) if (player != null) {
{ newWorld.getChunkProvider().provideChunk(MathHelper.floor_double(entity.posX) >> 4, MathHelper.floor_double(entity.posZ) >> 4);
newWorld.getChunkProvider().loadChunk(MathHelper.floor_double(entity.posX) >> 4, MathHelper.floor_double(entity.posZ) >> 4);
// Tell Forge we're moving its players so everyone else knows. // Tell Forge we're moving its players so everyone else knows.
// Let's try doing this down here in case this is what's killing NEI. // Let's try doing this down here in case this is what's killing NEI.
FMLCommonHandler.instance().firePlayerChangedDimensionEvent((EntityPlayer) entity, oldWorld.provider.dimensionId, newWorld.provider.dimensionId); FMLCommonHandler.instance().firePlayerChangedDimensionEvent((EntityPlayer) entity, oldWorld.provider.getDimensionId(), newWorld.provider.getDimensionId());
} }
DDTeleporter.placeInPortal(entity, newWorld, destination, properties, checkOrientation); DDTeleporter.placeInPortal(entity, newWorld, destination, properties, checkOrientation);
@ -401,45 +373,33 @@ public class DDTeleporter {
if(link == null) throw new IllegalArgumentException("link cannot be null."); if(link == null) throw new IllegalArgumentException("link cannot be null.");
if(entity == null) throw new IllegalArgumentException("entity cannot be null."); if(entity == null) throw new IllegalArgumentException("entity cannot be null.");
if (cooldown == 0 || entity instanceof EntityPlayer) if (cooldown == 0 || entity instanceof EntityPlayer) {
{
// According to Steven, we increase the cooldown by a random amount so that if someone // According to Steven, we increase the cooldown by a random amount so that if someone
// makes a loop with doors and throws items in them, the slamming sounds won't all // makes a loop with doors and throws items in them, the slamming sounds won't all
// sync up and be very loud. The cooldown itself prevents server-crashing madness. // sync up and be very loud. The cooldown itself prevents server-crashing madness.
cooldown = 2 + random.nextInt(2); cooldown = 2 + random.nextInt(2);
} } else {
else
{
return; return;
} }
if (!initializeDestination(link, DDProperties.instance(),entity,door)) if (!initializeDestination(link, DDProperties.instance(),entity,door)) {
{
return; return;
} } if (link.linkType() == LinkType.RANDOM) {
if (link.linkType() == LinkType.RANDOM)
{
Point4D randomDestination = getRandomDestination(); Point4D randomDestination = getRandomDestination();
if (randomDestination != null) if (randomDestination != null) {
{
entity = teleportEntity(entity, randomDestination, true); entity = teleportEntity(entity, randomDestination, true);
entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F); entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
} }
} } else {
else
{
buildExitDoor(door, link, DDProperties.instance()); buildExitDoor(door, link, DDProperties.instance());
entity = teleportEntity(entity, link.destination(), link.linkType() != LinkType.UNSAFE_EXIT); entity = teleportEntity(entity, link.destination(), link.linkType() != LinkType.UNSAFE_EXIT);
entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F); entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
} }
} }
private static boolean initializeDestination(DimLink link, DDProperties properties, Entity entity, Block door) private static boolean initializeDestination(DimLink link, DDProperties properties, Entity entity, Block door) {
{ if (link.hasDestination()&&link.linkType()!=LinkType.PERSONAL) {
if (link.hasDestination()&&link.linkType()!=LinkType.PERSONAL) if (PocketManager.isBlackListed(link.destination().getDimension())) {
{
if (PocketManager.isBlackListed(link.destination().getDimension()))
{
// This link leads to a dimension that has been blacklisted. // This link leads to a dimension that has been blacklisted.
// That means that it was a pocket and it was deleted. // That means that it was a pocket and it was deleted.
@ -447,35 +407,26 @@ public class DDTeleporter {
// the teleport operation. We don't need to assign 'link' with // the teleport operation. We don't need to assign 'link' with
// a different value. DimData will overwrite it in-place. // a different value. DimData will overwrite it in-place.
DimData start = PocketManager.getDimensionData(link.source().getDimension()); DimData start = PocketManager.getDimensionData(link.source().getDimension());
if (link.linkType() == LinkType.DUNGEON) if (link.linkType() == LinkType.DUNGEON) {
{
// Ovewrite the link into a dungeon link with no destination // Ovewrite the link into a dungeon link with no destination
start.createLink(link.source(), LinkType.DUNGEON, link.orientation(), null); start.createLink(link.source(), LinkType.DUNGEON, link.orientation(), null);
} } else {
else if (start.isPocketDimension()) {
{
if (start.isPocketDimension())
{
// Ovewrite the link into a safe exit link, because // Ovewrite the link into a safe exit link, because
// this could be the only way out from a pocket. // this could be the only way out from a pocket.
start.createLink(link.source(), LinkType.SAFE_EXIT, link.orientation(), null); start.createLink(link.source(), LinkType.SAFE_EXIT, link.orientation(), null);
} } else {
else
{
// Cancel the teleport attempt // Cancel the teleport attempt
return false; return false;
} }
} }
} } else {
else
{
return true; return true;
} }
} }
// Check the destination type and respond accordingly // Check the destination type and respond accordingly
switch (link.linkType()) switch (link.linkType()) {
{
case DUNGEON: case DUNGEON:
return PocketBuilder.generateNewDungeonPocket(link, properties); return PocketBuilder.generateNewDungeonPocket(link, properties);
case POCKET: case POCKET:
@ -489,8 +440,7 @@ public class DDTeleporter {
case UNSAFE_EXIT: case UNSAFE_EXIT:
return generateUnsafeExit(link); return generateUnsafeExit(link);
case LIMBO: case LIMBO:
if(!(entity instanceof EntityPlayer)) if(!(entity instanceof EntityPlayer)) {
{
return false; return false;
} }
@ -506,32 +456,27 @@ public class DDTeleporter {
} }
} }
private static boolean setupPersonalLink(DimLink link, DDProperties properties,Entity entity, Block door) private static boolean setupPersonalLink(DimLink link, DDProperties properties,Entity entity, Block door) {
{ if(!(entity instanceof EntityPlayer)) {
if(!(entity instanceof EntityPlayer))
{
return false; return false;
} }
EntityPlayer player = (EntityPlayer)entity; EntityPlayer player = (EntityPlayer)entity;
DimData dim = PocketManager.getPersonalDimensionForPlayer(player.getGameProfile().getId().toString()); DimData dim = PocketManager.getPersonalDimensionForPlayer(player.getGameProfile().getId().toString());
if(dim == null) if(dim == null) {
{
return PocketBuilder.generateNewPersonalPocket(link, properties, player, door); return PocketBuilder.generateNewPersonalPocket(link, properties, player, door);
} }
DimLink personalHomeLink = dim.getLink(dim.origin()); DimLink personalHomeLink = dim.getLink(dim.origin());
if(personalHomeLink!=null) if(personalHomeLink!=null) {
{
link.tail.setDestination(personalHomeLink.source()); link.tail.setDestination(personalHomeLink.source());
PocketManager.getDimensionData(link.source().getDimension()).setLinkDestination(personalHomeLink, link.source().getX(), link.source().getY(), link.source().getZ()); PocketManager.getDimensionData(link.source().getDimension()).setLinkDestination(personalHomeLink, link.source().toBlockPos());
} }
return true; return true;
} }
private static Point4D getRandomDestination() private static Point4D getRandomDestination() {
{
// Our aim is to return a random link's source point // Our aim is to return a random link's source point
// so that a link of type RANDOM can teleport a player there. // so that a link of type RANDOM can teleport a player there.
@ -543,27 +488,22 @@ public class DDTeleporter {
// Don't just pick a random root and a random link within that root // Don't just pick a random root and a random link within that root
// because we want to have unbiased selection among all links. // because we want to have unbiased selection among all links.
ArrayList<Point4D> matches = new ArrayList<Point4D>(); ArrayList<Point4D> matches = new ArrayList<Point4D>();
for (DimData dimension : PocketManager.getRootDimensions()) for (DimData dimension : PocketManager.getRootDimensions()) {
{ for (DimLink link : dimension.getAllLinks()) {
for (DimLink link : dimension.getAllLinks()) if (link.linkType() != LinkType.RANDOM) {
{
if (link.linkType() != LinkType.RANDOM)
{
matches.add(link.source()); matches.add(link.source());
} }
} }
} }
// Pick a random point, if any is available // Pick a random point, if any is available
if (!matches.isEmpty()) if (!matches.isEmpty()) {
{
return matches.get( random.nextInt(matches.size()) ); return matches.get( random.nextInt(matches.size()) );
} }
return null; return null;
} }
private static boolean generateUnsafeExit(DimLink link) private static boolean generateUnsafeExit(DimLink link) {
{
// An unsafe exit teleports the user to the first available air space // An unsafe exit teleports the user to the first available air space
// in the pocket's root dimension. X and Z are kept roughly the same // in the pocket's root dimension. X and Z are kept roughly the same
// as the source location, but Y is set by searching down. We don't // as the source location, but Y is set by searching down. We don't
@ -575,68 +515,58 @@ public class DDTeleporter {
DimData current = PocketManager.getDimensionData(link.point.getDimension()); DimData current = PocketManager.getDimensionData(link.point.getDimension());
if (current.isPocketDimension()) if (current.isPocketDimension()) {
{
Point4D source = link.source(); Point4D source = link.source();
World world = PocketManager.loadDimension(current.root().id()); World world = PocketManager.loadDimension(current.root().id());
if (world == null) if (world == null) {
{
return false; return false;
} }
BlockPos destination = yCoordHelper.findDropPoint(world, source.getX(), source.getY() + 1, source.getZ()); BlockPos destination = yCoordHelper.findDropPoint(world, source.getX(), source.getY() + 1, source.getZ());
if (destination != null) if (destination != null) {
{ current.root().setLinkDestination(link, destination);
current.root().setLinkDestination(link, destination.getX(), destination.getY(), destination.getZ());
return true; return true;
} }
} }
return false; return false;
} }
private static void buildExitDoor(Block door,DimLink link, DDProperties prop) private static void buildExitDoor(Block door,DimLink link, DDProperties prop) {
{
World startWorld = PocketManager.loadDimension(link.source().getDimension()); World startWorld = PocketManager.loadDimension(link.source().getDimension());
World destWorld = PocketManager.loadDimension(link.destination().getDimension()); World destWorld = PocketManager.loadDimension(link.destination().getDimension());
TileEntity doorTE = startWorld.getTileEntity(link.source().getX(), link.source().getY(), link.point.getZ()); TileEntity doorTE = startWorld.getTileEntity(link.source().toBlockPos());
if(doorTE instanceof TileEntityDimDoor) if(doorTE instanceof TileEntityDimDoor) {
{ if((TileEntityDimDoor.class.cast(doorTE).hasGennedPair)) {
if((TileEntityDimDoor.class.cast(doorTE).hasGennedPair))
{
return; return;
} }
TileEntityDimDoor.class.cast(doorTE).hasGennedPair=true; TileEntityDimDoor.class.cast(doorTE).hasGennedPair=true;
Block blockToReplace = destWorld.getBlock(link.destination().getX(), link.destination().getY(), link.destination().getZ()); Block blockToReplace = destWorld.getBlockState(link.destination().toBlockPos()).getBlock();
if(!destWorld.isAirBlock(link.destination().getX(), link.destination().getY(), link.destination().getZ())) if(!destWorld.isAirBlock(link.destination().toBlockPos())) {
{ if(!blockToReplace.isReplaceable(destWorld, link.destination().toBlockPos())) {
if(!blockToReplace.isReplaceable(destWorld, link.destination().getX(), link.destination().getY(), link.destination().getZ()))
{
return; return;
} }
} }
ItemDoor.placeDoorBlock(destWorld, link.destination().getX(), link.destination().getY()-1, link.destination().getZ(),link.getDestinationOrientation(), door); ItemDoor.placeDoor(destWorld, link.destination().toBlockPos().down(), link.getDestinationOrientation(), door);
TileEntity doorDestTE = ((BaseDimDoor)door).initDoorTE(destWorld, link.destination().getX(), link.destination().getY(), link.destination().getZ()); TileEntity doorDestTE = ((BaseDimDoor)door).initDoorTE(destWorld, link.destination().toBlockPos());
if(doorDestTE instanceof TileEntityDimDoor) if(doorDestTE instanceof TileEntityDimDoor) {
{
TileEntityDimDoor.class.cast(doorDestTE).hasGennedPair=true; TileEntityDimDoor.class.cast(doorDestTE).hasGennedPair=true;
} }
} }
} }
private static boolean generateSafeExit(DimLink link, DDProperties properties) private static boolean generateSafeExit(DimLink link, DDProperties properties) {
{
DimData current = PocketManager.getDimensionData(link.point.getDimension()); DimData current = PocketManager.getDimensionData(link.point.getDimension());
return generateSafeExit(current.root(), link, properties); return generateSafeExit(current.root(), link, properties);
} }
private static boolean generateDungeonExit(DimLink link, DDProperties properties) private static boolean generateDungeonExit(DimLink link, DDProperties properties) {
{
// A dungeon exit acts the same as a safe exit, but has the chance of // A dungeon exit acts the same as a safe exit, but has the chance of
// taking the user to any non-pocket dimension, excluding Limbo and The End. // taking the user to any non-pocket dimension, excluding Limbo and The End.
// There is a chance of choosing the Nether first before other root dimensions // There is a chance of choosing the Nether first before other root dimensions
@ -647,21 +577,16 @@ public class DDTeleporter {
ArrayList<DimData> roots = PocketManager.getRootDimensions(); ArrayList<DimData> roots = PocketManager.getRootDimensions();
int shiftChance = START_ROOT_SHIFT_CHANCE + ROOT_SHIFT_CHANCE_PER_LEVEL * (current.packDepth() - 1); int shiftChance = START_ROOT_SHIFT_CHANCE + ROOT_SHIFT_CHANCE_PER_LEVEL * (current.packDepth() - 1);
if (random.nextInt(MAX_ROOT_SHIFT_CHANCE) < shiftChance) if (random.nextInt(MAX_ROOT_SHIFT_CHANCE) < shiftChance) {
{ if (current.root().id() != OVERWORLD_DIMENSION_ID && random.nextInt(MAX_OVERWORLD_EXIT_CHANCE) < OVERWORLD_EXIT_CHANCE) {
if (current.root().id() != OVERWORLD_DIMENSION_ID && random.nextInt(MAX_OVERWORLD_EXIT_CHANCE) < OVERWORLD_EXIT_CHANCE)
{
return generateSafeExit(PocketManager.createDimensionDataDangerously(OVERWORLD_DIMENSION_ID), link, properties); return generateSafeExit(PocketManager.createDimensionDataDangerously(OVERWORLD_DIMENSION_ID), link, properties);
} } if (current.root().id() != NETHER_DIMENSION_ID && random.nextInt(MAX_NETHER_EXIT_CHANCE) < NETHER_EXIT_CHANCE) {
if (current.root().id() != NETHER_DIMENSION_ID && random.nextInt(MAX_NETHER_EXIT_CHANCE) < NETHER_EXIT_CHANCE)
{
return generateSafeExit(PocketManager.createDimensionDataDangerously(NETHER_DIMENSION_ID), link, properties); return generateSafeExit(PocketManager.createDimensionDataDangerously(NETHER_DIMENSION_ID), link, properties);
} }
for (int attempts = 0; attempts < 10; attempts++)
{ for (int attempts = 0; attempts < 10; attempts++) {
DimData selection = roots.get( random.nextInt(roots.size()) ); DimData selection = roots.get( random.nextInt(roots.size()) );
if (selection != current.root() && isValidForDungeonExit(selection, properties)) if (selection != current.root() && isValidForDungeonExit(selection, properties)) {
{
return generateSafeExit(selection, link, properties); return generateSafeExit(selection, link, properties);
} }
} }
@ -674,18 +599,17 @@ public class DDTeleporter {
private static boolean isValidForDungeonExit(DimData destination, DDProperties properties) private static boolean isValidForDungeonExit(DimData destination, DDProperties properties)
{ {
// Prevent exits to The End and Limbo // Prevent exits to The End and Limbo
if (destination.id() == END_DIMENSION_ID || destination.id() == properties.LimboDimensionID) if (destination.id() == END_DIMENSION_ID || destination.id() == properties.LimboDimensionID) {
{
return false; return false;
} }
// Prevent exits to Witchery's Spirit World; we need to load the dimension to retrieve its name. // Prevent exits to Witchery's Spirit World; we need to load the dimension to retrieve its name.
// This is okay because the dimension would have to be loaded subsequently by generateSafeExit(). // This is okay because the dimension would have to be loaded subsequently by generateSafeExit().
World world = PocketManager.loadDimension(destination.id()); World world = PocketManager.loadDimension(destination.id());
return (world != null && !SPIRIT_WORLD_NAME.equals(world.provider.getDimensionName())); return (world != null && !SPIRIT_WORLD_NAME.equals(world.provider.getDimensionName()));
} }
private static boolean generateSafeExit(DimData destinationDim, DimLink link, DDProperties properties) private static boolean generateSafeExit(DimData destinationDim, DimLink link, DDProperties properties) {
{
// A safe exit attempts to place a Warp Door in a dimension with // A safe exit attempts to place a Warp Door in a dimension with
// some precautions to protect the player. The X and Z coordinates // some precautions to protect the player. The X and Z coordinates
// are fixed to match the source (mostly - may be shifted a little), // are fixed to match the source (mostly - may be shifted a little),
@ -694,8 +618,7 @@ public class DDTeleporter {
Point4D source = link.source(); Point4D source = link.source();
World world = PocketManager.loadDimension(destinationDim.id()); World world = PocketManager.loadDimension(destinationDim.id());
if (world == null) if (world == null) {
{
return false; return false;
} }
@ -704,40 +627,28 @@ public class DDTeleporter {
BlockPos locationUp = yCoordHelper.findSafeCubeUp(world, source.getX(), startY, source.getZ()); BlockPos locationUp = yCoordHelper.findSafeCubeUp(world, source.getX(), startY, source.getZ());
BlockPos locationDown = yCoordHelper.findSafeCubeDown(world, source.getX(), startY, source.getZ()); BlockPos locationDown = yCoordHelper.findSafeCubeDown(world, source.getX(), startY, source.getZ());
if (locationUp == null) if (locationUp == null) {
{ destination = locationDown;
} else if (locationDown == null) {
destination = locationUp;
} else if (locationUp.getY() - startY <= startY - locationDown.getY()) {
destination = locationUp;
} else {
destination = locationDown; destination = locationDown;
} }
else if (locationDown == null)
{ if (destination != null) {
destination = locationUp;
}
else if (locationUp.getY() - startY <= startY - locationDown.getY())
{
destination = locationUp;
}
else
{
destination = locationDown;
}
if (destination != null)
{
// Set up a 3x3 platform at the destination // Set up a 3x3 platform at the destination
// Only place fabric of reality if the block is replaceable or air // Only place fabric of reality if the block is replaceable or air
// Don't cause block updates // Don't cause block updates
int x = destination.getX(); BlockPos pos = destination;
int y = destination.getY(); for (int dx = -1; dx <= 1; dx++) {
int z = destination.getZ(); for (int dz = -1; dz <= 1; dz++) {
for (int dx = -1; dx <= 1; dx++)
{
for (int dz = -1; dz <= 1; dz++)
{
// Checking if the block is not an opaque solid is equivalent // Checking if the block is not an opaque solid is equivalent
// checking for a replaceable block, because we only allow // checking for a replaceable block, because we only allow
// exits intersecting blocks on those two surfaces. // exits intersecting blocks on those two surfaces.
if (!world.isBlockNormalCubeDefault(x + dx, y, z + dz, false)) if (!world.isBlockNormalCube(pos.add(dx, 0, dz), false)) {
{ world.setBlockState(pos.add(dx, 0, dz), DimDoors.blockDimWall.getDefaultState());
world.setBlock(x + dx, y, z + dz, DimDoors.blockDimWall, 0, 2);
} }
} }
} }
@ -745,31 +656,28 @@ public class DDTeleporter {
// Clear out any blocks in the space above the platform layer // Clear out any blocks in the space above the platform layer
// This removes any potential threats like replaceable Poison Ivy from BoP // This removes any potential threats like replaceable Poison Ivy from BoP
// Remember to avoid block updates to keep gravel from collapsing // Remember to avoid block updates to keep gravel from collapsing
for (int dy = 1; dy <= 2; dy++) for (int dy = 1; dy <= 2; dy++) {
{ for (int dx = -1; dx <= 1; dx++) {
for (int dx = -1; dx <= 1; dx++) for (int dz = -1; dz <= 1; dz++) {
{ world.setBlockState(pos.add(dx, dy, dz), Blocks.air.getDefaultState());
for (int dz = -1; dz <= 1; dz++)
{
world.setBlock(x + dx, y + dy, z + dz, Blocks.air, 0, 2);
} }
} }
} }
// Create a reverse link for returning // Create a reverse link for returning
int orientation = getDestinationOrientation(source, properties); EnumFacing orientation = getDestinationOrientation(source, properties);
DimData sourceDim = PocketManager.getDimensionData(link.source().getDimension()); DimData sourceDim = PocketManager.getDimensionData(link.source().getDimension());
DimLink reverse = destinationDim.createLink(x, y + 2, z, LinkType.REVERSE,orientation); DimLink reverse = destinationDim.createLink(pos.up(2), LinkType.REVERSE,orientation);
sourceDim.setLinkDestination(reverse, source.getX(), source.getY(), source.getZ()); sourceDim.setLinkDestination(reverse, source.toBlockPos());
// Set up the warp door at the destination // Set up the warp door at the destination
orientation = BlockRotator.transformMetadata(orientation, 2, DimDoors.warpDoor); orientation = EnumFacingHelper.getFacingFromBlockState(BlockRotator.transform(DimDoors.warpDoor.getDefaultState(), 2));
ItemDoor.placeDoorBlock(world, x, y + 1, z, orientation, DimDoors.warpDoor); ItemDoor.placeDoor(world, pos.up(), orientation, DimDoors.warpDoor);
// Complete the link to the destination // Complete the link to the destination
// This comes last so the destination isn't set unless everything else works first // This comes last so the destination isn't set unless everything else works first
destinationDim.setLinkDestination(link, x, y + 2, z); destinationDim.setLinkDestination(link, pos.up(2));
} }
return (destination != null); return (destination != null);

View file

@ -1,50 +1,37 @@
package com.zixiken.dimdoors.schematic; package com.zixiken.dimdoors.schematic;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage; import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
public class ChunkBlockSetter implements IBlockSetter public class ChunkBlockSetter implements IBlockSetter {
{
private boolean ignoreAir; private boolean ignoreAir;
public ChunkBlockSetter(boolean ignoreAir) public ChunkBlockSetter(boolean ignoreAir) {
{
this.ignoreAir = ignoreAir; this.ignoreAir = ignoreAir;
} }
public void setBlock(World world, int x, int y, int z, Block block, int metadata) public void setBlock(World world, BlockPos pos, IBlockState state) {
{ if (state.getBlock().isAir(world, pos) && ignoreAir) {
if (block.isAir(world, x, y, z) && ignoreAir)
{
return; return;
} }
int cX = x >> 4; int cX = pos.getX() >> 4;
int cZ = z >> 4; int cZ = pos.getY() >> 4;
int cY = y >> 4;
Chunk chunk; Chunk chunk;
int localX = (x % 16) < 0 ? (x % 16) + 16 : (x % 16); int localX = (pos.getX() % 16) < 0 ? (pos.getX() % 16) + 16 : (pos.getX() % 16);
int localZ = (z % 16) < 0 ? (z % 16) + 16 : (z % 16); int localZ = (pos.getZ() % 16) < 0 ? (pos.getZ() % 16) + 16 : (pos.getZ() % 16);
ExtendedBlockStorage extBlockStorage;
try try {
{
chunk = world.getChunkFromChunkCoords(cX, cZ); chunk = world.getChunkFromChunkCoords(cX, cZ);
extBlockStorage = chunk.getBlockStorageArray()[cY]; chunk.setBlockState(new BlockPos(localX, pos.getY() & 15, localZ), state);
if (extBlockStorage == null)
{
extBlockStorage = new ExtendedBlockStorage(cY << 4, !world.provider.hasNoSky);
chunk.getBlockStorageArray()[cY] = extBlockStorage;
}
extBlockStorage.func_150818_a(localX, y & 15, localZ, block);
extBlockStorage.setExtBlockMetadata(localX, y & 15, localZ, metadata);
chunk.setChunkModified(); chunk.setChunkModified();
} } catch(Exception e) {
catch(Exception e)
{
e.printStackTrace(); e.printStackTrace();
} }
} }

View file

@ -9,9 +9,7 @@ import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.monster.IMob; import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.*;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import com.zixiken.dimdoors.config.DDProperties; import com.zixiken.dimdoors.config.DDProperties;
import com.zixiken.dimdoors.core.DDTeleporter; import com.zixiken.dimdoors.core.DDTeleporter;
@ -40,8 +38,7 @@ public class MobMonolith extends EntityFlying implements IMob
private static DDProperties properties = null; private static DDProperties properties = null;
public MobMonolith(World world) public MobMonolith(World world) {
{
super(world); super(world);
this.setSize(WIDTH, HEIGHT); this.setSize(WIDTH, HEIGHT);
this.noClip = true; this.noClip = true;
@ -51,88 +48,74 @@ public class MobMonolith extends EntityFlying implements IMob
} }
public boolean isDangerous() { public boolean isDangerous() {
return properties.MonolithTeleportationEnabled && (properties.LimboDimensionID != worldObj.provider.dimensionId || !properties.DangerousLimboMonolithsDisabled); return properties.MonolithTeleportationEnabled && (properties.LimboDimensionID != worldObj.provider.getDimensionId() || !properties.DangerousLimboMonolithsDisabled);
} }
@Override @Override
protected void damageEntity(DamageSource par1DamageSource, float par2) protected void damageEntity(DamageSource par1DamageSource, float par2) {
{
return; return;
} }
@Override @Override
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) {
{ if (par1DamageSource != DamageSource.inWall) {
if (par1DamageSource != DamageSource.inWall)
{
this.aggro = MAX_AGGRO; this.aggro = MAX_AGGRO;
} }
return false; return false;
} }
@Override @Override
public boolean canBreatheUnderwater() public boolean canBreatheUnderwater() {
{
return true; return true;
} }
@Override @Override
public AxisAlignedBB getBoundingBox() public AxisAlignedBB getCollisionBoundingBox() {
{
return null; return null;
} }
@Override @Override
public AxisAlignedBB getCollisionBox(Entity par1Entity) public AxisAlignedBB getCollisionBox(Entity par1Entity) {
{
return null; return null;
} }
@Override @Override
public boolean canDespawn() public boolean canDespawn() {
{
return false; return false;
} }
@Override @Override
protected void applyEntityAttributes() protected void applyEntityAttributes() {
{
super.applyEntityAttributes(); super.applyEntityAttributes();
this.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.maxHealth).setBaseValue(57005); this.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.maxHealth).setBaseValue(57005);
} }
@Override @Override
public boolean canBePushed() public boolean canBePushed() {
{
return false; return false;
} }
@Override @Override
public float getEyeHeight() public float getEyeHeight() {
{
return EYE_HEIGHT; return EYE_HEIGHT;
} }
@Override @Override
protected void entityInit() protected void entityInit() {
{
super.entityInit(); super.entityInit();
// Add a short for the aggro level // Add a short for the aggro level
this.dataWatcher.addObject(AGGRO_WATCHER_INDEX, Short.valueOf((short) 0)); this.dataWatcher.addObject(AGGRO_WATCHER_INDEX, Short.valueOf((short) 0));
} }
@Override @Override
public boolean isEntityAlive() public boolean isEntityAlive() {
{
return false; return false;
} }
@Override @Override
public void onEntityUpdate() public void onEntityUpdate() {
{
// Remove this Monolith if it's not in Limbo or in a pocket dimension // Remove this Monolith if it's not in Limbo or in a pocket dimension
if (!(this.worldObj.provider.dimensionId == properties.LimboDimensionID|| this.worldObj.provider instanceof PocketProvider)) if (!(this.worldObj.provider.getDimensionId() == properties.LimboDimensionID|| this.worldObj.provider instanceof PocketProvider)) {
{
this.setDead(); this.setDead();
super.onEntityUpdate(); super.onEntityUpdate();
return; return;
@ -146,11 +129,9 @@ public class MobMonolith extends EntityFlying implements IMob
this.updateAggroLevel(player, visibility); this.updateAggroLevel(player, visibility);
// Change orientation and face a player if one is in range // Change orientation and face a player if one is in range
if (player != null) if (player != null) {
{
this.facePlayer(player); this.facePlayer(player);
if (!this.worldObj.isRemote && isDangerous()) if (!this.worldObj.isRemote && isDangerous()) {
{
// Play sounds on the server side, if the player isn't in Limbo. // Play sounds on the server side, if the player isn't in Limbo.
// Limbo is excluded to avoid drowning out its background music. // Limbo is excluded to avoid drowning out its background music.
// Also, since it's a large open area with many Monoliths, some // Also, since it's a large open area with many Monoliths, some
@ -159,23 +140,19 @@ public class MobMonolith extends EntityFlying implements IMob
this.playSounds(player); this.playSounds(player);
} }
if (visibility) if (visibility) {
{
// Only spawn particles on the client side and outside Limbo // Only spawn particles on the client side and outside Limbo
if (this.worldObj.isRemote && isDangerous()) if (this.worldObj.isRemote && isDangerous()) {
{
this.spawnParticles(player); this.spawnParticles(player);
} }
// Teleport the target player if various conditions are met // Teleport the target player if various conditions are met
if (aggro >= MAX_AGGRO && !this.worldObj.isRemote && if (aggro >= MAX_AGGRO && !this.worldObj.isRemote &&
properties.MonolithTeleportationEnabled && !player.capabilities.isCreativeMode && properties.MonolithTeleportationEnabled && !player.capabilities.isCreativeMode && isDangerous()) {
isDangerous())
{
this.aggro = 0; this.aggro = 0;
Point4D destination = LimboProvider.getLimboSkySpawn(player, properties); Point4D destination = LimboProvider.getLimboSkySpawn(player, properties);
DDTeleporter.teleportEntity(player, destination, false); DDTeleporter.teleportEntity(player, destination, false);
player.worldObj.playSoundAtEntity(player, DimDoors.modid + ":crack", 13, 1); player.worldObj.playSoundAtEntity(player, DimDoors.MODID + ":crack", 13, 1);
} }
} }
} }
@ -185,28 +162,21 @@ public class MobMonolith extends EntityFlying implements IMob
{ {
// If we're working on the server side, adjust aggro level // If we're working on the server side, adjust aggro level
// If we're working on the client side, retrieve aggro level from dataWatcher // If we're working on the client side, retrieve aggro level from dataWatcher
if (!this.worldObj.isRemote) if (!this.worldObj.isRemote) {
{
// Server side... // Server side...
// Rapidly increase the aggro level if this Monolith can see the player // Rapidly increase the aggro level if this Monolith can see the player
if (visibility) if (visibility) {
{ if (this.worldObj.provider.getDimensionId() == properties.LimboDimensionID) {
if (this.worldObj.provider.dimensionId == properties.LimboDimensionID)
{
if (isDangerous()) if (isDangerous())
aggro++; aggro++;
else else
aggro += 36; aggro += 36;
} } else {
else
{
// Aggro increases faster outside of Limbo // Aggro increases faster outside of Limbo
aggro += 3; aggro += 3;
} }
} } else {
else if (isDangerous()) {
{
if (isDangerous()) {
if (aggro > aggroCap) { if (aggro > aggroCap) {
// Decrease aggro over time // Decrease aggro over time
aggro--; aggro--;
@ -221,16 +191,13 @@ public class MobMonolith extends EntityFlying implements IMob
int maxAggro = isDangerous()?MAX_AGGRO:180; int maxAggro = isDangerous()?MAX_AGGRO:180;
aggro = (short) MathHelper.clamp_int(aggro, 0, maxAggro); aggro = (short) MathHelper.clamp_int(aggro, 0, maxAggro);
this.dataWatcher.updateObject(AGGRO_WATCHER_INDEX, Short.valueOf(aggro)); this.dataWatcher.updateObject(AGGRO_WATCHER_INDEX, Short.valueOf(aggro));
} } else {
else
{
// Client side... // Client side...
aggro = this.dataWatcher.getWatchableObjectShort(AGGRO_WATCHER_INDEX); aggro = this.dataWatcher.getWatchableObjectShort(AGGRO_WATCHER_INDEX);
} }
} }
public int getTextureState() public int getTextureState() {
{
// Determine texture state from aggro progress // Determine texture state from aggro progress
return MathHelper.clamp_int(MAX_TEXTURE_STATE * aggro / MAX_AGGRO, 0, MAX_TEXTURE_STATE); return MathHelper.clamp_int(MAX_TEXTURE_STATE * aggro / MAX_AGGRO, 0, MAX_TEXTURE_STATE);
} }
@ -239,33 +206,27 @@ public class MobMonolith extends EntityFlying implements IMob
* Plays sounds at different levels of aggro, using soundTime to prevent too many sounds at once. * Plays sounds at different levels of aggro, using soundTime to prevent too many sounds at once.
* @param entityPlayer * @param entityPlayer
*/ */
private void playSounds(EntityPlayer entityPlayer) private void playSounds(EntityPlayer entityPlayer) {
{
float aggroPercent = this.getAggroProgress(); float aggroPercent = this.getAggroProgress();
if (this.soundTime <= 0) if (this.soundTime <= 0)
{ {
this.playSound(DimDoors.modid + ":monk", 1F, 1F); this.playSound(DimDoors.MODID + ":monk", 1F, 1F);
this.soundTime = 100; this.soundTime = 100;
} } if ((aggroPercent > 0.70) && this.soundTime < 100) {
if ((aggroPercent > 0.70) && this.soundTime < 100) this.worldObj.playSoundEffect(entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, DimDoors.MODID + ":tearing", 1F, (float) (1 + this.rand.nextGaussian()));
{
this.worldObj.playSoundEffect(entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, DimDoors.modid + ":tearing", 1F, (float) (1 + this.rand.nextGaussian()));
this.soundTime = 100 + this.rand.nextInt(75); this.soundTime = 100 + this.rand.nextInt(75);
} } if ((aggroPercent > 0.80) && this.soundTime < 200) {
if ((aggroPercent > 0.80) && this.soundTime < 200) this.worldObj.playSoundEffect(entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, DimDoors.MODID + ":tearing", 7, 1F);
{
this.worldObj.playSoundEffect(entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, DimDoors.modid + ":tearing", 7, 1F);
this.soundTime = 250; this.soundTime = 250;
} }
this.soundTime--; this.soundTime--;
} }
private void spawnParticles(EntityPlayer player) private void spawnParticles(EntityPlayer player) {
{
int count = 10 * aggro / MAX_AGGRO; int count = 10 * aggro / MAX_AGGRO;
for (int i = 1; i < count; ++i)
{ for (int i = 1; i < count; ++i) {
player.worldObj.spawnParticle("portal", player.posX + (this.rand.nextDouble() - 0.5D) * this.width, player.worldObj.spawnParticle(EnumParticleTypes.PORTAL, player.posX + (this.rand.nextDouble() - 0.5D) * this.width,
player.posY + this.rand.nextDouble() * player.height - 0.75D, player.posY + this.rand.nextDouble() * player.height - 0.75D,
player.posZ + (this.rand.nextDouble() - 0.5D) * player.width, player.posZ + (this.rand.nextDouble() - 0.5D) * player.width,
(this.rand.nextDouble() - 0.5D) * 2.0D, -this.rand.nextDouble(), (this.rand.nextDouble() - 0.5D) * 2.0D, -this.rand.nextDouble(),
@ -273,13 +234,11 @@ public class MobMonolith extends EntityFlying implements IMob
} }
} }
public float getAggroProgress() public float getAggroProgress() {
{
return ((float) aggro) / MAX_AGGRO; return ((float) aggro) / MAX_AGGRO;
} }
private void facePlayer(EntityPlayer player) private void facePlayer(EntityPlayer player) {
{
double d0 = player.posX - this.posX; double d0 = player.posX - this.posX;
double d1 = player.posZ - this.posZ; double d1 = player.posZ - this.posZ;
double d2 = (player.posY + player.getEyeHeight()) - (this.posY + this.getEyeHeight()); double d2 = (player.posY + player.getEyeHeight()) - (this.posY + this.getEyeHeight());
@ -292,15 +251,13 @@ public class MobMonolith extends EntityFlying implements IMob
} }
@Override @Override
public void writeEntityToNBT(NBTTagCompound rootTag) public void writeEntityToNBT(NBTTagCompound rootTag) {
{
super.writeEntityToNBT(rootTag); super.writeEntityToNBT(rootTag);
rootTag.setInteger("Aggro", this.aggro); rootTag.setInteger("Aggro", this.aggro);
} }
@Override @Override
public void readEntityFromNBT(NBTTagCompound rootTag) public void readEntityFromNBT(NBTTagCompound rootTag) {
{
super.readEntityFromNBT(rootTag); super.readEntityFromNBT(rootTag);
// Load Monoliths with half aggro so they don't teleport players instantly // Load Monoliths with half aggro so they don't teleport players instantly
@ -308,29 +265,22 @@ public class MobMonolith extends EntityFlying implements IMob
} }
@Override @Override
public boolean getCanSpawnHere() public boolean getCanSpawnHere() {
{
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, AxisAlignedBB.getBoundingBox( this.posX-15, posY-4, this.posZ-15, this.posX+15, this.posY+15, this.posZ+15)); List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, AxisAlignedBB.fromBounds(this.posX-15, posY-4, this.posZ-15, this.posX+15, this.posY+15, this.posZ+15));
if (this.worldObj.provider.dimensionId == DDProperties.instance().LimboDimensionID) if (this.worldObj.provider.getDimensionId() == DDProperties.instance().LimboDimensionID) {
{ if(list.size()>0) {
if(list.size()>0)
{
return false; return false;
} }
} }
else if(this.worldObj.provider instanceof PocketProvider) else if(this.worldObj.provider instanceof PocketProvider) {
{ if (list.size() > 5 || this.worldObj.canBlockSeeSky(new BlockPos((int)this.posX, (int)this.posY, (int)this.posZ))) {
if (list.size() > 5 ||
this.worldObj.canBlockSeeTheSky((int)this.posX, (int)this.posY, (int)this.posZ))
{
return false; return false;
} }
} }
return this.worldObj.checkNoEntityCollision(this.boundingBox) &&
this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && return this.worldObj.checkNoEntityCollision(this.getEntityBoundingBox()) && this.worldObj.getCollidingBoundingBoxes(this, this.getEntityBoundingBox()).isEmpty() && !this.worldObj.isAnyLiquid(this.getEntityBoundingBox());
!this.worldObj.isAnyLiquid(this.boundingBox);
} }
} }

View file

@ -50,7 +50,7 @@ public class CustomSkyProvider extends IRenderHandler
if (mc.theWorld.provider.isSurfaceWorld()) if (mc.theWorld.provider.isSurfaceWorld())
{ {
GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_2D);
Vec3 vec3 = world.getSkyColor(mc.renderViewEntity, par1); Vec3 vec3 = world.getSkyColor(mc.getRenderViewEntity(), par1);
float f1 = (float)vec3.xCoord; float f1 = (float)vec3.xCoord;
float f2 = (float)vec3.yCoord; float f2 = (float)vec3.yCoord;
float f3 = (float)vec3.zCoord; float f3 = (float)vec3.zCoord;