If it still does not work, try adding print-out statements inside checkForNeighbors to print what the values actually are. I tried replicating this idea and found that sometimes the server had the correct values but the client did not. Maybe that was just me, though.
its not working the checkForNeighbors is never being ran, why can that be?
thanks for the response, but that poses a new problem. My world.getBlock(x + 1, y, z) == GunnCraftBlocks.Pipe) have errors under getBlock only options are to change it to getBlockMetadata and isAirBlock
i believe you just helped me with the other post that was basically tied to this just simplified a specific question
/*
* attempt to make a neighbor checking function
*/
public void checkForNeighbors(World world, int x, int y, int z) {
if (world.getBlock(x - 1, y, z) == GunnCraftBlocks.Pipe){
num1 = true;
}
if (world.getBlock(x + 1, y, z) == GunnCraftBlocks.Pipe){
num1 = true;
}
if (world.getBlock(x, y - 1, z) == GunnCraftBlocks.Pipe){
num2 = true;
}
if (world.getBlock(x, y + 1, z) == GunnCraftBlocks.Pipe){
num2 = true;
}
if (world.getBlock(x, y, z - 1) == GunnCraftBlocks.Pipe){
num3 = true;
}
if (world.getBlock(x, y, z + 1) == GunnCraftBlocks.Pipe){
num3 = true;
}
}
I would also recommend changing num1, num2, and num3 to booleans (true-false values) and renaming to shouldRender1, shouldRender2, and shouldRender3 (or some other descriptive name).
Thanks for the advice sky_01 on changing a few things
I would like to make a pipe block/tile entity that can visually connect with other blocks like it, Just like in IC2.
I've made a block, the tile entity, model and render for it. I just need help with the checking its neighbors and rendering the block to look like its connecting.
0
why isn't checkForNeighbors being ran?
ModelPipe class:
package com.gunnthorian.model;
import java.util.Random;
import com.gunnthorian.block.GunnCraftBlocks;
import com.gunnthorian.block.Pipe;
import com.gunnthorian.renderer.RenderPipe;
import net.minecraft.block.Block;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class ModelPipe extends ModelBase{
private static final TileEntity TileEntity = null;
private static final float F = 0;
//fields
ModelRenderer horrizShape1;
ModelRenderer horrizShape2;
ModelRenderer horrizShape3;
ModelRenderer horrizShape4;
ModelRenderer verticalShape1;
ModelRenderer verticalShape2;
ModelRenderer verticalShape3;
ModelRenderer verticalShape4;
ModelRenderer horriz2Shape1;
ModelRenderer horriz2Shape2;
ModelRenderer horriz2Shape3;
ModelRenderer horriz2Shape4;
public ModelPipe()
{
textureWidth = 16;
textureHeight = 16;
horrizShape1 = new ModelRenderer(this, 0, 0);
horrizShape1.addBox(0F, 0F, 0F, 16, 1, 1);
horrizShape1.setRotationPoint(-8F, 18F, 2F);
horrizShape1.setTextureSize(64, 32);
horrizShape1.mirror = true;
setRotation(horrizShape1, 0F, 0F, 0F);
horrizShape2 = new ModelRenderer(this, 0, 0);
horrizShape2.addBox(0F, 0F, 0F, 16, 1, 1);
horrizShape2.setRotationPoint(-8F, 18F, -3F);
horrizShape2.setTextureSize(64, 32);
horrizShape2.mirror = true;
setRotation(horrizShape2, 0F, 0F, 0F);
horrizShape3 = new ModelRenderer(this, 0, 0);
horrizShape3.addBox(0F, 0F, 0F, 16, 1, 1);
horrizShape3.setRotationPoint(-8F, 13F, 2F);
horrizShape3.setTextureSize(64, 32);
horrizShape3.mirror = true;
setRotation(horrizShape3, 0F, 0F, 0F);
horrizShape4 = new ModelRenderer(this, 0, 0);
horrizShape4.addBox(0F, 0F, 0F, 16, 1, 1);
horrizShape4.setRotationPoint(-8F, 13F, -3F);
horrizShape4.setTextureSize(64, 32);
horrizShape4.mirror = true;
setRotation(horrizShape4, 0F, 0F, 0F);
verticalShape1 = new ModelRenderer(this, 0, 0);
verticalShape1.addBox(0F, 0F, 0F, 1, 16, 1);
verticalShape1.setRotationPoint(-3F, 8F, 2F);
verticalShape1.setTextureSize(64, 32);
verticalShape1.mirror = true;
setRotation(verticalShape1, 0F, 0F, 0F);
verticalShape2 = new ModelRenderer(this, 0, 0);
verticalShape2.addBox(0F, 0F, 0F, 1, 16, 1);
verticalShape2.setRotationPoint(2F, 8F, 2F);
verticalShape2.setTextureSize(64, 32);
verticalShape2.mirror = true;
setRotation(verticalShape2, 0F, 0F, 0F);
verticalShape3 = new ModelRenderer(this, 0, 0);
verticalShape3.addBox(0F, 0F, 0F, 1, 16, 1);
verticalShape3.setRotationPoint(-3F, 8F, -3F);
verticalShape3.setTextureSize(64, 32);
verticalShape3.mirror = true;
setRotation(verticalShape3, 0F, 0F, 0F);
verticalShape4 = new ModelRenderer(this, 0, 0);
verticalShape4.addBox(0F, 0F, 0F, 1, 16, 1);
verticalShape4.setRotationPoint(2F, 8F, -3F);
verticalShape4.setTextureSize(64, 32);
verticalShape4.mirror = true;
setRotation(verticalShape1, 0F, 0F, 0F);
horriz2Shape1 = new ModelRenderer(this, 0, 0);
horriz2Shape1.addBox(0F, 0F, 0F, 1, 1, 16);
horriz2Shape1.setRotationPoint(-3F, 18F, -8F);
horriz2Shape1.setTextureSize(64, 32);
horriz2Shape1.mirror = true;
setRotation(horriz2Shape1, 0F, 0F, 0F);
horriz2Shape2 = new ModelRenderer(this, 0, 0);
horriz2Shape2.addBox(0F, 0F, 0F, 1, 1, 16);
horriz2Shape2.setRotationPoint(2F, 18F, -8F);
horriz2Shape2.setTextureSize(64, 32);
horriz2Shape2.mirror = true;
setRotation(horriz2Shape2, 0F, 0F, 0F);
horriz2Shape3 = new ModelRenderer(this, 0, 0);
horriz2Shape3.addBox(0F, 0F, 0F, 1, 1, 16);
horriz2Shape3.setRotationPoint(-3F, 13F, -8F);
horriz2Shape3.setTextureSize(64, 32);
horriz2Shape3.mirror = true;
setRotation(horriz2Shape3, 0F, 0F, 0F);
horriz2Shape4 = new ModelRenderer(this, 0, 0);
horriz2Shape4.addBox(0F, 0F, 0F, 1, 1, 16);
horriz2Shape4.setRotationPoint(2F, 13F, -8F);
horriz2Shape4.setTextureSize(64, 32);
horriz2Shape4.mirror = true;
setRotation(horriz2Shape4, 0F, 0F, 0F);
}
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
super.render(entity, f, f1, f2, f3, f4, f5);
setRotationAngles(f, f1, f2, f3, f4, f5, entity);
horrizShape1.render(f5);
horrizShape2.render(f5);
horrizShape3.render(f5);
horrizShape4.render(f5);
verticalShape1.render(f5);
verticalShape2.render(f5);
verticalShape3.render(f5);
verticalShape4.render(f5);
horriz2Shape1.render(f5);
horriz2Shape2.render(f5);
horriz2Shape3.render(f5);
horriz2Shape4.render(f5);
}
public boolean num1 = false;
public boolean num2 = false;
public boolean num3 = false;
/*
* attempt to make a neighbor checking function
*/
public void testRun(){
System.out.println("RunTest positive");
}
public void checkForNeighbors(World world, int x, int y, int z) {
System.out.println("test run positive");
if (world.getBlock(x - 1, y, z) == GunnCraftBlocks.Pipe){
num1 = true;
System.out.println("tested block true");
}
if (world.getBlock(x + 1, y, z) == GunnCraftBlocks.Pipe){
num1 = true;
System.out.println("tested block true");
}
if (world.getBlock(x, y - 1, z) == GunnCraftBlocks.Pipe){
num2 = true;
System.out.println("tested block true");
}
if (world.getBlock(x, y + 1, z) == GunnCraftBlocks.Pipe){
num2 = true;
System.out.println("tested block true");
}
if (world.getBlock(x, y, z - 1) == GunnCraftBlocks.Pipe){
num3 = true;
System.out.println("tested block true");
}
if (world.getBlock(x, y, z + 1) == GunnCraftBlocks.Pipe){
num3 = true;
System.out.println("tested block true");
}
}
public void shouldRenderModel1(float f5){
if(num1 == false){
horrizShape1.render(f5);
horrizShape2.render(f5);
horrizShape3.render(f5);
horrizShape4.render(f5);
}
}
public void shouldRenderModel2(float f5){
if(num2 == true){
verticalShape1.render(f5);
verticalShape2.render(f5);
verticalShape3.render(f5);
verticalShape4.render(f5);
}
}
public void shouldRenderModel3(float f5){
if(num3 == true){
horriz2Shape1.render(f5);
horriz2Shape2.render(f5);
horriz2Shape3.render(f5);
horriz2Shape4.render(f5);
}
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)
{
super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
}
public void checkForNeighbors(World worldObj, double x, double y, double z) {
}
}
RenderPipe class:
package com.gunnthorian.renderer;
import org.lwjgl.opengl.GL11;
import com.gunnthorian.block.Pipe;
import com.gunnthorian.lib.RefStrings;
import com.gunnthorian.model.ModelPipe;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public class RenderPipe extends TileEntitySpecialRenderer{
ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/models/Pipe.png");
private ModelPipe model;
private Pipe Pipe;
public RenderPipe(){
this.model = new ModelPipe();
}
public void renderTileEntityAt(TileEntity entity, double x, double y, double z, float F) {
GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
GL11.glRotatef(180, 0F, 0F, 1F);
this.bindTexture(texture);
GL11.glPushMatrix();
this.model.testRun();
this.model.checkForNeighbors(entity.getWorldObj(), x, y, z);
this.model.shouldRenderModel1(0.0625F);
this.model.shouldRenderModel2(0.0625F);
this.model.shouldRenderModel3(0.0625F);
GL11.glPopMatrix();
GL11.glPopMatrix();
}
}
Console:
[08:15:29] [Client thread/INFO] [STDOUT]: [com.gunnthorian.model.ModelPipe:testRun:138]: RunTest positive
[08:15:29] [Client thread/INFO] [STDOUT]: [com.gunnthorian.model.ModelPipe:testRun:138]: RunTest positive
[08:15:29] [Client thread/INFO] [STDOUT]: [com.gunnthorian.model.ModelPipe:testRun:138]: RunTest positive
[08:15:29] [Client thread/INFO] [STDOUT]: [com.gunnthorian.model.ModelPipe:testRun:138]: RunTest positive
[08:15:29] [Client thread/INFO] [STDOUT]: [com.gunnthorian.model.ModelPipe:testRun:138]: RunTest positive
[08:15:29] [Client thread/INFO] [STDOUT]: [com.gunnthorian.model.ModelPipe:testRun:138]: RunTest positive
help please
0
its not working the checkForNeighbors is never being ran, why can that be?
0
thanks for the response, but that poses a new problem. My world.getBlock(x + 1, y, z) == GunnCraftBlocks.Pipe) have errors under getBlock only options are to change it to getBlockMetadata and isAirBlock
i believe you just helped me with the other post that was basically tied to this just simplified a specific question
0
I'm running a function: renderTileEntityAt(TileEntity entity, double x, double y, double z, float F)
and under that I also need to run: this.model.checkForNeighbors(entity.getWorld(), x, y, z)
however entity.getWorld() isn't a thing so I need help trying to find out how to get the world parameter necessary with using the entity one given.
Code:
public void renderTileEntityAt(TileEntity entity, double x, double y, double z, float F) {
GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
GL11.glRotatef(180, 0F, 0F, 1F);
this.bindTexture(texture);
this.model.checkForNeighbors(entity.getWorld(), x, y, z);
GL11.glPushMatrix();
this.model.shouldRenderModel1(0.0625F);
this.model.shouldRenderModel2(0.0625F);
this.model.shouldRenderModel3(0.0625F);
GL11.glPopMatrix();
GL11.glPopMatrix();
}
Any suggestions or help would be greatly appreciated!
Thanks!
0
Can you make the block land as a normal block, like sand does so it fills the hole?
0
what do I have to change for RenderPipe to run checkForNeighbors() and run this.model.renderModel1(0.0625F); depending on the results
Model Pipe:
package com.gunnthorian.model;
import java.util.Random;
import com.gunnthorian.block.GunnCraftBlocks;
import com.gunnthorian.block.Pipe;
import com.gunnthorian.renderer.RenderPipe;
import net.minecraft.block.Block;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class ModelPipe extends ModelBase{
private static final TileEntity TileEntity = null;
private static final float F = 0;
//fields
ModelRenderer horrizShape1;
ModelRenderer horrizShape2;
ModelRenderer horrizShape3;
ModelRenderer horrizShape4;
ModelRenderer verticalShape1;
ModelRenderer verticalShape2;
ModelRenderer verticalShape3;
ModelRenderer verticalShape4;
ModelRenderer horriz2Shape1;
ModelRenderer horriz2Shape2;
ModelRenderer horriz2Shape3;
ModelRenderer horriz2Shape4;
public ModelPipe()
{
textureWidth = 16;
textureHeight = 16;
horrizShape1 = new ModelRenderer(this, 0, 0);
horrizShape1.addBox(0F, 0F, 0F, 16, 1, 1);
horrizShape1.setRotationPoint(-8F, 18F, 2F);
horrizShape1.setTextureSize(64, 32);
horrizShape1.mirror = true;
setRotation(horrizShape1, 0F, 0F, 0F);
horrizShape2 = new ModelRenderer(this, 0, 0);
horrizShape2.addBox(0F, 0F, 0F, 16, 1, 1);
horrizShape2.setRotationPoint(-8F, 18F, -3F);
horrizShape2.setTextureSize(64, 32);
horrizShape2.mirror = true;
setRotation(horrizShape2, 0F, 0F, 0F);
horrizShape3 = new ModelRenderer(this, 0, 0);
horrizShape3.addBox(0F, 0F, 0F, 16, 1, 1);
horrizShape3.setRotationPoint(-8F, 13F, 2F);
horrizShape3.setTextureSize(64, 32);
horrizShape3.mirror = true;
setRotation(horrizShape3, 0F, 0F, 0F);
horrizShape4 = new ModelRenderer(this, 0, 0);
horrizShape4.addBox(0F, 0F, 0F, 16, 1, 1);
horrizShape4.setRotationPoint(-8F, 13F, -3F);
horrizShape4.setTextureSize(64, 32);
horrizShape4.mirror = true;
setRotation(horrizShape4, 0F, 0F, 0F);
verticalShape1 = new ModelRenderer(this, 0, 0);
verticalShape1.addBox(0F, 0F, 0F, 1, 16, 1);
verticalShape1.setRotationPoint(-3F, 8F, 2F);
verticalShape1.setTextureSize(64, 32);
verticalShape1.mirror = true;
setRotation(verticalShape1, 0F, 0F, 0F);
verticalShape2 = new ModelRenderer(this, 0, 0);
verticalShape2.addBox(0F, 0F, 0F, 1, 16, 1);
verticalShape2.setRotationPoint(2F, 8F, 2F);
verticalShape2.setTextureSize(64, 32);
verticalShape2.mirror = true;
setRotation(verticalShape2, 0F, 0F, 0F);
verticalShape3 = new ModelRenderer(this, 0, 0);
verticalShape3.addBox(0F, 0F, 0F, 1, 16, 1);
verticalShape3.setRotationPoint(-3F, 8F, -3F);
verticalShape3.setTextureSize(64, 32);
verticalShape3.mirror = true;
setRotation(verticalShape3, 0F, 0F, 0F);
verticalShape4 = new ModelRenderer(this, 0, 0);
verticalShape4.addBox(0F, 0F, 0F, 1, 16, 1);
verticalShape4.setRotationPoint(2F, 8F, -3F);
verticalShape4.setTextureSize(64, 32);
verticalShape4.mirror = true;
setRotation(verticalShape1, 0F, 0F, 0F);
horriz2Shape1 = new ModelRenderer(this, 0, 0);
horriz2Shape1.addBox(0F, 0F, 0F, 1, 1, 16);
horriz2Shape1.setRotationPoint(-3F, 18F, -8F);
horriz2Shape1.setTextureSize(64, 32);
horriz2Shape1.mirror = true;
setRotation(horriz2Shape1, 0F, 0F, 0F);
horriz2Shape2 = new ModelRenderer(this, 0, 0);
horriz2Shape2.addBox(0F, 0F, 0F, 1, 1, 16);
horriz2Shape2.setRotationPoint(2F, 18F, -8F);
horriz2Shape2.setTextureSize(64, 32);
horriz2Shape2.mirror = true;
setRotation(horriz2Shape2, 0F, 0F, 0F);
horriz2Shape3 = new ModelRenderer(this, 0, 0);
horriz2Shape3.addBox(0F, 0F, 0F, 1, 1, 16);
horriz2Shape3.setRotationPoint(-3F, 13F, -8F);
horriz2Shape3.setTextureSize(64, 32);
horriz2Shape3.mirror = true;
setRotation(horriz2Shape3, 0F, 0F, 0F);
horriz2Shape4 = new ModelRenderer(this, 0, 0);
horriz2Shape4.addBox(0F, 0F, 0F, 1, 1, 16);
horriz2Shape4.setRotationPoint(2F, 13F, -8F);
horriz2Shape4.setTextureSize(64, 32);
horriz2Shape4.mirror = true;
setRotation(horriz2Shape4, 0F, 0F, 0F);
}
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
super.render(entity, f, f1, f2, f3, f4, f5);
setRotationAngles(f, f1, f2, f3, f4, f5, entity);
horrizShape1.render(f5);
horrizShape2.render(f5);
horrizShape3.render(f5);
horrizShape4.render(f5);
verticalShape1.render(f5);
verticalShape2.render(f5);
verticalShape3.render(f5);
verticalShape4.render(f5);
horriz2Shape1.render(f5);
horriz2Shape2.render(f5);
horriz2Shape3.render(f5);
horriz2Shape4.render(f5);
}
public boolean num1 = false;
public boolean num2 = false;
public boolean num3 = false;
/*
* attempt to make a neighbor checking function
*/
public void checkForNeighbors(World world, int x, int y, int z) {
if (world.getBlock(x - 1, y, z) == GunnCraftBlocks.Pipe){
num1 = true;
}
if (world.getBlock(x + 1, y, z) == GunnCraftBlocks.Pipe){
num1 = true;
}
if (world.getBlock(x, y - 1, z) == GunnCraftBlocks.Pipe){
num2 = true;
}
if (world.getBlock(x, y + 1, z) == GunnCraftBlocks.Pipe){
num2 = true;
}
if (world.getBlock(x, y, z - 1) == GunnCraftBlocks.Pipe){
num3 = true;
}
if (world.getBlock(x, y, z + 1) == GunnCraftBlocks.Pipe){
num3 = true;
}
}
public void shouldRenderModel1(float f5){
if(num1 == true){
horrizShape1.render(f5);
horrizShape2.render(f5);
horrizShape3.render(f5);
horrizShape4.render(f5);
}
}
public void shouldRenderModel2(float f5){
if(num2 == true){
verticalShape1.render(f5);
verticalShape2.render(f5);
verticalShape3.render(f5);
verticalShape4.render(f5);
}
}
public void shouldRenderModel3(float f5){
if(num3 == true){
horriz2Shape1.render(f5);
horriz2Shape2.render(f5);
horriz2Shape3.render(f5);
horriz2Shape4.render(f5);
}
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)
{
super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
}
}
RenderPipe:
package com.gunnthorian.renderer;
import org.lwjgl.opengl.GL11;
import com.gunnthorian.block.Pipe;
import com.gunnthorian.lib.RefStrings;
import com.gunnthorian.model.ModelPipe;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public class RenderPipe extends TileEntitySpecialRenderer{
ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/models/Pipe.png");
private ModelPipe model;
private Pipe Pipe;
public RenderPipe(){
this.model = new ModelPipe();
}
public void renderTileEntityAt(TileEntity entity, double x, double y, double z, float F) {
GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
GL11.glRotatef(180, 0F, 0F, 1F);
this.bindTexture(texture);
GL11.glPushMatrix();
this.model.shouldRenderModel1(0.0625F);
this.model.shouldRenderModel2(0.0625F);
this.model.shouldRenderModel3(0.0625F);
GL11.glPopMatrix();
GL11.glPopMatrix();
}
}
Thanks for the advice sky_01 on changing a few things
0
I would like to make a pipe block/tile entity that can visually connect with other blocks like it, Just like in IC2.
I've made a block, the tile entity, model and render for it. I just need help with the checking its neighbors and rendering the block to look like its connecting.
picture of my pipe now:
http://media-minecraftforum.cursecdn.com/temporary-attachments/232/237/635877083299750065.png (not quite sure how to add a picture)
my code for the Pipe class, ModelPipe, and RenderPipe:
package com.gunnthorian.block;
import java.util.Random;
import com.gunnthorian.creativetabs.GunnCraftCreativeTabs;
import com.gunnthorian.model.ModelPipe;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class Pipe extends</p><p>BlockContainer{
public Pipe() {
super(Material.anvil);
this.setCreativeTab(GunnCraftCreativeTabs.tabGunnCraft);
this.setHardness(5.0F);
this.setResistance(0.5F);
floatvar3 = 0.3125F;
this.setBlockBounds(var3, var3, var3, 1.0F - var3, 1.0F - var3, 1.0F - var3);
}
public int getRenderType(){
return 80;
}
public boolean isOpaqueCube(){
returnfalse;
}
public boolean renderAsNormalBlock(){
returnfalse;
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, intp_149915_2_) {
returnnew TileEntityPipe();
}
}
P
package com.gunnthorian.model;
import java.util.Random;
import com.gunnthorian.block.GunnCraftBlocks;
import com.gunnthorian.block.Pipe;
import com.gunnthorian.renderer.RenderPipe;
import net.minecraft.block.Block;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class ModelPipe extends ModelBase{
privatestaticfinal TileEntity TileEntity = null;
privatestaticfinalfloatF = 0;
//fields
ModelRenderer horrizShape1;
ModelRenderer horrizShape2;
ModelRenderer horrizShape3;
ModelRenderer horrizShape4;
ModelRenderer verticalShape1;
ModelRenderer verticalShape2;
ModelRenderer verticalShape3;
ModelRenderer verticalShape4;
ModelRenderer horriz2Shape1;
ModelRenderer horriz2Shape2;
ModelRenderer horriz2Shape3;
ModelRenderer horriz2Shape4;
public ModelPipe()
{
textureWidth = 16;
textureHeight = 16;
horrizShape1 = new ModelRenderer(this, 0, 0);
horrizShape1.addBox(0F, 0F, 0F, 16, 1, 1);
horrizShape1.setRotationPoint(-8F, 18F, 2F);
horrizShape1.setTextureSize(64, 32);
horrizShape1.mirror = true;
setRotation(horrizShape1, 0F, 0F, 0F);
horrizShape2 = new ModelRenderer(this, 0, 0);
horrizShape2.addBox(0F, 0F, 0F, 16, 1, 1);
horrizShape2.setRotationPoint(-8F, 18F, -3F);
horrizShape2.setTextureSize(64, 32);
horrizShape2.mirror = true;
setRotation(horrizShape2, 0F, 0F, 0F);
horrizShape3 = new ModelRenderer(this, 0, 0);
horrizShape3.addBox(0F, 0F, 0F, 16, 1, 1);
horrizShape3.setRotationPoint(-8F, 13F, 2F);
horrizShape3.setTextureSize(64, 32);
horrizShape3.mirror = true;
setRotation(horrizShape3, 0F, 0F, 0F);
horrizShape4 = new ModelRenderer(this, 0, 0);
horrizShape4.addBox(0F, 0F, 0F, 16, 1, 1);
horrizShape4.setRotationPoint(-8F, 13F, -3F);
horrizShape4.setTextureSize(64, 32);
horrizShape4.mirror = true;
setRotation(horrizShape4, 0F, 0F, 0F);
verticalShape1 = new ModelRenderer(this, 0, 0);
verticalShape1.addBox(0F, 0F, 0F, 1, 16, 1);
verticalShape1.setRotationPoint(-3F, 8F, 2F);
verticalShape1.setTextureSize(64, 32);
verticalShape1.mirror = true;
setRotation(verticalShape1, 0F, 0F, 0F);
verticalShape2 = new ModelRenderer(this, 0, 0);
verticalShape2.addBox(0F, 0F, 0F, 1, 16, 1);
verticalShape2.setRotationPoint(2F, 8F, 2F);
verticalShape2.setTextureSize(64, 32);
verticalShape2.mirror = true;
setRotation(verticalShape2, 0F, 0F, 0F);
verticalShape3 = new ModelRenderer(this, 0, 0);
verticalShape3.addBox(0F, 0F, 0F, 1, 16, 1);
verticalShape3.setRotationPoint(-3F, 8F, -3F);
verticalShape3.setTextureSize(64, 32);
verticalShape3.mirror = true;
setRotation(verticalShape3, 0F, 0F, 0F);
verticalShape4 = new ModelRenderer(this, 0, 0);
verticalShape4.addBox(0F, 0F, 0F, 1, 16, 1);
verticalShape4.setRotationPoint(2F, 8F, -3F);
verticalShape4.setTextureSize(64, 32);
verticalShape4.mirror = true;
setRotation(verticalShape1, 0F, 0F, 0F);
horriz2Shape1 = new ModelRenderer(this, 0, 0);
horriz2Shape1.addBox(0F, 0F, 0F, 1, 1, 16);
horriz2Shape1.setRotationPoint(-3F, 18F, -8F);
horriz2Shape1.setTextureSize(64, 32);
horriz2Shape1.mirror = true;
setRotation(horriz2Shape1, 0F, 0F, 0F);
horriz2Shape2 = new ModelRenderer(this, 0, 0);
horriz2Shape2.addBox(0F, 0F, 0F, 1, 1, 16);
horriz2Shape2.setRotationPoint(2F, 18F, -8F);
horriz2Shape2.setTextureSize(64, 32);
horriz2Shape2.mirror = true;
setRotation(horriz2Shape2, 0F, 0F, 0F);
horriz2Shape3 = new ModelRenderer(this, 0, 0);
horriz2Shape3.addBox(0F, 0F, 0F, 1, 1, 16);
horriz2Shape3.setRotationPoint(-3F, 13F, -8F);
horriz2Shape3.setTextureSize(64, 32);
horriz2Shape3.mirror = true;
setRotation(horriz2Shape3, 0F, 0F, 0F);
horriz2Shape4 = new ModelRenderer(this, 0, 0);
horriz2Shape4.addBox(0F, 0F, 0F, 1, 1, 16);
horriz2Shape4.setRotationPoint(2F, 13F, -8F);
horriz2Shape4.setTextureSize(64, 32);
horriz2Shape4.mirror = true;
setRotation(horriz2Shape4, 0F, 0F, 0F);
}
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
super.render(entity, f, f1, f2, f3, f4, f5);
setRotationAngles(f, f1, f2, f3, f4, f5, entity);
horrizShape1.render(f5);
horrizShape2.render(f5);
horrizShape3.render(f5);
horrizShape4.render(f5);
verticalShape1.render(f5);
verticalShape2.render(f5);
verticalShape3.render(f5);
verticalShape4.render(f5);
horriz2Shape1.render(f5);
horriz2Shape2.render(f5);
horriz2Shape3.render(f5);
horriz2Shape4.render(f5);
}
public int num1 = 1;
public int num2 = 1;
public int num3 = 1;
/*
* attempt to make a neighbor checking function
*/
public void checkForNeighbors(World world, int x, int y, int z, Random par5Random) {
if (world.getBlock(x - 1, y, z) == GunnCraftBlocks.Pipe){
num1 = 1;
}
if (world.getBlock(x + 1, y, z) == GunnCraftBlocks.Pipe){
num1 = 1;
}
if (world.getBlock(x, y - 1, z) == GunnCraftBlocks.Pipe){
num2 = 1;
}
if (world.getBlock(x, y + 1, z) == GunnCraftBlocks.Pipe){
num2 = 1;
}
if (world.getBlock(x, y, z - 1) == GunnCraftBlocks.Pipe){
num3 = 1;
}
if (world.getBlock(x, y, z + 1) == GunnCraftBlocks.Pipe){
num3 = 1;
}
}
public void renderModel1(float f5){
if(num1 == 1){
horrizShape1.render(f5);
horrizShape2.render(f5);
horrizShape3.render(f5);
horrizShape4.render(f5);
}
}
public void renderModel2(float f5){
if(num2 == 1){
verticalShape1.render(f5);
verticalShape2.render(f5);
verticalShape3.render(f5);
verticalShape4.render(f5);
}
}
public void renderModel3(float f5){
if(num3 == 1){
horriz2Shape1.render(f5);
horriz2Shape2.render(f5);
horriz2Shape3.render(f5);
horriz2Shape4.render(f5);
}
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)
{
super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
}
}
package com.gunnthorian.renderer;
import org.lwjgl.opengl.GL11;
import com.gunnthorian.block.Pipe;
import com.gunnthorian.lib.RefStrings;
import com.gunnthorian.model.ModelPipe;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
public class RenderPipe extends TileEntitySpecialRenderer{
ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/models/Pipe.png");
private ModelPipe model;
public RenderPipe(){
this.model = new ModelPipe();
}
@Override
publicvoid renderTileEntityAt(TileEntity entity, doublex, doubley, doublez, floatF) {
GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
GL11.glRotatef(180, 0F, 0F, 1F);
this.bindTexture(texture);
GL11.glPushMatrix();
this.model.renderModel1(0.0625F);
this.model.renderModel2(0.0625F);
this.model.renderModel3(0.0625F);
GL11.glPopMatrix();
GL11.glPopMatrix();
}
}
Hope some one could help! Thanks!
0
0
0
0
0
0
0
0