remove BlockMultiTexture
This commit is contained in:
parent
0d75f89a56
commit
a7f087f598
10 changed files with 31 additions and 315 deletions
Binary file not shown.
Before Width: | Height: | Size: 238 B |
Binary file not shown.
Before Width: | Height: | Size: 238 B |
Binary file not shown.
Before Width: | Height: | Size: 238 B |
Before Width: | Height: | Size: 238 B After Width: | Height: | Size: 238 B |
|
@ -10,27 +10,34 @@ package buildcraft.builders;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.BuildCraftBuilders;
|
||||
import buildcraft.api.events.BlockInteractionEvent;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import buildcraft.core.BlockMultiTexture;
|
||||
import buildcraft.core.BlockBuildCraft;
|
||||
import buildcraft.core.CreativeTabBuildCraft;
|
||||
import buildcraft.core.GuiIds;
|
||||
import buildcraft.core.utils.Utils;
|
||||
|
||||
public class BlockArchitect extends BlockMultiTexture {
|
||||
public class BlockArchitect extends BlockBuildCraft {
|
||||
IIcon blockTextureTop;
|
||||
IIcon blockTextureSide;
|
||||
IIcon blockTextureFront;
|
||||
|
||||
public BlockArchitect() {
|
||||
super(Material.iron, CreativeTabBuildCraft.BLOCKS);
|
||||
|
@ -125,15 +132,30 @@ public class BlockArchitect extends BlockMultiTexture {
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* MULTI TEXTURE */
|
||||
@Override
|
||||
public String getIconPrefix() {
|
||||
return "architect_";
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int i, int j) {
|
||||
if (j == 0 && i == 3) {
|
||||
return blockTextureFront;
|
||||
}
|
||||
|
||||
if (i == j) {
|
||||
return blockTextureFront;
|
||||
}
|
||||
|
||||
switch (i) {
|
||||
case 1:
|
||||
return blockTextureTop;
|
||||
default:
|
||||
return blockTextureSide;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFrontSide(IBlockAccess world, int x, int y, int z) {
|
||||
return world.getBlockMetadata(x, y, z);
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister par1IconRegister) {
|
||||
blockTextureTop = par1IconRegister.registerIcon("buildcraft:architect_top");
|
||||
blockTextureSide = par1IconRegister.registerIcon("buildcraft:architect_side");
|
||||
blockTextureFront = par1IconRegister.registerIcon("buildcraft:architect_front");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ public class BlockBuilder extends BlockBuildCraft {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int i, int j) {
|
||||
if (j == 0 && i == 3) {
|
||||
return blockTextureFront;
|
||||
|
|
|
@ -9,9 +9,7 @@
|
|||
package buildcraft.builders;
|
||||
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import buildcraft.builders.urbanism.TileUrbanist;
|
||||
import buildcraft.core.render.RenderBlockMultiTexture;
|
||||
import buildcraft.core.render.RenderBoxProvider;
|
||||
import buildcraft.core.render.RenderBuilder;
|
||||
|
||||
|
@ -26,8 +24,6 @@ public class BuilderProxyClient extends BuilderProxy {
|
|||
public void registerBlockRenderers() {
|
||||
super.registerBlockRenderers();
|
||||
|
||||
RenderingRegistry.registerBlockHandler(new RenderBlockMultiTexture());
|
||||
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileUrbanist.class, new RenderBoxProvider());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileArchitect.class, new RenderArchitect());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileFiller.class, new RenderBuilder());
|
||||
|
|
|
@ -1,139 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.core;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.core.render.IconFlipped;
|
||||
import buildcraft.core.render.RenderBlockMultiTexture;
|
||||
|
||||
/**
|
||||
* This whole class may need tweaking
|
||||
*/
|
||||
public abstract class BlockMultiTexture extends BlockBuildCraft {
|
||||
|
||||
private static Map<String, IIcon> iconMap = new HashMap<String, IIcon>();
|
||||
|
||||
public BlockMultiTexture(Material material, CreativeTabBuildCraft tab) {
|
||||
super(material, tab);
|
||||
}
|
||||
|
||||
public static int getUVTopForFront(int front) {
|
||||
switch (front) {
|
||||
case 2:
|
||||
return 3;
|
||||
case 3:
|
||||
return 0;
|
||||
case 4:
|
||||
return 1;
|
||||
case 5:
|
||||
return 2;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract int getFrontSide(IBlockAccess world, int x, int y, int z);
|
||||
|
||||
public abstract String getIconPrefix();
|
||||
|
||||
//TODO Remove once we get past 1.7.2! Bug #37106
|
||||
public boolean shouldFlipU(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int front = getFrontSide(world, x, y, z);
|
||||
return (front == 4 && side == 2) || (front == 5 && side == 5) || (front == 5 && side == 2) || (front == 2 && side == 5) || (front == 2 && side == 2) || (front == 3 && side == 5) || shouldFlipU(side, getFrontSide(world, x, y, z));
|
||||
}
|
||||
|
||||
public boolean shouldFlipV(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return shouldFlipV(side, getFrontSide(world, x, y, z));
|
||||
}
|
||||
|
||||
public boolean shouldFlipU(int side, int front) {
|
||||
return front == 3;
|
||||
}
|
||||
|
||||
public boolean shouldFlipV(int side, int front) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getIconPostfix(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return getIconPostfix(side, getFrontSide(world, x, y, z));
|
||||
}
|
||||
|
||||
public String getIconPostfix(int side, int front) {
|
||||
ForgeDirection forgeSide = ForgeDirection.getOrientation(side);
|
||||
ForgeDirection forgeFront = ForgeDirection.getOrientation(front);
|
||||
ForgeDirection forgeBack = forgeFront.getOpposite();
|
||||
ForgeDirection forgeLeft = forgeFront.getRotation(ForgeDirection.UP).getOpposite();
|
||||
ForgeDirection forgeRight = forgeFront.getRotation(ForgeDirection.UP);
|
||||
|
||||
// This would be a switch statement if it could be... :(
|
||||
if (forgeSide == forgeFront) {
|
||||
return "front";
|
||||
} else if (forgeSide == forgeLeft) {
|
||||
return "leftSide";
|
||||
} else if (forgeSide == forgeRight) {
|
||||
return "rightSide";
|
||||
} else if (forgeSide == forgeBack) {
|
||||
return "back";
|
||||
} else if (forgeSide == ForgeDirection.UP) {
|
||||
return "top";
|
||||
} else if (forgeSide == ForgeDirection.DOWN) {
|
||||
return "bottom";
|
||||
}
|
||||
|
||||
// If all else fails
|
||||
return "front";
|
||||
}
|
||||
|
||||
private String getIconName(int side) {
|
||||
return getIconName(side, ForgeDirection.WEST.ordinal());
|
||||
}
|
||||
|
||||
private String getIconName(int side, int front) {
|
||||
return getIconPrefix() + getIconPostfix(side, front);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return RenderBlockMultiTexture.renderID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
|
||||
String name = getIconName(i);
|
||||
iconMap.put(name, register.registerIcon("buildcraft:" + name));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
IconFlipped icon = new IconFlipped(iconMap.get(getIconName(side, ForgeDirection.SOUTH.ordinal())));
|
||||
icon.flipU(shouldFlipU(side, ForgeDirection.SOUTH.ordinal()));
|
||||
icon.flipV(shouldFlipV(side, ForgeDirection.SOUTH.ordinal()));
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
IconFlipped icon = new IconFlipped(iconMap.get(getIconName(side, getFrontSide(world, x, y, z))));
|
||||
icon.flipU(shouldFlipU(world, x, y, z, side));
|
||||
icon.flipV(shouldFlipV(world, x, y, z, side));
|
||||
return icon;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.core.render;
|
||||
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class IconFlipped implements IIcon {
|
||||
|
||||
private final IIcon icon;
|
||||
|
||||
private boolean flipU, flipV;
|
||||
|
||||
public IconFlipped(IIcon icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public IconFlipped flipU(boolean flip) {
|
||||
this.flipU = flip;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IconFlipped flipV(boolean flip) {
|
||||
this.flipV = flip;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconWidth() {
|
||||
return flipU ? -this.icon.getIconWidth() : this.icon.getIconWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconHeight() {
|
||||
return flipV ? -this.icon.getIconHeight() : this.icon.getIconHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMinU() {
|
||||
return flipU ? this.icon.getMaxU() : this.icon.getMinU();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMaxU() {
|
||||
return flipU ? this.icon.getMinU() : this.icon.getMaxU();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getInterpolatedU(double value) {
|
||||
float f = getMaxU() - getMinU();
|
||||
return getMinU() + f * (((float) value / 16.0F));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMinV() {
|
||||
return flipV ? this.icon.getMaxV() : this.icon.getMinV();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMaxV() {
|
||||
return flipV ? this.icon.getMinV() : this.icon.getMaxV();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getInterpolatedV(double value) {
|
||||
float f = getMaxV() - getMinV();
|
||||
return getMinV() + f * (((float) value / 16.0F));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconName() {
|
||||
return this.icon.getIconName();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.core.render;
|
||||
|
||||
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;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.core.BlockMultiTexture;
|
||||
|
||||
public class RenderBlockMultiTexture implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public static int renderID;
|
||||
|
||||
static {
|
||||
renderID = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
renderer.uvRotateTop = BlockMultiTexture.getUVTopForFront(ForgeDirection.EAST.ordinal());
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
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, block.getIcon(0, metadata));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, metadata));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, metadata));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1.0F);
|
||||
renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, metadata));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, metadata));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(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) {
|
||||
renderer.uvRotateTop = BlockMultiTexture.getUVTopForFront(((BlockMultiTexture) block).getFrontSide(world, x, y, z));
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.uvRotateTop = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return renderID;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue