Various Small Changes #142

Merged
SenseiKiwi merged 9 commits from master into master 2014-03-08 02:53:14 +00:00
20 changed files with 186 additions and 57 deletions
Showing only changes of commit 576ac0aae2 - Show all commits

View File

@@ -6,6 +6,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.IconFlipped;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@@ -28,9 +29,13 @@ import cpw.mods.fml.relauncher.SideOnly;
public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEntityProvider
{
private Icon blockIconBottom;
protected final DDProperties properties;
@SideOnly(Side.CLIENT)
private Icon[] upperTextures;
@SideOnly(Side.CLIENT)
private Icon[] lowerTextures;
public BaseDimDoor(int blockID, Material material, DDProperties properties)
{
super(blockID, material);
@@ -39,10 +44,15 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
}
@Override
public void registerIcons(IconRegister par1IconRegister)
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName()+"_top");
this.blockIconBottom = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName()+"_bottom");
upperTextures = new Icon[2];
lowerTextures = new Icon[2];
upperTextures[0] = iconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName() + "_upper");
lowerTextures[0] = iconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName() + "_lower");
upperTextures[1] = new IconFlipped(upperTextures[0], true, false);
lowerTextures[1] = new IconFlipped(lowerTextures[0], true, false);
}
/**
@@ -50,9 +60,9 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
*/
@Override
@SideOnly(Side.CLIENT)
public Icon getIcon(int par1, int par2)
public Icon getIcon(int side, int metadata)
{
return this.blockIcon;
return this.upperTextures[0];
}
@Override
@@ -64,22 +74,24 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
int var10 = this.getFullMetadata(world, x, y, z);
int var11 = var10 & 7;
var11 ^= 4;
final int MAGIC_CONSTANT = 1003;
if ((var10 & 8) == 0)
int metadata = this.getFullMetadata(world, x, y, z);
int lowMeta = metadata & 7;
lowMeta ^= 4;
if (isUpperDoorBlock(metadata))
{
world.setBlockMetadataWithNotify(x, y, z, var11,2);
world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
world.setBlockMetadataWithNotify(x, y - 1, z, lowMeta,2);
world.markBlockRangeForRenderUpdate(x, y - 1, z, x, y, z);
}
else
{
world.setBlockMetadataWithNotify(x, y - 1, z, var11,2);
world.markBlockRangeForRenderUpdate(x, y - 1, z, x, y, z);
world.setBlockMetadataWithNotify(x, y, z, lowMeta, 2);
world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
}
world.playAuxSFXAtEntity(player, 1003, x, y, z, 0);
world.playAuxSFXAtEntity(player, MAGIC_CONSTANT, x, y, z, 0);
return true;
}
@@ -91,21 +103,71 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
this.updateAttachedTile(world, x, y, z);
}
/**
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
*/
@Override
@SideOnly(Side.CLIENT)
public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
public Icon getBlockTexture(IBlockAccess blockAccess, int x, int y, int z, int side)
{
if(par1IBlockAccess.getBlockId(par2, par3-1, par4) == this.blockID)
if (side != 1 && side != 0)
{
return this.blockIcon;
int fullMetadata = this.getFullMetadata(blockAccess, x, y, z);
int orientation = fullMetadata & 3;
boolean reversed = false;
if (isDoorOpen(fullMetadata))
{
if (orientation == 0 && side == 2)
{
reversed = !reversed;
}
else if (orientation == 1 && side == 5)
{
reversed = !reversed;
}
else if (orientation == 2 && side == 3)
{
reversed = !reversed;
}
else if (orientation == 3 && side == 4)
{
reversed = !reversed;
}
}
else
{
return blockIconBottom;
if (orientation == 0 && side == 5)
{
reversed = !reversed;
}
else if (orientation == 1 && side == 3)
{
reversed = !reversed;
}
else if (orientation == 2 && side == 4)
{
reversed = !reversed;
}
else if (orientation == 3 && side == 2)
{
reversed = !reversed;
}
if ((fullMetadata & 16) != 0)
{
reversed = !reversed;
}
}
if (isUpperDoorBlock(fullMetadata))
return this.upperTextures[reversed ? 1 : 0];
else
return this.lowerTextures[reversed ? 1 : 0];
}
else
{
return this.lowerTextures[0];
}
}
@@ -353,12 +415,12 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
@Override
public abstract int getDrops();
protected static boolean isUpperDoorBlock(int metadata)
public static boolean isUpperDoorBlock(int metadata)
{
return (metadata & 8) != 0;
}
protected static boolean isDoorOpen(int metadata)
public static boolean isDoorOpen(int metadata)
{
return (metadata & 4) != 0;
}

View File

@@ -27,7 +27,7 @@ public class BlockDimWall extends Block
public BlockDimWall(int blockID, int j, Material par2Material)
{
super(blockID, Material.ground);
super(blockID, par2Material);
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
}

View File

@@ -8,6 +8,7 @@ import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.IconFlipped;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.Item;
import net.minecraft.util.Icon;
@@ -15,7 +16,10 @@ import net.minecraft.world.IBlockAccess;
public class BlockDoorGold extends BlockDoor
{
private Icon blockIconBottom;
@SideOnly(Side.CLIENT)
private Icon[] upperTextures;
@SideOnly(Side.CLIENT)
private Icon[] lowerTextures;
public BlockDoorGold(int par1, Material par2Material)
{
@@ -23,10 +27,15 @@ public class BlockDoorGold extends BlockDoor
}
@Override
public void registerIcons(IconRegister par1IconRegister)
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName()+"_top");
this.blockIconBottom = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName()+"_bottom");
upperTextures = new Icon[2];
lowerTextures = new Icon[2];
upperTextures[0] = iconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName() + "_upper");
lowerTextures[0] = iconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName() + "_lower");
upperTextures[1] = new IconFlipped(upperTextures[0], true, false);
lowerTextures[1] = new IconFlipped(lowerTextures[0], true, false);
}
@Override
@@ -35,23 +44,81 @@ public class BlockDoorGold extends BlockDoor
return (par1 & 8) != 0 ? 0 : mod_pocketDim.itemGoldenDoor.itemID;
}
@Override
public Icon getIcon(int par1, int par2)
{
return this.blockIcon;
}
/**
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
*/
@Override
@SideOnly(Side.CLIENT)
public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
public Icon getIcon(int side, int metadata)
{
if (par1IBlockAccess.getBlockId(par2, par3 - 1, par4) == this.blockID)
return this.upperTextures[0];
}
/**
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
*/
@Override
@SideOnly(Side.CLIENT)
public Icon getBlockTexture(IBlockAccess blockAccess, int x, int y, int z, int side)
{
return this.blockIcon;
if (side != 1 && side != 0)
{
int fullMetadata = this.getFullMetadata(blockAccess, x, y, z);
int orientation = fullMetadata & 3;
boolean reversed = false;
if (BaseDimDoor.isDoorOpen(fullMetadata))
{
if (orientation == 0 && side == 2)
{
reversed = !reversed;
}
else if (orientation == 1 && side == 5)
{
reversed = !reversed;
}
else if (orientation == 2 && side == 3)
{
reversed = !reversed;
}
else if (orientation == 3 && side == 4)
{
reversed = !reversed;
}
}
else
{
return blockIconBottom;
if (orientation == 0 && side == 5)
{
reversed = !reversed;
}
else if (orientation == 1 && side == 3)
{
reversed = !reversed;
}
else if (orientation == 2 && side == 4)
{
reversed = !reversed;
}
else if (orientation == 3 && side == 2)
{
reversed = !reversed;
}
if ((fullMetadata & 16) != 0)
{
reversed = !reversed;
}
}
if (BaseDimDoor.isUpperDoorBlock(fullMetadata))
return this.upperTextures[reversed ? 1 : 0];
else
return this.lowerTextures[reversed ? 1 : 0];
}
else
{
return this.lowerTextures[0];
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 625 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 778 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 698 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB