Did the bulk of Rendering and a few other things.

This commit is contained in:
Waterpicker 2016-08-11 01:26:24 -05:00
parent 1e62c62924
commit 9fe42a2358
19 changed files with 743 additions and 1472 deletions

View file

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

View file

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

View file

@ -20,7 +20,6 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import com.zixiken.dimdoors.client.PrivatePocketRender;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -65,10 +64,6 @@ public class BlockDimWall extends Block {
else return SUPER_EXPLOSION_RESISTANCE;
}
public int getRenderType() {
return PrivatePocketRender.renderID;
}
@Override
public int damageDropped(IBlockState state) {
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.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.audio.ISound;
import net.minecraft.client.audio.PositionedSoundRecord;
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.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 {
private DDProperties properties;
@ -21,18 +21,18 @@ public class ClientOnlyHooks {
public ClientOnlyHooks(DDProperties 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)
@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 (FMLClientHandler.instance().getClient().thePlayer.worldObj.provider.dimensionId == DimDoors.properties.LimboDimensionID) {
ResourceLocation sound = new ResourceLocation(DimDoors.modid + ":creepy");
if (FMLClientHandler.instance().getClient().thePlayer.worldObj.provider.getDimensionId() == DimDoors.properties.LimboDimensionID) {
ResourceLocation sound = new ResourceLocation(DimDoors.MODID + ":creepy");
if (!Minecraft.getMinecraft().getSoundHandler().isSoundPlaying(limboMusic)) {
event.result = limboMusic;
@ -45,7 +45,7 @@ public class ClientOnlyHooks {
@SubscribeEvent
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)) {
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.EntityFX;
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.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)
public class ClosingRiftFX extends EntityFX
{
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;
private int baseTextureIndex = 160;
private boolean trail;
private boolean twinkle;
private EffectRenderer effectRenderer;
private float fadeColourRed;
private float fadeColourGreen;
private float fadeColourBlue;
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);
this.motionX = par8;
this.motionY = par10;
this.motionZ = par12;
this.field_92047_az = par14EffectRenderer;
super(world, x, y, z);
this.motionX = motionX;
this.motionY = motionY;
this.motionZ = motionZ;
this.effectRenderer = effectRenderer;
this.particleScale *= .55F;
this.particleMaxAge = 30 + this.rand.nextInt(16);
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()
public AxisAlignedBB getCollisionBoundingBox()
{
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.
*/
@Override
public boolean canBePushed()
{
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 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) {
this.doRenderParticle(worldRenderer, partialTicks, p_180434_4_, p_180434_5_, p_180434_6_, p_180434_7_, p_180434_8_);
}
}
public void doRenderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
{
float var8 = super.particleTextureIndexX % 16 / 16.0F;
float var9 = var8 + 0.0624375F;
float var10 = this.particleTextureIndexX / 16 / 16.0F;
float var11 = var10 + 0.0624375F;
float var12 = 0.1F * this.particleScale;
float var13 = (float)(this.prevPosX + (this.posX - this.prevPosX) * par2 - interpPosX);
float var14 = (float)(this.prevPosY + (this.posY - this.prevPosY) * par2 - interpPosY);
float var15 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * par2 - interpPosZ);
float var16 = 0.8F;
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 var9 = var8 + 0.0624375F;
float var10 = this.particleTextureIndexX / 16 / 16.0F;
float var11 = var10 + 0.0624375F;
float var12 = 0.1F * this.particleScale;
float var13 = (float)(this.prevPosX + (this.posX - this.prevPosX) * par2 - interpPosX);
float var14 = (float)(this.prevPosY + (this.posY - this.prevPosY) * par2 - interpPosY);
float var15 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * par2 - interpPosZ);
float var16 = 0.8F;
if (PocketManager.createDimensionData(worldObj).isPocketDimension())
{
var16 = 0.4F;
}
if (PocketManager.createDimensionData(worldObj).isPocketDimension()) {
var16 = 0.4F;
}
par1Tessellator.setColorRGBA_F(this.particleRed * var16, this.particleGreen * var16, this.particleBlue * var16, (float) .7);
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();
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();
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();
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();
}
par1Tessellator.addVertexWithUV(var13 - par3 * var12 - par6 * var12, var14 - par4 * var12, var15 - par5 * var12 - par7 * var12, var9, var11);
par1Tessellator.addVertexWithUV(var13 - par3 * var12 + par6 * var12, var14 + par4 * var12, var15 - par5 * var12 + par7 * var12, var9, var10);
par1Tessellator.addVertexWithUV(var13 + par3 * var12 + par6 * var12, var14 + par4 * var12, var15 + par5 * var12 + par7 * var12, var8, var10);
par1Tessellator.addVertexWithUV(var13 + par3 * var12 - par6 * var12, var14 - par4 * var12, var15 + par5 * var12 - par7 * var12, var8, var11);
}
/**
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
/**
* 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.particleAge++ >= this.particleMaxAge)
{
this.setDead();
}
if (this.hasFadeColour) {
this.particleRed += (this.fadeColourRed - this.particleRed) * 0.2F;
this.particleGreen += (this.fadeColourGreen - this.particleGreen) * 0.2F;
this.particleBlue += (this.fadeColourBlue - this.particleBlue) * 0.2F;
}
}
if (this.particleAge > this.particleMaxAge / 2)
{
this.setAlphaF(1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / this.particleMaxAge);
this.setParticleTextureIndex(this.baseTextureIndex + (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.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;
}
}
if (this.onGround) {
this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D;}
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.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);
var1.setRBGColorF(this.particleRed, this.particleGreen, this.particleBlue);
var1.particleAge = var1.particleMaxAge / 2;
if (this.onGround)
{
this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D;
}
if (this.hasFadeColour) {
var1.hasFadeColour = true;
var1.fadeColourRed = this.fadeColourRed;
var1.fadeColourGreen = this.fadeColourGreen;
var1.fadeColourBlue = this.fadeColourBlue;
}
if (this.field_92054_ax && 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.field_92047_az);
var1.setRBGColorF(this.particleRed, this.particleGreen, this.particleBlue);
var1.particleAge = var1.particleMaxAge / 2;
var1.twinkle = this.twinkle;
this.effectRenderer.addEffect(var1);
}
}
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)
{
@Override
public int getBrightnessForRender(float par1) {
return 15728880;
}
}
/**
* Gets how bright this entity is.
*/
@Override
public float getBrightness(float par1)
{
return 1.0F;
}
/**
* Gets how bright this entity is.
*/
@Override
public float getBrightness(float par1) {
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.EntityFirework;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GoggleRiftFX extends EntityFirework.SparkFX
{
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)
{
public class GoggleRiftFX extends EntityFirework.SparkFX {
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);
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.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
// - ZeuX
package com.zixiken.dimdoors.client;
import java.util.Random;
import com.zixiken.dimdoors.ticking.MobMonolith;
import net.minecraft.client.renderer.GlStateManager;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
public class ModelMobObelisk extends ModelBase
{
//fields
public class ModelMobObelisk extends ModelBase {
//fields
ModelRenderer wholemonolith;
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()
{
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)
{
@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);
GL11.glScalef(((MobMonolith) par1Entity).getRenderSizeModifier(), ((MobMonolith) par1Entity).getRenderSizeModifier(), ((MobMonolith) par1Entity).getRenderSizeModifier());
GlStateManager.scale(((MobMonolith) par1Entity).getRenderSizeModifier(), ((MobMonolith) par1Entity).getRenderSizeModifier(), ((MobMonolith) par1Entity).getRenderSizeModifier());
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.DimDoors;
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 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.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import static org.lwjgl.opengl.GL11.*;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderDimDoor extends TileEntitySpecialRenderer<TileEntityDimDoor>
{
private FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16);
private ResourceLocation warpPath= new ResourceLocation(DimDoors.modid + ":textures/other/WARP.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 keyOutline= new ResourceLocation(DimDoors.modid + ":textures/other/keyOutline.png");
private ResourceLocation keyOutlineLight= new ResourceLocation(DimDoors.modid + ":textures/other/keyOutlineLight.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 KeyholeLight= new ResourceLocation(DimDoors.MODID + ":textures/other/keyholeLight.png");
private ResourceLocation keyOutline= new ResourceLocation(DimDoors.MODID + ":textures/other/keyOutline.png");
private ResourceLocation keyOutlineLight= new ResourceLocation(DimDoors.MODID + ":textures/other/keyOutlineLight.png");
private static final int NETHER_DIMENSION_ID = -1;
@ -47,162 +45,122 @@ public class RenderDimDoor extends TileEntitySpecialRenderer<TileEntityDimDoor>
/**
* Renders the dimdoor.
*/
public void renderDimDoorTileEntity(TileEntityDimDoor tile, double x,
double y, double z)
{
public void renderDimDoorTileEntity(TileEntityDimDoor tile, double x, double y, double z) {
GL11.glDisable(GL11.GL_LIGHTING);
Random rand = new Random(31100L);
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 var16 = 0.2625F;
float var17 = 1.0F / (var15 + .80F);
if (count == 0)
{
this.bindTexture(warpPath);
// move files into assets/modid and change to new ResourceLocation(modid:/RIFT.png)
this.bindTexture(warpPath);
GlStateManager.enableBlend();
if (count == 0) {
var17 = 0.1F;
var15 = 25.0F;
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)
{
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);
if (count == 1) {
var16 = .5F;
GlStateManager.blendFunc(GL11.GL_ONE, GL11.GL_ONE);
}
GlStateManager.translate(Minecraft.getSystemTime() % 200000L / 200000.0F, 0, 0.0F);
GlStateManager.translate(0, Minecraft.getSystemTime() % 200000L / 200000.0F, 0.0F);
GlStateManager.translate(0, 0, Minecraft.getSystemTime() % 200000L / 200000.0F);
GlStateManager.texGen(GlStateManager.TexGen.S, GL11.GL_OBJECT_LINEAR);
GlStateManager.texGen(GlStateManager.TexGen.T, GL11.GL_OBJECT_LINEAR);
GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_LINEAR);
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_LINEAR);
GL11.glTranslatef(
Minecraft.getSystemTime() % 200000L / 200000.0F,
0, 0.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,
GL11.GL_OBJECT_LINEAR);
GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE,
GL11.GL_OBJECT_LINEAR);
GL11.glTexGeni(GL11.GL_R, GL11.GL_TEXTURE_GEN_MODE,
GL11.GL_OBJECT_LINEAR);
GL11.glTexGeni(GL11.GL_Q, GL11.GL_TEXTURE_GEN_MODE,
GL11.GL_OBJECT_LINEAR);
switch ((tile.orientation % 4) + 4)
{
case 4:
GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE,
this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GL11.glTexGen(GL11.GL_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));
GL11.glTexGen(GL11.GL_Q, GL11.GL_OBJECT_PLANE,
this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.15F));
EnumFacing orientation = EnumFacing.getHorizontal((tile.orientation.getHorizontalIndex() % 4) + 4);
switch (orientation) {
case SOUTH:
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));
GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.15F));
break;
case 5:
GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE,
this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GL11.glTexGen(GL11.GL_T, GL11.GL_OBJECT_PLANE,
this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F));
GL11.glTexGen(GL11.GL_R, GL11.GL_OBJECT_PLANE,
this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GL11.glTexGen(GL11.GL_Q, GL11.GL_OBJECT_PLANE,
this.getFloatBuffer(0.0F, 0.0F, 1.0F, 0.15F));
case WEST:
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(1.0F, 0.0F, 0.0F, 0.0F));
GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 1.0F, 0.15F));
break;
case 6:
GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE,
this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GL11.glTexGen(GL11.GL_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));
GL11.glTexGen(GL11.GL_Q, GL11.GL_OBJECT_PLANE,
this.getFloatBuffer(1.0F, 0.0F, 0.0F, -0.15F));
case NORTH:
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));
GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(1.0F, 0.0F, 0.0F, -0.15F));
break;
case 7:
GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE,
this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GL11.glTexGen(GL11.GL_T, GL11.GL_OBJECT_PLANE,
this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F));
GL11.glTexGen(GL11.GL_R, GL11.GL_OBJECT_PLANE,
this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GL11.glTexGen(GL11.GL_Q, GL11.GL_OBJECT_PLANE,
this.getFloatBuffer(0.0F, 0.0F, 1.0F, -0.15F));
case EAST:
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(1.0F, 0.0F, 0.0F, 0.0F));
GlStateManager.texGen(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GlStateManager.texGen(GlStateManager.TexGen.Q, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 1.0F, -0.15F));
break;
}
}
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.S);
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.T);
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.R);
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.Q);
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);
GlStateManager.popMatrix();
GlStateManager.matrixMode(GL11.GL_TEXTURE);
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);
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);
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldRenderer = tessellator.getWorldRenderer();
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
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)
{
case 0:
GL11.glVertex3d(x + .01F, y - 1, z);
GL11.glVertex3d(x + .01, y - 1, z + 1.0D);
GL11.glVertex3d(x + .01, y + 1, z + 1.0D);
GL11.glVertex3d(x + .01, y + 1, z);
switch (tile.orientation) {
case SOUTH:
worldRenderer.pos(x + .01F, y - 1, z).endVertex();
worldRenderer.pos(x + .01, y - 1, z + 1.0D).endVertex();
worldRenderer.pos(x + .01, y + 1, z + 1.0D).endVertex();
worldRenderer.pos(x + .01, y + 1, z).endVertex();
break;
case 1:
GL11.glVertex3d(x, y + 1, z + .01);
GL11.glVertex3d(x + 1, y + 1, z + .01);
GL11.glVertex3d(x + 1, y -1, z + .01);
GL11.glVertex3d(x, y -1, z + .01);
case WEST:
worldRenderer.pos(x, y + 1, z + .01).endVertex();
worldRenderer.pos(x + 1, y + 1, z + .01).endVertex();
worldRenderer.pos(x + 1, y -1, z + .01).endVertex();
worldRenderer.pos(x, y -1, z + .01).endVertex();
break;
case 2:
GL11.glVertex3d(x + .99, y + 1, z);
GL11.glVertex3d(x + .99, y + 1, z + 1.0D);
GL11.glVertex3d(x + .99, y - 1, z + 1.0D);
GL11.glVertex3d(x + .99, y - 1, z);
case NORTH:
worldRenderer.pos(x + .99, y + 1, z).endVertex();
worldRenderer.pos(x + .99, y + 1, z + 1.0D).endVertex();
worldRenderer.pos(x + .99, y - 1, z + 1.0D).endVertex();
worldRenderer.pos(x + .99, y - 1, z).endVertex();
break;
case 3:
GL11.glVertex3d(x, y -1, z + .99);
GL11.glVertex3d(x + 1, y -1, z + .99);
GL11.glVertex3d(x + 1, y + 1, z + .99);
GL11.glVertex3d(x, y + 1, z + .99);
case EAST:
worldRenderer.pos(x, y -1, z + .99).endVertex();
worldRenderer.pos(x + 1, y -1, z + .99).endVertex();
worldRenderer.pos(x + 1, y + 1, z + .99).endVertex();
worldRenderer.pos(x, y + 1, z + .99).endVertex();
break;
case 4:
/*case 4:
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);
@ -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, y + 1, z + .85);
break;
break;*/
}
tessellator.draw();
GL11.glEnd();
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GlStateManager.popMatrix();
GlStateManager.matrixMode(GL11.GL_MODELVIEW);
}
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_TEXTURE_GEN_S);
GL11.glDisable(GL11.GL_TEXTURE_GEN_T);
GL11.glDisable(GL11.GL_TEXTURE_GEN_R);
GL11.glDisable(GL11.GL_TEXTURE_GEN_Q);
GL11.glEnable(GL11.GL_LIGHTING);
GlStateManager.disableBlend();
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.S);
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.T);
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.R);
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.Q);
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.put(par1).put(par2).put(par3).put(par4);
buffer.flip();
return buffer;
}
private void renderKeyHole(TileEntityDimDoor tile, double x,
double y, double z, int i)
{
if(tile.orientation>3)
{
return;
}
int rotation = (tile.orientation+3)%4;
private void renderKeyHole(TileEntityDimDoor tile, double x, double y, double z, int i) {
EnumFacing rotation = EnumFacing.getHorizontal((tile.orientation.getHorizontalIndex()+3)%4);
GL11.glPushMatrix();
GL11.glTranslated(x,y,z);
GlStateManager.pushMatrix();
GlStateManager.translate(x,y,z);
x= ActiveRenderInfo.objectX;
y = ActiveRenderInfo.objectY;
z = ActiveRenderInfo.objectZ;
x = ActiveRenderInfo.getPosition().xCoord;
y = ActiveRenderInfo.getPosition().yCoord;
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.glTranslatef(0.007F, .25F, 0F);
GlStateManager.translate(0.007F, .25F, 0F);
switch (rotation)
{
case 0:
switch (rotation) {
case SOUTH:
GL11.glTranslatef(-0.5F, 0, -0.03F);
break;
case 1:
case WEST:
GL11.glTranslatef(-.5F, 0F, .97F);
break;
case 2:
case NORTH:
GL11.glTranslatef(.5F, 0F, .97F);
break;
case 3:
case EAST:
GL11.glTranslatef(0.5F, 0F, -0.03F);
}
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.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);
GL11.glDisable(GL_LIGHTING);
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_BLEND);
if(i==1) {
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
public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8)
{
if (properties.DoorRenderingEnabled)
{
TileEntityDimDoor tile = (TileEntityDimDoor) par1TileEntity;
try
{
DimDoors.dimensionalDoor.updateAttachedTile(tile.getWorldObj(),
tile.xCoord, tile.yCoord, tile.zCoord);
}
catch (Exception e)
{
public void renderTileEntityAt(TileEntityDimDoor te, double x, double y, double z, float partialTicks, int destroyStage) {
if (properties.DoorRenderingEnabled) {
TileEntityDimDoor tile = te;
try {
DimDoors.dimensionalDoor.updateAttachedTile(tile.getWorld(), tile.getPos());
} catch (Exception e) {
e.printStackTrace();
}
if (tile.openOrClosed)
{
renderDimDoorTileEntity((TileEntityDimDoor) par1TileEntity, par2, par4, par6);
if(tile.lockStatus>=1)
{
for(int i = 0; i<1+tile.lockStatus; i++ )
{
this.renderKeyHole(tile, par2, par4, par6, i);
if (tile.openOrClosed) {
renderDimDoorTileEntity((TileEntityDimDoor) te, x, y, z);
if(tile.lockStatus>=1) {
for(int i = 0; i<1+tile.lockStatus; i++ ) {
this.renderKeyHole(tile, x, y, z, i);
}
}

View file

@ -3,6 +3,7 @@ package com.zixiken.dimdoors.client;
import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.ticking.MobMonolith;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.entity.RenderLiving;
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.common.MinecraftForge;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderMobObelisk extends RenderLiving<MobMonolith>
{
@ -25,15 +25,15 @@ public class RenderMobObelisk extends RenderLiving<MobMonolith>
public RenderMobObelisk(RenderManager manager) {
super(manager, new ModelMobObelisk(), 0.5F);
this.obeliskModel = (ModelMobObelisk)this.mainModel;
this.obeliskModel = (ModelMobObelisk) this.mainModel;
}
@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 maxScaling = 0.1f;
MobMonolith monolith = ((MobMonolith) entity);
MobMonolith monolith = (MobMonolith) entity;
float aggroScaling = 0;
if (monolith.isDangerous()) {
@ -50,69 +50,64 @@ public class RenderMobObelisk extends RenderLiving<MobMonolith>
// Render with jitter
this.render(entity, x + xJitter, y + yJitter, z + zJitter, par8, par9);
this.func_110827_b(entity, x, y, z, par8, par9);
this.renderLeash(entity, x, y, z, par8, par9);
}
public void render(EntityLiving par1EntityLivingBase, double x, double y, double z, float par8, float par9)
{
if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre(par1EntityLivingBase, this, x, y, z))) return;
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
this.mainModel.onGround = this.renderSwingProgress(par1EntityLivingBase, 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;
GlStateManager.pushMatrix();
GlStateManager.disableCull();
GlStateManager.disableLighting();
GlStateManager.disableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
try
{
float interpolatedYaw = interpolateRotation(par1EntityLivingBase.prevRenderYawOffset, par1EntityLivingBase.renderYawOffset, par9);
float interpolatedYawHead = interpolateRotation(par1EntityLivingBase.prevRotationYawHead, par1EntityLivingBase.rotationYawHead, par9);
try {
float interpolatedYaw = interpolateRotation(entity.prevRenderYawOffset, entity.renderYawOffset, par9);
float interpolatedYawHead = interpolateRotation(entity.prevRotationYawHead, entity.rotationYawHead, par9);
float rotation;
float pitch = par1EntityLivingBase.prevRotationPitch + (par1EntityLivingBase.rotationPitch - par1EntityLivingBase.prevRotationPitch) * par9;
this.renderLivingAt(par1EntityLivingBase, x, y, z);
float pitch = entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * par9;
this.renderLivingAt(entity, x, y, z);
rotation = this.handleRotationFloat(par1EntityLivingBase, par9);
this.rotateCorpse(par1EntityLivingBase, rotation, interpolatedYaw, par9);
rotation = this.handleRotationFloat(entity, par9);
this.rotateCorpse(entity, rotation, interpolatedYaw, par9);
float f6 = 0.0625F;
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GlStateManager.enableRescaleNormal();
GL11.glScalef(-1.0F, -1.0F, 1.0F);
this.preRenderCallback(par1EntityLivingBase, par9);
GL11.glRotatef(((MobMonolith)par1EntityLivingBase).pitchLevel , 1.0F, 0.0F, 0.0F);
GL11.glTranslatef(0.0F, 24.0F * f6 - 0.0078125F, 0.0F);
GlStateManager.scale(-1.0F, -1.0F, 1.0F);
this.preRenderCallback(entity, par9);
GlStateManager.rotate(((MobMonolith) entity).pitchLevel, 1.0F, 0.0F, 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);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GlStateManager.disableTexture2D();;
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
}
catch (Exception exception)
{
GlStateManager.disableRescaleNormal();
} catch (Exception exception) {
exception.printStackTrace();
}
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GlStateManager.enableTexture2D();
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Post(par1EntityLivingBase, this, x, y, z));
GlStateManager.enableCull();
GlStateManager.enableLighting();
GlStateManager.disableBlend();
GlStateManager.popMatrix();
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;
while (f3 < -180.0f)
{
while (f3 < -180.0f) {
f3 += 360.0F;
}
while (f3 >= 180.0F)
{
f3 -= 360.0F;
@ -121,9 +116,8 @@ public class RenderMobObelisk extends RenderLiving<MobMonolith>
}
@Override
protected ResourceLocation getEntityTexture(Entity entity)
{
protected ResourceLocation getEntityTexture(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 com.zixiken.dimdoors.tileentities.TileEntityRift;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderRift extends TileEntitySpecialRenderer
{
public class RenderRift extends TileEntitySpecialRenderer {
@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
GL11.glPushMatrix();
// make the rift render on both sides, disable texture mapping and
// lighting
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDisable(GL_TEXTURE_2D);
GL11.glDisable(GL_LIGHTING);
GL11.glEnable(GL_BLEND);
GlStateManager.disableCull();
GlStateManager.disableTexture2D();
GlStateManager.disableLighting();
GlStateManager.enableBlend();
/**
* GL11.glLogicOp(GL11.GL_INVERT);
* GL11.glEnable(GL11.GL_COLOR_LOGIC_OP);
@ -32,12 +30,12 @@ public class RenderRift extends TileEntitySpecialRenderer
TileEntityRift rift = (TileEntityRift) te;
// draws the verticies corresponding to the passed it
GL11.glDisable(GL_BLEND);
// reenable all the stuff we disabled
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL_TEXTURE_2D);
GlStateManager.disableBlend();
GlStateManager.enableCull();
GlStateManager.enableLighting();
GlStateManager.enableTexture2D();
GL11.glPopMatrix();
GlStateManager.popMatrix();
}
}

View file

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

View file

@ -4,69 +4,41 @@ import com.zixiken.dimdoors.core.PocketManager;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.particle.EntityFX;
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.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)
public class RiftFX extends EntityFX
{
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 class RiftFX extends EntityFX {
private int baseTextureIndex = 160;
private boolean trail;
private boolean twinkle;
private final EffectRenderer effectRenderer;
private float fadeColourRed;
private float fadeColourGreen;
private float fadeColourBlue;
private boolean hasFadeColour;
public RiftFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, EffectRenderer par14EffectRenderer)
{
super(par1World, par2, par4, par6);
this.motionX = par8;
this.motionY = par10;
this.motionZ = par12;
this.field_92047_az = 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;
this.motionY = motionY;
this.motionZ = motionZ;
this.effectRenderer = effectRenderer;
this.particleScale *= 0.75F;
this.particleMaxAge = 40 + this.rand.nextInt(26);
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()
{
public AxisAlignedBB getCollisionBoundingBox() {
return null;
}
@ -80,17 +52,13 @@ public class RiftFX extends EntityFX
}
@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 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) {
this.doRenderParticle(worldRenderer, 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 f7 = f6 + 0.0624375F;
@ -98,8 +66,7 @@ public class RiftFX extends EntityFX
float f9 = f8 + 0.0624375F;
float f10 = 0.1F * this.particleScale;
if (this.particleIcon != null)
{
if (this.particleIcon != null) {
f6 = this.particleIcon.getMinU();
f7 = this.particleIcon.getMaxU();
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 f14 = 0F;
if (PocketManager.createDimensionData(worldObj).isPocketDimension())
{
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);
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();
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();
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();
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();
}
/**
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate()
{
public void onUpdate() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if (this.particleAge++ >= this.particleMaxAge)
{
if (this.particleAge++ >= this.particleMaxAge) {
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);
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;
if (this.hasFadeColour) {
this.particleRed += (this.fadeColourRed - this.particleRed) * 0.2F;
this.particleGreen += (this.fadeColourGreen - this.particleGreen) * 0.2F;
this.particleBlue += (this.fadeColourBlue - 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.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.9100000262260437D;
this.motionY *= 0.9100000262260437D;
this.motionZ *= 0.9100000262260437D;
if (this.onGround)
{
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)
{
RiftFX var1 = new RiftFX(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.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);
rift.setRBGColorF(this.particleRed, this.particleGreen, this.particleBlue);
rift.particleAge = rift.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;
if (this.hasFadeColour) {
rift.hasFadeColour = true;
rift.fadeColourRed = this.fadeColourRed;
rift.fadeColourGreen = this.fadeColourGreen;
rift.fadeColourBlue = this.fadeColourBlue;
}
var1.field_92048_ay = this.field_92048_ay;
this.field_92047_az.addEffect(var1);
rift.twinkle = this.twinkle;
this.effectRenderer.addEffect(rift);
}
}
@Override
public int getBrightnessForRender(float par1)
{
public int getBrightnessForRender(float par1) {
return 15728880;
}
@ -192,8 +149,7 @@ public class RiftFX extends EntityFX
* Gets how bright this entity is.
*/
@Override
public float getBrightness(float par1)
{
public float getBrightness(float par1) {
return 1.0F;
}
}

View file

@ -1,24 +1,19 @@
package com.zixiken.dimdoors.client;
public class TESyncHandler
{
public void onServerChanges()
{
public class TESyncHandler {
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 net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
public class CommandCreatePocket extends DDCommandBase {
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.
//The pocket dimension will serve as a room for the player to build a dungeon.
int x = (int) sender.posX;
int y = (int) sender.posY;
int z = (int) sender.posZ;
DungeonHelper.instance().createCustomDungeonDoor(sender.worldObj, x, y, z);
BlockPos pos = new BlockPos((int) sender.posX, (int) sender.posY, (int) sender.posZ);
DungeonHelper.instance().createCustomDungeonDoor(sender.worldObj, pos);
//Notify the player
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.Random;
import com.zixiken.dimdoors.helpers.EnumFacingHelper;
import com.zixiken.dimdoors.world.LimboProvider;
import com.zixiken.dimdoors.blocks.BaseDimDoor;
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.util.Point4D;
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.BlockDoor;
import net.minecraft.block.state.IBlockState;
@ -38,7 +37,7 @@ import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager;
import com.zixiken.dimdoors.watcher.ClientDimData;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.FMLCommonHandler;
public class DDTeleporter {
private static final Random random = new Random();
@ -103,41 +102,34 @@ public class DDTeleporter {
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 y = destination.getY();
int z = destination.getZ();
EnumFacing orientation;
if (checkOrientation)
{
if (checkOrientation) {
orientation = getDestinationOrientation(destination, properties);
entity.rotationYaw = (orientation.getIndex() * 90) + 90;
}
else
{
} else {
// Teleport the entity to the precise destination point
orientation = EnumFacing.SOUTH;
}
if (entity instanceof EntityPlayer)
{
if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
if (checkDestination(world, destination, orientation))
{
switch (orientation)
{
case 0:
if (checkDestination(world, destination, orientation)) {
switch (orientation) {
case SOUTH:
player.setPositionAndUpdate(x - 0.5, y - 1, z + 0.5);
break;
case 1:
case WEST:
player.setPositionAndUpdate(x + 0.5, y - 1, z - 0.5);
break;
case 2:
case NORTH:
player.setPositionAndUpdate(x + 1.5, y - 1, z + 0.5);
break;
case 3:
case EAST:
player.setPositionAndUpdate(x + 0.5, y - 1, z + 1.5);
break;
default:
@ -148,30 +140,27 @@ public class DDTeleporter {
else {
player.setPositionAndUpdate(x + 0.5, y - 1, z + 0.5);
}
}
else if (entity instanceof EntityMinecart)
{
} else if (entity instanceof EntityMinecart) {
entity.motionX = 0;
entity.motionZ = 0;
entity.motionY = 0;
switch (orientation)
{
case 0:
switch (orientation) {
case SOUTH:
DDTeleporter.setEntityPosition(entity, x - 0.5, y, z + 0.5);
entity.motionX = -0.39;
entity.worldObj.updateEntityWithOptionalForce(entity, false);
break;
case 1:
case WEST:
DDTeleporter.setEntityPosition(entity, x + 0.5, y, z - 0.5);
entity.motionZ = -0.39;
entity.worldObj.updateEntityWithOptionalForce(entity, false);
break;
case 2:
case NORTH:
DDTeleporter.setEntityPosition(entity, x + 1.5, y, z + 0.5);
entity.motionX = 0.39;
entity.worldObj.updateEntityWithOptionalForce(entity, false);
break;
case 3:
case EAST:
DDTeleporter.setEntityPosition(entity, x + 0.5, y, z + 1.5);
entity.motionZ = 0.39;
entity.worldObj.updateEntityWithOptionalForce(entity, false);
@ -181,21 +170,18 @@ public class DDTeleporter {
entity.worldObj.updateEntityWithOptionalForce(entity, false);
break;
}
}
else
{
switch (orientation)
{
case 0:
} else {
switch (orientation) {
case SOUTH:
setEntityPosition(entity, x - 0.5, y, z + 0.5);
break;
case 1:
case WEST:
setEntityPosition(entity, x + 0.5, y, z - 0.5);
break;
case 2:
case NORTH:
setEntityPosition(entity, x + 1.5, y, z + 0.5);
break;
case 3:
case EAST:
setEntityPosition(entity, x + 0.5, y, z + 1.5);
break;
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.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.setPosition(x, y, z);
}
@ -232,12 +217,9 @@ public class DDTeleporter {
}
public static Entity teleportEntity(Entity entity, Point4D destination, boolean checkOrientation) {
if (entity == null)
{
if (entity == null) {
throw new IllegalArgumentException("entity cannot be null.");
}
if (destination == null)
{
} if (destination == null) {
throw new IllegalArgumentException("destination cannot be null.");
}
//This beautiful teleport method is based off of xCompWiz's teleport function.
@ -248,15 +230,13 @@ public class DDTeleporter {
DDProperties properties = DDProperties.instance();
// Is something riding? Handle it first.
if (entity.riddenByEntity != null)
{
if (entity.riddenByEntity != null) {
return teleportEntity(entity.riddenByEntity, destination, checkOrientation);
}
// Are we riding something? Dismount and tell the mount to go first.
Entity cart = entity.ridingEntity;
if (cart != null)
{
if (cart != null) {
entity.mountEntity(null);
cart = teleportEntity(cart, destination, checkOrientation);
// 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.
boolean difDest = entity.dimension != destination.getDimension();
if (difDest)
{
if (difDest) {
// Destination isn't loaded? Then we need to load it.
newWorld = PocketManager.loadDimension(destination.getDimension());
}
else
{
} else {
newWorld = oldWorld;
}
@ -279,10 +256,8 @@ public class DDTeleporter {
// TODO Check to see if this is actually vital.
DDTeleporter.placeInPortal(entity, newWorld, destination, properties, checkOrientation);
if (difDest) // Are we moving our target to a new dimension?
{
if(player != null) // Are we working with a player?
{
if (difDest) // Are we moving our target to a new dimension?{
if(player != null) // Are we working with a player?{
// We need to do all this special stuff to move a player between dimensions.
//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.
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.
// 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));
}
// Creates sanity by removing the entity from its old location's chunk entity list, if applicable.
int entX = entity.chunkCoordX;
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).isModified = true;
oldWorld.getChunkFromChunkCoords(entX, entZ).setModified(true);
}
// Memory concerns.
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();
entity.isDead = false;
entity.writeMountToNBT(entityNBT);
if(entityNBT.hasNoTags())
{
if(entityNBT.hasNoTags()) {
return entity;
}
entity.isDead = true;
entity = EntityList.createEntityFromNBT(entityNBT, newWorld);
if (entity == null)
{
if (entity == null) {
// TODO FIXME IMPLEMENT NULL CHECKS THAT ACTUALLY DO SOMETHING.
/*
* shit ourselves in an organized fashion, preferably
@ -360,27 +334,25 @@ public class DDTeleporter {
// Finally, respawn the entity in its new home.
newWorld.spawnEntityInWorld(entity);
entity.setWorld(newWorld);
}
entity.worldObj.updateEntityWithOptionalForce(entity, false);
// 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.
if (player != null)
{
if (player != null) {
entity.worldObj.updateEntityWithOptionalForce(entity, true);
}
entity.mountEntity(cart);
}
// Did we teleport a player? Load the chunk for them.
if (player != null)
{
newWorld.getChunkProvider().loadChunk(MathHelper.floor_double(entity.posX) >> 4, MathHelper.floor_double(entity.posZ) >> 4);
if (player != null) {
newWorld.getChunkProvider().provideChunk(MathHelper.floor_double(entity.posX) >> 4, MathHelper.floor_double(entity.posZ) >> 4);
// 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.
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);
@ -401,45 +373,33 @@ public class DDTeleporter {
if(link == null) throw new IllegalArgumentException("link 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
// 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.
cooldown = 2 + random.nextInt(2);
}
else
{
} else {
return;
}
if (!initializeDestination(link, DDProperties.instance(),entity,door))
{
if (!initializeDestination(link, DDProperties.instance(),entity,door)) {
return;
}
if (link.linkType() == LinkType.RANDOM)
{
} if (link.linkType() == LinkType.RANDOM) {
Point4D randomDestination = getRandomDestination();
if (randomDestination != null)
{
if (randomDestination != null) {
entity = teleportEntity(entity, randomDestination, true);
entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
}
}
else
{
} else {
buildExitDoor(door, link, DDProperties.instance());
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);
}
}
private static boolean initializeDestination(DimLink link, DDProperties properties, Entity entity, Block door)
{
if (link.hasDestination()&&link.linkType()!=LinkType.PERSONAL)
{
if (PocketManager.isBlackListed(link.destination().getDimension()))
{
private static boolean initializeDestination(DimLink link, DDProperties properties, Entity entity, Block door) {
if (link.hasDestination()&&link.linkType()!=LinkType.PERSONAL) {
if (PocketManager.isBlackListed(link.destination().getDimension())) {
// This link leads to a dimension that has been blacklisted.
// 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
// a different value. DimData will overwrite it in-place.
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
start.createLink(link.source(), LinkType.DUNGEON, link.orientation(), null);
}
else
{
if (start.isPocketDimension())
{
} else {
if (start.isPocketDimension()) {
// Ovewrite the link into a safe exit link, because
// this could be the only way out from a pocket.
start.createLink(link.source(), LinkType.SAFE_EXIT, link.orientation(), null);
}
else
{
} else {
// Cancel the teleport attempt
return false;
}
}
}
else
{
} else {
return true;
}
}
// Check the destination type and respond accordingly
switch (link.linkType())
{
switch (link.linkType()) {
case DUNGEON:
return PocketBuilder.generateNewDungeonPocket(link, properties);
case POCKET:
@ -489,8 +440,7 @@ public class DDTeleporter {
case UNSAFE_EXIT:
return generateUnsafeExit(link);
case LIMBO:
if(!(entity instanceof EntityPlayer))
{
if(!(entity instanceof EntityPlayer)) {
return false;
}
@ -506,32 +456,27 @@ public class DDTeleporter {
}
}
private static boolean setupPersonalLink(DimLink link, DDProperties properties,Entity entity, Block door)
{
if(!(entity instanceof EntityPlayer))
{
private static boolean setupPersonalLink(DimLink link, DDProperties properties,Entity entity, Block door) {
if(!(entity instanceof EntityPlayer)) {
return false;
}
EntityPlayer player = (EntityPlayer)entity;
DimData dim = PocketManager.getPersonalDimensionForPlayer(player.getGameProfile().getId().toString());
if(dim == null)
{
if(dim == null) {
return PocketBuilder.generateNewPersonalPocket(link, properties, player, door);
}
DimLink personalHomeLink = dim.getLink(dim.origin());
if(personalHomeLink!=null)
{
if(personalHomeLink!=null) {
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;
}
private static Point4D getRandomDestination()
{
private static Point4D getRandomDestination() {
// Our aim is to return a random link's source point
// 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
// because we want to have unbiased selection among all links.
ArrayList<Point4D> matches = new ArrayList<Point4D>();
for (DimData dimension : PocketManager.getRootDimensions())
{
for (DimLink link : dimension.getAllLinks())
{
if (link.linkType() != LinkType.RANDOM)
{
for (DimData dimension : PocketManager.getRootDimensions()) {
for (DimLink link : dimension.getAllLinks()) {
if (link.linkType() != LinkType.RANDOM) {
matches.add(link.source());
}
}
}
// Pick a random point, if any is available
if (!matches.isEmpty())
{
if (!matches.isEmpty()) {
return matches.get( random.nextInt(matches.size()) );
}
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
// 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
@ -575,68 +515,58 @@ public class DDTeleporter {
DimData current = PocketManager.getDimensionData(link.point.getDimension());
if (current.isPocketDimension())
{
if (current.isPocketDimension()) {
Point4D source = link.source();
World world = PocketManager.loadDimension(current.root().id());
if (world == null)
{
if (world == null) {
return false;
}
BlockPos destination = yCoordHelper.findDropPoint(world, source.getX(), source.getY() + 1, source.getZ());
if (destination != null)
{
current.root().setLinkDestination(link, destination.getX(), destination.getY(), destination.getZ());
if (destination != null) {
current.root().setLinkDestination(link, destination);
return true;
}
}
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 destWorld = PocketManager.loadDimension(link.destination().getDimension());
TileEntity doorTE = startWorld.getTileEntity(link.source().getX(), link.source().getY(), link.point.getZ());
if(doorTE instanceof TileEntityDimDoor)
{
if((TileEntityDimDoor.class.cast(doorTE).hasGennedPair))
{
TileEntity doorTE = startWorld.getTileEntity(link.source().toBlockPos());
if(doorTE instanceof TileEntityDimDoor) {
if((TileEntityDimDoor.class.cast(doorTE).hasGennedPair)) {
return;
}
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(!blockToReplace.isReplaceable(destWorld, link.destination().getX(), link.destination().getY(), link.destination().getZ()))
{
if(!destWorld.isAirBlock(link.destination().toBlockPos())) {
if(!blockToReplace.isReplaceable(destWorld, link.destination().toBlockPos())) {
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;
}
}
}
private static boolean generateSafeExit(DimLink link, DDProperties properties)
{
private static boolean generateSafeExit(DimLink link, DDProperties properties) {
DimData current = PocketManager.getDimensionData(link.point.getDimension());
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
// 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
@ -647,21 +577,16 @@ public class DDTeleporter {
ArrayList<DimData> roots = PocketManager.getRootDimensions();
int shiftChance = START_ROOT_SHIFT_CHANCE + ROOT_SHIFT_CHANCE_PER_LEVEL * (current.packDepth() - 1);
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 (random.nextInt(MAX_ROOT_SHIFT_CHANCE) < shiftChance) {
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);
}
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);
}
for (int attempts = 0; attempts < 10; attempts++)
{
for (int attempts = 0; attempts < 10; attempts++) {
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);
}
}
@ -674,18 +599,17 @@ public class DDTeleporter {
private static boolean isValidForDungeonExit(DimData destination, DDProperties properties)
{
// 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;
}
// 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().
World world = PocketManager.loadDimension(destination.id());
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
// some precautions to protect the player. The X and Z coordinates
// are fixed to match the source (mostly - may be shifted a little),
@ -694,8 +618,7 @@ public class DDTeleporter {
Point4D source = link.source();
World world = PocketManager.loadDimension(destinationDim.id());
if (world == null)
{
if (world == null) {
return false;
}
@ -704,40 +627,28 @@ public class DDTeleporter {
BlockPos locationUp = yCoordHelper.findSafeCubeUp(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;
}
else if (locationDown == null)
{
destination = locationUp;
}
else if (locationUp.getY() - startY <= startY - locationDown.getY())
{
destination = locationUp;
}
else
{
destination = locationDown;
}
if (destination != null)
{
if (destination != null) {
// Set up a 3x3 platform at the destination
// Only place fabric of reality if the block is replaceable or air
// Don't cause block updates
int x = destination.getX();
int y = destination.getY();
int z = destination.getZ();
for (int dx = -1; dx <= 1; dx++)
{
for (int dz = -1; dz <= 1; dz++)
{
BlockPos pos = destination;
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 for a replaceable block, because we only allow
// exits intersecting blocks on those two surfaces.
if (!world.isBlockNormalCubeDefault(x + dx, y, z + dz, false))
{
world.setBlock(x + dx, y, z + dz, DimDoors.blockDimWall, 0, 2);
if (!world.isBlockNormalCube(pos.add(dx, 0, dz), false)) {
world.setBlockState(pos.add(dx, 0, dz), DimDoors.blockDimWall.getDefaultState());
}
}
}
@ -745,31 +656,28 @@ public class DDTeleporter {
// Clear out any blocks in the space above the platform layer
// This removes any potential threats like replaceable Poison Ivy from BoP
// Remember to avoid block updates to keep gravel from collapsing
for (int dy = 1; dy <= 2; dy++)
{
for (int dx = -1; dx <= 1; dx++)
{
for (int dz = -1; dz <= 1; dz++)
{
world.setBlock(x + dx, y + dy, z + dz, Blocks.air, 0, 2);
for (int dy = 1; dy <= 2; dy++) {
for (int dx = -1; dx <= 1; dx++) {
for (int dz = -1; dz <= 1; dz++) {
world.setBlockState(pos.add(dx, dy, dz), Blocks.air.getDefaultState());
}
}
}
// Create a reverse link for returning
int orientation = getDestinationOrientation(source, properties);
EnumFacing orientation = getDestinationOrientation(source, properties);
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
orientation = BlockRotator.transformMetadata(orientation, 2, DimDoors.warpDoor);
ItemDoor.placeDoorBlock(world, x, y + 1, z, orientation, DimDoors.warpDoor);
orientation = EnumFacingHelper.getFacingFromBlockState(BlockRotator.transform(DimDoors.warpDoor.getDefaultState(), 2));
ItemDoor.placeDoor(world, pos.up(), orientation, DimDoors.warpDoor);
// Complete the link to the destination
// 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);

View file

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

View file

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

View file

@ -50,7 +50,7 @@ public class CustomSkyProvider extends IRenderHandler
if (mc.theWorld.provider.isSurfaceWorld())
{
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 f2 = (float)vec3.yCoord;
float f3 = (float)vec3.zCoord;