mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-26 23:23:15 +00:00
Lots of changes, fixed a few crashes, and minor bugs. Also, doesnt need Asielib anymore
This commit is contained in:
1 parent
333c1d6596
commit
fd4351711a
146 files changed
+12167
-9527
No files matched your search
@@ -5,50 +5,58 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class BlockTexturedOre extends Block {
|
||||
int currentPass;
|
||||
Block base;
|
||||
IIcon icon;
|
||||
String iconFile;
|
||||
public class BlockTexturedOre extends Block
|
||||
{
|
||||
int currentPass;
|
||||
Block base;
|
||||
IIcon icon;
|
||||
String iconFile;
|
||||
|
||||
public BlockTexturedOre(Material mat, Block base) {
|
||||
super(mat);
|
||||
public BlockTexturedOre(Material mat, Block base)
|
||||
{
|
||||
super(mat);
|
||||
|
||||
this.base = base;
|
||||
}
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
public BlockTexturedOre(Material mat, String iconFile) {
|
||||
super(mat);
|
||||
public BlockTexturedOre(Material mat, String iconFile)
|
||||
{
|
||||
super(mat);
|
||||
|
||||
this.iconFile=iconFile;
|
||||
}
|
||||
this.iconFile = iconFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return BlockTexturedOreRenderer.id;
|
||||
}
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return BlockTexturedOreRenderer.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass() {
|
||||
return 1;
|
||||
}
|
||||
@Override
|
||||
public int getRenderBlockPass()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderInPass(int pass) {
|
||||
currentPass = pass;
|
||||
@Override
|
||||
public boolean canRenderInPass(int pass)
|
||||
{
|
||||
currentPass = pass;
|
||||
|
||||
return pass == 1 || pass == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
if(iconFile!=null)
|
||||
icon=register.registerIcon(iconFile);
|
||||
}
|
||||
return pass == 1 || pass == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register)
|
||||
{
|
||||
if(iconFile != null)
|
||||
icon = register.registerIcon(iconFile);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,66 +10,78 @@ import org.lwjgl.opengl.GL11;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockTexturedOreRenderer implements ISimpleBlockRenderingHandler {
|
||||
float bot=-0.001f,top=1.0f-bot;
|
||||
static int id;
|
||||
public class BlockTexturedOreRenderer implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
float bot = -0.001f, top = 1.0f - bot;
|
||||
static int id;
|
||||
|
||||
public BlockTexturedOreRenderer() {
|
||||
id = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
public BlockTexturedOreRenderer()
|
||||
{
|
||||
id = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block blck, int meta, int modelID, RenderBlocks renderer) {
|
||||
if (blck == null || !(blck instanceof BlockTexturedOre))
|
||||
return;
|
||||
|
||||
BlockTexturedOre block=(BlockTexturedOre) blck;
|
||||
|
||||
if(block.icon!=null){
|
||||
renderer.overrideBlockTexture=block.icon;
|
||||
renderer.renderBlockAsItem(Blocks.stone,meta,1.0f);
|
||||
renderer.overrideBlockTexture=null;
|
||||
} else if(block.base!=null){
|
||||
renderer.renderBlockAsItem(block.base,meta,1.0f);
|
||||
}
|
||||
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
renderer.setRenderBounds(bot, bot, bot, top, top, top);
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
Drawing.drawBlock(block, meta, renderer);
|
||||
GL11.glDisable(3042);
|
||||
}
|
||||
@Override
|
||||
public void renderInventoryBlock(Block blck, int meta, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if(blck == null || !(blck instanceof BlockTexturedOre))
|
||||
return;
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block blck, int modelId, RenderBlocks renderer) {
|
||||
if (blck == null || !(blck instanceof BlockTexturedOre))
|
||||
return false;
|
||||
BlockTexturedOre block=(BlockTexturedOre) blck;
|
||||
|
||||
if(block.currentPass==0){
|
||||
if(block.icon!=null){
|
||||
renderer.overrideBlockTexture=block.icon;
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.overrideBlockTexture=null;
|
||||
} else if(block.base!=null){
|
||||
renderer.renderBlockByRenderType(block.base, x, y, z);
|
||||
}
|
||||
} else{
|
||||
renderer.setRenderBounds(bot, bot, bot, top, top, top);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
BlockTexturedOre block = (BlockTexturedOre) blck;
|
||||
|
||||
return true;
|
||||
}
|
||||
if(block.icon != null)
|
||||
{
|
||||
renderer.overrideBlockTexture = block.icon;
|
||||
renderer.renderBlockAsItem(Blocks.stone, meta, 1.0f);
|
||||
renderer.overrideBlockTexture = null;
|
||||
} else if(block.base != null)
|
||||
{
|
||||
renderer.renderBlockAsItem(block.base, meta, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return true;
|
||||
}
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
renderer.setRenderBounds(bot, bot, bot, top, top, top);
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
Drawing.drawBlock(block, meta, renderer);
|
||||
GL11.glDisable(3042);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return id;
|
||||
}
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block blck, int modelId, RenderBlocks renderer)
|
||||
{
|
||||
if(blck == null || !(blck instanceof BlockTexturedOre))
|
||||
return false;
|
||||
BlockTexturedOre block = (BlockTexturedOre) blck;
|
||||
|
||||
if(block.currentPass == 0)
|
||||
{
|
||||
if(block.icon != null)
|
||||
{
|
||||
renderer.overrideBlockTexture = block.icon;
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.overrideBlockTexture = null;
|
||||
} else if(block.base != null)
|
||||
{
|
||||
renderer.renderBlockByRenderType(block.base, x, y, z);
|
||||
}
|
||||
} else
|
||||
{
|
||||
renderer.setRenderBounds(bot, bot, bot, top, top, top);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -5,62 +5,65 @@ import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class Drawing {
|
||||
public static void drawBlock(Block block,IIcon icon, RenderBlocks renderer){
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
public class Drawing
|
||||
{
|
||||
public static void drawBlock(Block block, IIcon icon, RenderBlocks renderer)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||
renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, icon);
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, icon);
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1.0F);
|
||||
renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, icon);
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, icon);
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, icon);
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, icon);
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawBlock(Block block,int meta, RenderBlocks renderer){
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
public static void drawBlock(Block block, int meta, RenderBlocks renderer)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||
renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1.0F);
|
||||
renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, meta));
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,11 @@ package info.jbcs.minecraft.utilities;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
public class DummyContainer extends Container {
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
public class DummyContainer extends Container
|
||||
{
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -14,78 +14,88 @@ import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class General {
|
||||
public static Random rand = new Random();
|
||||
public class General
|
||||
{
|
||||
public static Random rand = new Random();
|
||||
|
||||
public static void propelTowards(Entity what, Entity whereTo, double force) {
|
||||
double dx = whereTo.posX - what.posX;
|
||||
double dy = whereTo.posY - what.posY;
|
||||
double dz = whereTo.posZ - what.posZ;
|
||||
double total = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
||||
public static void propelTowards(Entity what, Entity whereTo, double force)
|
||||
{
|
||||
double dx = whereTo.posX - what.posX;
|
||||
double dy = whereTo.posY - what.posY;
|
||||
double dz = whereTo.posZ - what.posZ;
|
||||
double total = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
||||
|
||||
if (total == 0) {
|
||||
what.motionX = 0;
|
||||
what.motionY = 0;
|
||||
what.motionZ = 0;
|
||||
} else {
|
||||
what.motionX = dx / total * force;
|
||||
what.motionY = dy / total * force;
|
||||
what.motionZ = dz / total * force;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isInRange(double distance, double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||
double x = x1 - x2;
|
||||
double y = y1 - y2;
|
||||
double z = z1 - z2;
|
||||
if(total == 0)
|
||||
{
|
||||
what.motionX = 0;
|
||||
what.motionY = 0;
|
||||
what.motionZ = 0;
|
||||
} else
|
||||
{
|
||||
what.motionX = dx / total * force;
|
||||
what.motionY = dy / total * force;
|
||||
what.motionZ = dz / total * force;
|
||||
}
|
||||
}
|
||||
|
||||
return x * x + y * y + z * z < distance * distance;
|
||||
}
|
||||
public static boolean isInRange(double distance, double x1, double y1, double z1, double x2, double y2, double z2)
|
||||
{
|
||||
double x = x1 - x2;
|
||||
double y = y1 - y2;
|
||||
double z = z1 - z2;
|
||||
|
||||
public static Item getItem(ItemStack stack) {
|
||||
if (stack == null)
|
||||
return null;
|
||||
if (stack.getItem() == null)
|
||||
return null;
|
||||
return x * x + y * y + z * z < distance * distance;
|
||||
}
|
||||
|
||||
return stack.getItem();
|
||||
}
|
||||
public static Item getItem(ItemStack stack)
|
||||
{
|
||||
if(stack == null)
|
||||
return null;
|
||||
if(stack.getItem() == null)
|
||||
return null;
|
||||
|
||||
public static String getUnlocalizedName(Block block) {
|
||||
String name=block.getUnlocalizedName();
|
||||
if(name.startsWith("tile.")) name=name.substring(5);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public static String getName(Block block){
|
||||
String res=block.getUnlocalizedName();
|
||||
return res.substring(5);
|
||||
}
|
||||
|
||||
return stack.getItem();
|
||||
}
|
||||
|
||||
public static MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3) {
|
||||
float var4 = 1.0F;
|
||||
float var5 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4;
|
||||
float var6 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4;
|
||||
double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * var4;
|
||||
double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * var4 + 1.62D - par2EntityPlayer.yOffset;
|
||||
double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * var4;
|
||||
Vec3 var13 = par1World.getWorldVec3Pool().getVecFromPool(var7, var9, var11);
|
||||
float var14 = MathHelper.cos(-var6 * 0.017453292F - (float) Math.PI);
|
||||
float var15 = MathHelper.sin(-var6 * 0.017453292F - (float) Math.PI);
|
||||
float var16 = -MathHelper.cos(-var5 * 0.017453292F);
|
||||
float var17 = MathHelper.sin(-var5 * 0.017453292F);
|
||||
float var18 = var15 * var16;
|
||||
float var20 = var14 * var16;
|
||||
double var21 = 5.0D;
|
||||
public static String getUnlocalizedName(Block block)
|
||||
{
|
||||
String name = block.getUnlocalizedName();
|
||||
if(name.startsWith("tile.")) name = name.substring(5);
|
||||
|
||||
if (par2EntityPlayer instanceof EntityPlayerMP) {
|
||||
var21 = ((EntityPlayerMP) par2EntityPlayer).theItemInWorldManager.getBlockReachDistance();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
Vec3 var23 = var13.addVector(var18 * var21, var17 * var21, var20 * var21);
|
||||
return par1World.rayTraceBlocks(var13, var23, par3);
|
||||
}
|
||||
public static String getName(Block block)
|
||||
{
|
||||
String res = block.getUnlocalizedName();
|
||||
return res.substring(5);
|
||||
}
|
||||
|
||||
|
||||
public static MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3)
|
||||
{
|
||||
float var4 = 1.0F;
|
||||
float var5 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4;
|
||||
float var6 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4;
|
||||
double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * var4;
|
||||
double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * var4 + 1.62D - par2EntityPlayer.yOffset;
|
||||
double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * var4;
|
||||
Vec3 var13 = par1World.getWorldVec3Pool().getVecFromPool(var7, var9, var11);
|
||||
float var14 = MathHelper.cos(-var6 * 0.017453292F - (float) Math.PI);
|
||||
float var15 = MathHelper.sin(-var6 * 0.017453292F - (float) Math.PI);
|
||||
float var16 = -MathHelper.cos(-var5 * 0.017453292F);
|
||||
float var17 = MathHelper.sin(-var5 * 0.017453292F);
|
||||
float var18 = var15 * var16;
|
||||
float var20 = var14 * var16;
|
||||
double var21 = 5.0D;
|
||||
|
||||
if(par2EntityPlayer instanceof EntityPlayerMP)
|
||||
{
|
||||
var21 = ((EntityPlayerMP) par2EntityPlayer).theItemInWorldManager.getBlockReachDistance();
|
||||
}
|
||||
|
||||
Vec3 var23 = var13.addVector(var18 * var21, var17 * var21, var20 * var21);
|
||||
return par1World.rayTraceBlocks(var13, var23, par3);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,27 +9,33 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GeneralClient {
|
||||
public static Random rand = new Random();
|
||||
public class GeneralClient
|
||||
{
|
||||
public static Random rand = new Random();
|
||||
|
||||
public static void playChiselSound(World world, int x, int y, int z, String sound) {
|
||||
Minecraft.getMinecraft().theWorld.playSound(x + 0.5, y + 0.5, z + 0.5, sound, 0.3f + 0.7f * rand.nextFloat(), 0.6f + 0.4f * rand.nextFloat(), true);
|
||||
}
|
||||
public static void playChiselSound(World world, int x, int y, int z, String sound)
|
||||
{
|
||||
Minecraft.getMinecraft().theWorld.playSound(x + 0.5, y + 0.5, z + 0.5, sound, 0.3f + 0.7f * rand.nextFloat(), 0.6f + 0.4f * rand.nextFloat(), true);
|
||||
}
|
||||
|
||||
|
||||
public static IIcon getMissingIcon() {
|
||||
return ((TextureMap)Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
|
||||
}
|
||||
public static IIcon getMissingIcon()
|
||||
{
|
||||
return ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
|
||||
}
|
||||
|
||||
static HashMap<String,ResourceLocation> resources=new HashMap<String,ResourceLocation>();
|
||||
public static void bind(String textureName) {
|
||||
ResourceLocation res=resources.get(textureName);
|
||||
|
||||
if(res==null){
|
||||
res=new ResourceLocation(textureName);
|
||||
resources.put(textureName,res);
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(res);
|
||||
}
|
||||
static HashMap<String, ResourceLocation> resources = new HashMap<String, ResourceLocation>();
|
||||
|
||||
public static void bind(String textureName)
|
||||
{
|
||||
ResourceLocation res = resources.get(textureName);
|
||||
|
||||
if(res == null)
|
||||
{
|
||||
res = new ResourceLocation(textureName);
|
||||
resources.put(textureName, res);
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(res);
|
||||
}
|
||||
}
|
||||
@@ -8,58 +8,69 @@ import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
|
||||
public abstract class GuiHandler implements Comparable {
|
||||
static ArrayList<GuiHandler> items = new ArrayList<GuiHandler>();
|
||||
public abstract class GuiHandler implements Comparable
|
||||
{
|
||||
static ArrayList<GuiHandler> items = new ArrayList<GuiHandler>();
|
||||
|
||||
int index;
|
||||
Object mod;
|
||||
String name;
|
||||
int index;
|
||||
Object mod;
|
||||
String name;
|
||||
|
||||
public GuiHandler(String n) {
|
||||
items.add(this);
|
||||
name = n;
|
||||
}
|
||||
public GuiHandler(String n)
|
||||
{
|
||||
items.add(this);
|
||||
name = n;
|
||||
}
|
||||
|
||||
public void open(EntityPlayer player, World world, int x, int y, int z) {
|
||||
player.openGui(mod, index, world, x, y, z);
|
||||
}
|
||||
public void open(EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
player.openGui(mod, index, world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object a) {
|
||||
return name.compareTo(((GuiHandler) a).name);
|
||||
}
|
||||
@Override
|
||||
public int compareTo(Object a)
|
||||
{
|
||||
return name.compareTo(((GuiHandler) a).name);
|
||||
}
|
||||
|
||||
public static void register(Object mod) {
|
||||
Collections.sort(items);
|
||||
int index = 0;
|
||||
public static void register(Object mod)
|
||||
{
|
||||
Collections.sort(items);
|
||||
int index = 0;
|
||||
|
||||
for (GuiHandler h : items) {
|
||||
h.mod = mod;
|
||||
h.index = index++;
|
||||
}
|
||||
for(GuiHandler h : items)
|
||||
{
|
||||
h.mod = mod;
|
||||
h.index = index++;
|
||||
}
|
||||
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(mod, new IGuiHandler() {
|
||||
@Override
|
||||
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if (id < 0 || id >= items.size()) {
|
||||
return null;
|
||||
}
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(mod, new IGuiHandler()
|
||||
{
|
||||
@Override
|
||||
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
if(id < 0 || id >= items.size())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return items.get(id).getServerGuiElement(id, player, world, x, y, z);
|
||||
}
|
||||
return items.get(id).getServerGuiElement(id, player, world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if (id < 0 || id >= items.size()) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
if(id < 0 || id >= items.size())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return items.get(id).getClientGuiElement(id, player, world, x, y, z);
|
||||
}
|
||||
});
|
||||
}
|
||||
return items.get(id).getClientGuiElement(id, player, world, x, y, z);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public abstract Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z);
|
||||
public abstract Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z);
|
||||
|
||||
public abstract Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z);
|
||||
public abstract Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z);
|
||||
}
|
||||
@@ -4,24 +4,29 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemMetaBlock extends ItemBlock {
|
||||
public ItemMetaBlock(Block b) {
|
||||
super(b);
|
||||
setMaxDamage(0);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemstack) {
|
||||
if (itemstack == null) {
|
||||
return Block.getBlockFromItem(this).getUnlocalizedName();
|
||||
}
|
||||
public class ItemMetaBlock extends ItemBlock
|
||||
{
|
||||
public ItemMetaBlock(Block b)
|
||||
{
|
||||
super(b);
|
||||
setMaxDamage(0);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
return Block.getBlockFromItem(this).getUnlocalizedName();
|
||||
}
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemstack)
|
||||
{
|
||||
if(itemstack == null)
|
||||
{
|
||||
return Block.getBlockFromItem(this).getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int i) {
|
||||
return i;
|
||||
}
|
||||
return Block.getBlockFromItem(this).getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int i)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user