Skip to content

Instantly share code, notes, and snippets.

@perky
Created December 19, 2012 20:12
Show Gist options
  • Save perky/4340049 to your computer and use it in GitHub Desktop.
Save perky/4340049 to your computer and use it in GitHub Desktop.
package ljdp.minechem.client;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.registry.TickRegistry;
import net.minecraft.world.World;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;
import ljdp.minechem.common.CommonProxy;
import ljdp.minechem.common.MinechemItems;
import ljdp.minechem.common.tileentity.TileEntityMicroscope;
public class ClientProxy extends CommonProxy {
@Override
public void registerRenderers() {
MinecraftForgeClient.preloadTexture(ELEMENTBOTTLES_PNG);
MinecraftForgeClient.preloadTexture(DECOMPOSER_GUI_PNG);
MinecraftForgeClient.preloadTexture(MICROSCOPE_GUI_PNG);
MinecraftForgeClient.preloadTexture(SYNTHESIS_GUI_PNG);
MinecraftForgeClient.preloadTexture(BLOCKS_PNG);
MinecraftForgeClient.preloadTexture(TERRAIN_ALPHA_PNG);
MinecraftForgeClient.preloadTexture(MICROSCOPE_MODEL);
RENDER_MICROSCOPE = RenderingRegistry.getNextAvailableRenderId();
MinecraftForgeClient.registerItemRenderer(MinechemItems.element.shiftedIndex, new ItemElementRenderer());
MinecraftForgeClient.registerItemRenderer(MinechemItems.molecule.shiftedIndex, new ItemMoleculeRenderer());
RenderingRegistry.registerBlockHandler(new RenderBlockGhostBlock());
TickRegistry.registerTickHandler(new TickHandler(), Side.CLIENT);
}
@Override
public void registerTileEntities() {
ClientRegistry.registerTileEntity(TileEntityMicroscope.class, "minechem.tileEntityMicroscope", new RenderTileEntityMicroscope());
}
@Override
public World getClientWorld() {
return FMLClientHandler.instance().getClient().theWorld;
}
}
package ljdp.minechem.common;
import ljdp.minechem.common.tileentity.TileEntityDecomposer;
import ljdp.minechem.common.tileentity.TileEntityMicroscope;
import ljdp.minechem.common.tileentity.TileEntitySynthesis;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.world.World;
public class CommonProxy {
public static String TEXTURE_DIR = "/ljdp/minechem/textures/";
public static String TAB_LEFT_PNG = TEXTURE_DIR + "tab_left.png";
public static String TAB_RIGHT_PNG = TEXTURE_DIR + "tab_right.png";
public static String ELEMENTBOTTLES_PNG = TEXTURE_DIR + "elementbottles.png";
public static String DECOMPOSER_GUI_PNG = TEXTURE_DIR + "ChemicalDecomposerGUI.png";
public static String MICROSCOPE_GUI_PNG = TEXTURE_DIR + "MicroscopeGUI.png";
public static String SYNTHESIS_GUI_PNG = TEXTURE_DIR + "SynthesisGUI.png";
public static String BLOCKS_PNG = TEXTURE_DIR + "blocktextures.png";
public static String ICONS_PNG = TEXTURE_DIR + "icons.png";
public static String TERRAIN_ALPHA_PNG = TEXTURE_DIR + "terrainWithAlpha.png";
public static String MICROSCOPE_MODEL = TEXTURE_DIR + "MicroscopeModel.png";
public static int RENDER_MICROSCOPE;
public void registerRenderers() {
}
public void registerTileEntities() {
GameRegistry.registerTileEntity(TileEntityMicroscope.class, "minechem.tileEntityMicroscope");
GameRegistry.registerTileEntity(TileEntitySynthesis.class, "minechem.tileEntitySynthesis");
GameRegistry.registerTileEntity(TileEntityDecomposer.class, "minechem.tileEntityDecomposer");
}
public World getClientWorld() {
return null;
}
}
// Date: 19/12/2012 19:16:44
// Template version 1.1
// Java generated by Techne
// Keep in mind that you still need to fill in some blanks
// - ZeuX
package ljdp.minechem.client;
import org.lwjgl.opengl.GL11;
import ljdp.minechem.common.ModMinechem;
import ljdp.minechem.common.tileentity.TileEntityMicroscope;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraftforge.client.ForgeHooksClient;
public class ModelMicroscope extends ModelBase
{
//fields
ModelRenderer base;
ModelRenderer neck_lower;
ModelRenderer platter;
ModelRenderer light;
ModelRenderer neck_upper;
ModelRenderer top;
ModelRenderer eyepiece;
ModelRenderer lens1;
ModelRenderer lens2;
ModelRenderer lens3;
ModelRenderer focus_right;
ModelRenderer focus_left;
ModelRenderer axle;
public ModelMicroscope()
{
textureWidth = 64;
textureHeight = 32;
base = new ModelRenderer(this, 8, 16);
base.addBox(0F, 0F, 0F, 14, 2, 14);
base.setRotationPoint(-7F, 22F, -7F);
base.setTextureSize(64, 32);
base.mirror = true;
setRotation(base, 0F, 0F, 0F);
neck_lower = new ModelRenderer(this, 16, 6);
neck_lower.addBox(0F, 0F, 0F, 4, 6, 4);
neck_lower.setRotationPoint(-2F, 16F, -7F);
neck_lower.setTextureSize(64, 32);
neck_lower.mirror = true;
setRotation(neck_lower, 0F, 0F, 0F);
platter = new ModelRenderer(this, 32, 7);
platter.addBox(0F, 0F, 0F, 8, 1, 8);
platter.setRotationPoint(-4F, 18F, -4F);
platter.setTextureSize(64, 32);
platter.mirror = true;
setRotation(platter, 0F, 0F, 0F);
light = new ModelRenderer(this, 0, 28);
light.addBox(0F, 0F, 0F, 2, 2, 2);
light.setRotationPoint(-1F, 20F, -1F);
light.setTextureSize(64, 32);
light.mirror = true;
setRotation(light, 0F, 0F, 0F);
neck_upper = new ModelRenderer(this, 8, 8);
neck_upper.addBox(0F, 0F, 0F, 2, 6, 2);
neck_upper.setRotationPoint(-1F, 11F, -3F);
neck_upper.setTextureSize(64, 32);
neck_upper.mirror = true;
setRotation(neck_upper, -0.5061455F, 0F, 0F);
top = new ModelRenderer(this, 46, 0);
top.addBox(0F, 0F, 0F, 4, 2, 5);
top.setRotationPoint(-2F, 11F, -3F);
top.setTextureSize(64, 32);
top.mirror = true;
setRotation(top, 0F, 0F, 0F);
eyepiece = new ModelRenderer(this, 0, 4);
eyepiece.addBox(0F, 0F, 0F, 1, 4, 1);
eyepiece.setRotationPoint(-0.5F, 9F, -6F);
eyepiece.setTextureSize(64, 32);
eyepiece.mirror = true;
setRotation(eyepiece, 0.8028515F, 0F, 0F);
lens1 = new ModelRenderer(this, 6, 0);
lens1.addBox(0F, 0F, 0F, 1, 3, 1);
lens1.setRotationPoint(-0.5F, 13F, -0.5F);
lens1.setTextureSize(64, 32);
lens1.mirror = true;
setRotation(lens1, 0F, 0F, 0F);
lens2 = new ModelRenderer(this, 6, 0);
lens2.addBox(0F, 0F, 0F, 1, 3, 1);
lens2.setRotationPoint(0.3666667F, 11.93333F, 1.1F);
lens2.setTextureSize(64, 32);
lens2.mirror = true;
setRotation(lens2, 0.3717861F, 1.07818F, 0.1858931F);
lens3 = new ModelRenderer(this, 6, 0);
lens3.addBox(0F, 0F, 0F, 1, 3, 1);
lens3.setRotationPoint(-0.2F, 11.73333F, 1.2F);
lens3.setTextureSize(64, 32);
lens3.mirror = true;
setRotation(lens3, -0.1115358F, -2.767534F, -0.3346075F);
focus_right = new ModelRenderer(this, 0, 0);
focus_right.addBox(0F, 0F, 0F, 1, 2, 2);
focus_right.setRotationPoint(3F, 17F, -7F);
focus_right.setTextureSize(64, 32);
focus_right.mirror = true;
setRotation(focus_right, 0F, 0F, 0F);
focus_left = new ModelRenderer(this, 0, 0);
focus_left.addBox(0F, 0F, 0F, 1, 2, 2);
focus_left.setRotationPoint(-4F, 17F, -7F);
focus_left.setTextureSize(64, 32);
focus_left.mirror = true;
setRotation(focus_left, 0F, 0F, 0F);
axle = new ModelRenderer(this, 10, 0);
axle.addBox(0F, 0F, 0F, 6, 1, 1);
axle.setRotationPoint(-3F, 17.5F, -6.5F);
axle.setTextureSize(64, 32);
axle.mirror = true;
setRotation(axle, 0F, 0F, 0F);
}
public void render(float scale)
{
base.render(scale);
neck_lower.render(scale);
platter.render(scale);
light.render(scale);
neck_upper.render(scale);
top.render(scale);
eyepiece.render(scale);
lens1.render(scale);
lens2.render(scale);
lens3.render(scale);
focus_right.render(scale);
focus_left.render(scale);
axle.render(scale);
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}
package ljdp.minechem.common.blocks;
import java.util.ArrayList;
import ljdp.minechem.common.ModMinechem;
import ljdp.minechem.common.tileentity.TileEntityMicroscope;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockMicroscope extends BlockMinechemContainer {
public BlockMicroscope(int par1) {
super(par1, Material.iron);
setCreativeTab(ModMinechem.minechemTab);
setBlockName("minechem.blockMicroscope");
}
@Override
public boolean onBlockActivated(World world, int x, int y,
int z, EntityPlayer entityPlayer, int par6, float par7,
float par8, float par9) {
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if(tileEntity == null || entityPlayer.isSneaking())
return false;
entityPlayer.openGui(ModMinechem.instance, 0, world, x, y, z);
return true;
}
@Override
public TileEntity createNewTileEntity(World var1) {
return new TileEntityMicroscope();
}
@Override
public ArrayList<ItemStack> addStacksDroppedOnBlockBreak(TileEntity tileEntity, ArrayList itemStacks) {
ItemStack inputStack = ((TileEntityMicroscope)tileEntity).getStackInSlot(0);
if(inputStack != null)
itemStacks.add(inputStack);
return itemStacks;
}
@Override
public String getTextureFile() {
return ModMinechem.proxy.BLOCKS_PNG;
}
@Override
public int getBlockTextureFromSide(int par1) {
return par1 == 1 ? 14 : 0;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int getRenderType() {
return ModMinechem.proxy.RENDER_MICROSCOPE;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
}
package ljdp.minechem.client;
import org.lwjgl.opengl.GL11;
import ljdp.minechem.common.ModMinechem;
import ljdp.minechem.common.tileentity.TileEntityMicroscope;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.client.ForgeHooksClient;
public class RenderTileEntityMicroscope extends TileEntitySpecialRenderer {
ModelMicroscope modelMicroscope;
public RenderTileEntityMicroscope() {
modelMicroscope = new ModelMicroscope();
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8) {
if(tileEntity instanceof TileEntityMicroscope) {
GL11.glPushMatrix();
GL11.glTranslated(x, y, z);
GL11.glDisable(GL11.GL_LIGHTING);
ForgeHooksClient.bindTexture(ModMinechem.proxy.MICROSCOPE_MODEL, 0);
modelMicroscope.render(0.0625F);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment