P.S. I modified checkForNeighbors to take the tile world and coords because pass other coords wouldn't make any sense considering it saves the vars into an instance of tile
except this ^ didn't know what coords or integers (still relatively new to modding)
however when I place a single pipe it renders as it should (rendering only this.model.shouldRenderMiddle(0.0625F)) but when I place the second it crashes
console -- Head -- Stacktrace:
at com.gunnthorian.block.TileEntityPipe.sync(TileEntityPipe.java:84)
at com.gunnthorian.block.TileEntityPipe.checkForNeighbors(TileEntityPipe.java:61)
at com.gunnthorian.block.Pipe.onNeighborBlockChange(Pipe.java:31)
@Override
public Packet getDescriptionPacket(){
return null;
}
public void onDataPacket(){
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
markDirty();
}
public boolean num1 = false;
public boolean num2 = false;
public boolean num3 = false;
public boolean num4 = false;
public boolean num5 = false;
public boolean num6 = false;
public void checkForNeighbors(World world, int x, int y, int z) {
if (world.getBlock(x - 1, y, z) == GunnCraftBlocks.Pipe){
num1 = true;
System.out.println("tested block left true");
}
if (world.getBlock(x + 1, y, z) == GunnCraftBlocks.Pipe){
num2 = true;
System.out.println("tested block right true");
}
if (world.getBlock(x, y, z - 1) == GunnCraftBlocks.Pipe){
num3 = true;
System.out.println("tested block front true");
}
if (world.getBlock(x, y, z + 1) == GunnCraftBlocks.Pipe){
num4 = true;
System.out.println("tested block back true");
}
if (world.getBlock(x, y + 1, z) == GunnCraftBlocks.Pipe){
num5 = true;
System.out.println("tested block top true");
}
if (world.getBlock(x, y - 1, z) == GunnCraftBlocks.Pipe){
num6 = true;
System.out.println("tested block bottom true");
}
}
}
If anyone could figure this out it would be greatly appreciated!
Im not too sure how to make packets, what I've made so far changes all of the tileentities
In the below attachments you can see that the pipes are treated as a whole not individually when being rendered - any help on this would be nice (not sure if this is related to the packets)
public boolean num1 = false;
public boolean num2 = false;
public boolean num3 = false;
public boolean num4 = false;
public boolean num5 = false;
public boolean num6 = false;
public void checkForNeighbors(World world, int x, int y, int z) {
if (world.getBlock(x - 1, y, z) == GunnCraftBlocks.Pipe){
num1 = true;
System.out.println("tested block left true");
}
if (world.getBlock(x + 1, y, z) == GunnCraftBlocks.Pipe){
num2 = true;
System.out.println("tested block right true");
}
if (world.getBlock(x, y, z - 1) == GunnCraftBlocks.Pipe){
num3 = true;
System.out.println("tested block front true");
}
if (world.getBlock(x, y, z + 1) == GunnCraftBlocks.Pipe){
num4 = true;
System.out.println("tested block back true");
}
if (world.getBlock(x, y + 1, z) == GunnCraftBlocks.Pipe){
num5 = true;
System.out.println("tested block top true");
}
if (world.getBlock(x, y - 1, z) == GunnCraftBlocks.Pipe){
num6 = true;
System.out.println("tested block bottom true");
}
}
public void shouldRenderMiddle(float f5){
middle.render(f5);
}
public void shouldRenderLeft(float f5){
if(num1 == true){
left.render(f5);
}
}
public void shouldRenderRight(float f5){
if(num2 == true){
right.render(f5);
}
}
public void shouldRenderFront(float f5){
if(num3 == true){
front.render(f5);
}
}
public void shouldRenderBack(float f5){
if(num4 == true){
back.render(f5);
}
}
public void shouldRenderTop(float f5){
if(num5 == true){
top.render(f5);
}
}
public void shouldRenderBottom(float f5){
if(num6 == true){
bottom.render(f5);
}
}
when I place only two down in the world it test each other positive (good news) and only that so the testing works and everything but it just renders it as if every side is positive (like in the picture at the beginning of the thread)
I have it running the right function now however the only problem is the getBlock under checkForNeighbors is always returning true. Even the ones that don't have a pipe next to them
What would I have to do in order to call the right one, I'm really new to modding, I thought that something on the lines of that was the problem thanks for the reply
0
no its not rendering them properly, the ModelPipe class is never receiving the num1-6 values
----- oh my bad lol
0
Okay, so now minecraft doesn't crash when the pipes update but the num1-6 values aren't there when the block gets rendered
0
I placed the
under my
Is the MainRegistry setup properly
package com.gunnthorian.Main;
import com.gunnthorian.block.GunnCraftBlocks;
import com.gunnthorian.creativetabs.GunnCraftCreativeTabs;
import com.gunnthorian.handler.MessagesHandler;
import com.gunnthorian.item.GunnCraftItems;
import com.gunnthorian.lib.RefStrings;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import net.minecraft.client.main.Main;
@Mod(modid = RefStrings.MODID, name = RefStrings.NAME, version = RefStrings.VERSION)
public class MainRegistry {
@SidedProxy(clientSide = RefStrings.CLEINTSIDEPROXY, serverSide = RefStrings.SERVERSIDEPROXY)
public static ServerProxy proxy;
/*@Instance("gunncraft")
public static MainRegistry instance;*/
@Instance
public static MainRegistry instance = new MainRegistry();
@EventHandler
public static void PreLoad(FMLPreInitializationEvent PreEvent){
GunnCraftCreativeTabs.initialiseTabs();
GunnCraftBlocks.mainRegistry();
GunnCraftItems.mainRegistry();
CraftingManager.mainRegistry();
MessagesHandler.registerPackets();
proxy.registerRenderInfo();
}
public void init(FMLInitializationEvent e) {
NetworkRegistry.INSTANCE.newSimpleChannel(((Mod) Main.class.getAnnotation(Mod.class)).modid());
}
@EventHandler
public static void Load(FMLInitializationEvent Event){
LanguageRegistry.instance().addStringLocalization("itemGroup.tabGunnCraft", "en_US", "tabgunncraft");
}
@EventHandler
public static void PostLoad(FMLPostInitializationEvent PostEvent){
}
}
0
pastern url:
http://pastebin.com/bLLB7fEU
0
So I did all of this
except this ^ didn't know what coords or integers (still relatively new to modding)
however when I place a single pipe it renders as it should (rendering only this.model.shouldRenderMiddle(0.0625F)) but when I place the second it crashes
console -- Head -- Stacktrace:
0
no errors yay! I only had to change some
message.readbytes.readInt()
to:
message.readbytes.readBoolean()
but the pipes still don't render the booleans are still all false
0
I have the following errors in my code:
package com.gunnthorian.block;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.network.Packet;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class TileEntityPipe extends TileEntity {
@Override
public Packet getDescriptionPacket(){
returnnull;
}
publicvoid onDataPacket(){
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
markDirty();
}
publicbooleannum1 = false;
publicbooleannum2 = false;
publicbooleannum3 = false;
publicbooleannum4 = false;
publicbooleannum5 = false;
publicbooleannum6 = false;
publicvoid checkForNeighbors(World world, intx, inty, intz) {
if (world.getBlock(x - 1, y, z) == GunnCraftBlocks.Pipe){
num1 = true;
System.out.println("tested block left true");
}
if (world.getBlock(x + 1, y, z) == GunnCraftBlocks.Pipe){
num2 = true;
System.out.println("tested block right true");
}
if (world.getBlock(x, y, z - 1) == GunnCraftBlocks.Pipe){
num3 = true;
System.out.println("tested block front true");
}
if (world.getBlock(x, y, z + 1) == GunnCraftBlocks.Pipe){
num4 = true;
System.out.println("tested block back true");
}
if (world.getBlock(x, y + 1, z) == GunnCraftBlocks.Pipe){
num5 = true;
System.out.println("tested block top true");
}
if (world.getBlock(x, y - 1, z) == GunnCraftBlocks.Pipe){
num6 = true;
System.out.println("tested block bottom true");
}
}
publicvoid sync() {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream outputStream = new DataOutputStream(bos);
try {
outputStream.writeInt(this.xCoord);
outputStream.writeInt(this.yCoord);
outputStream.writeInt(this.zCoord);
outputStream.writeBoolean(this.num1);
outputStream.writeBoolean(this.num2);
outputStream.writeBoolean(this.num3);
outputStream.writeBoolean(this.num4);
outputStream.writeBoolean(this.num5);
outputStream.writeBoolean(this.num6);
} catch (Exception ex) {
ex.printStackTrace();
}
if (this.worldObj != null && this.worldObj.provider != null) {
MessagesHandler.dispatcher.sendToAllAround(new MessageSyncTile(bos), new TargetPoint(this.worldObj.provider.dimensionId, this.xCoord, this.yCoord, this.zCoord, 8));
}
}
}
publicvoid recieveSync(booleanpar1, booleanpar2, booleanpar3, booleanpar4, booleanpar5, booleanpar6) {
this.num1 = par1;
this.num2 = par2;
this.num3 = par3;
this.num4 = par4;
this.num5 = par5;
this.num6 = par6;
}
}
package com.gunnthorian.handler;
import java.io.IOException;
import com.gunnthorian.block.TileEntityPipe;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
public static class Handler implements IMessageHandler<MessageSyncTile, IMessage> {
@Override
public IMessage onMessage(MessageSyncTile message, MessageContext ctx) {
if (!FMLCommonHandler.instance().getEffectiveSide().isClient())
returnnull;
try {
TileEntityPipe tep = (TileEntityPipe) FMLClientHandler.instance()
.getClientPlayerEntity().worldObj.getTileEntity(message.readbytes.readInt(),
message.readbytes.readInt(), message.readbytes.readInt());
if (tep != null) {
tep.recieveSync(message.readbytes.readInt(), message.readbytes.readInt(), message.readbytes.readInt(), message.readbytes.readInt(), message.readbytes.readInt(), message.readbytes.readInt());
}
} catch (IOException e) {
e.printStackTrace();
}
returnnull;
}
}
I'm having a hard time trying to figure out packets, thank you for the reply and coming up with the code for this!
--hopefully I edited it time before you read this, I had posted old code in one of the spoilers -- fixed now
0
why are the boolean value outputs from TileEntityPipe all false when they are tested in ModelPipe?
ModelPipe:
package com.gunnthorian.model;
import java.util.Random;
import com.gunnthorian.block.GunnCraftBlocks;
import com.gunnthorian.block.Pipe;
import com.gunnthorian.block.TileEntityPipe;
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 middle;
ModelRenderer left;
ModelRenderer right;
ModelRenderer front;
ModelRenderer back;
ModelRenderer top;
ModelRenderer bottom;
public ModelPipe()
{
textureWidth = 32;
textureHeight = 32;
middle = new ModelRenderer(this, 0, 0);
middle.addBox(0F, 0F, 0F, 6, 6, 6);
middle.setRotationPoint(-3F, 13F, -3F);
middle.setTextureSize(32, 32);
middle.mirror = true;
setRotation(middle, 0F, 0F, 0F);
left = new ModelRenderer(this, 0, 12);
left.addBox(0F, 0F, 0F, 5, 6, 6);
left.setRotationPoint(3F, 13F, -3F);
left.setTextureSize(32, 32);
left.mirror = true;
setRotation(left, 0F, 0F, 0F);
right = new ModelRenderer(this, 0, 12);
right.addBox(0F, 0F, 0F, 5, 6, 6);
right.setRotationPoint(-3F, 13F, 3F);
right.setTextureSize(32, 32);
right.mirror = true;
setRotation(right, 0F, -3.141593F, 0F);
front = new ModelRenderer(this, 0, 12);
front.addBox(0F, 0F, 0F, 5, 6, 6);
front.setRotationPoint(-3F, 13F, -3F);
front.setTextureSize(32, 32);
front.mirror = true;
setRotation(front, 0F, 1.570796F, 0F);
back = new ModelRenderer(this, 0, 12);
back.addBox(0F, 0F, 0F, 5, 6, 6);
back.setRotationPoint(3F, 13F, 3F);
back.setTextureSize(32, 32);
back.mirror = true;
setRotation(back, 0F, -1.570796F, 0F);
top = new ModelRenderer(this, 0, 12);
top.addBox(0F, 0F, 0F, 5, 6, 6);
top.setRotationPoint(-3F, 13F, -3F);
top.setTextureSize(32, 32);
top.mirror = true;
setRotation(top, 0F, 0F, -1.570796F);
bottom = new ModelRenderer(this, 0, 12);
bottom.addBox(0F, 0F, 0F, 5, 6, 6);
bottom.setRotationPoint(3F, 19F, -3F);
bottom.setTextureSize(32, 32);
bottom.mirror = true;
setRotation(bottom, 0F, 0F, 1.570796F);
}
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);
middle.render(f5);
left.render(f5);
right.render(f5);
front.render(f5);
back.render(f5);
top.render(f5);
bottom.render(f5);
}
TileEntityPipe tileentity = new TileEntityPipe();
boolean num1 = tileentity.num1;
boolean num2 = tileentity.num2;
boolean num3 = tileentity.num3;
boolean num4 = tileentity.num4;
boolean num5 = tileentity.num5;
boolean num6 = tileentity.num6;
public void shouldRenderMiddle(float f5){
middle.render(f5);
System.out.println(num1 + "," + num2 + "," + num3 + "," + num4 + "," + num5 + "," + num6);
}
public void shouldRenderLeft(float f5){
if(num1 == true){
left.render(f5);
}
}
public void shouldRenderRight(float f5){
if(num2 == true){
right.render(f5);
}
}
public void shouldRenderFront(float f5){
if(num3 == true){
front.render(f5);
}
}
public void shouldRenderBack(float f5){
if(num4 == true){
back.render(f5);
}
}
public void shouldRenderTop(float f5){
if(num5 == true){
top.render(f5);
}
}
public void shouldRenderBottom(float f5){
if(num6 == true){
bottom.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);
}
}
TileEntityPipe:
package com.gunnthorian.block;
import net.minecraft.network.Packet;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class TileEntityPipe extends TileEntity {
@Override
public Packet getDescriptionPacket(){
return null;
}
public void onDataPacket(){
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
markDirty();
}
public boolean num1 = false;
public boolean num2 = false;
public boolean num3 = false;
public boolean num4 = false;
public boolean num5 = false;
public boolean num6 = false;
public void checkForNeighbors(World world, int x, int y, int z) {
if (world.getBlock(x - 1, y, z) == GunnCraftBlocks.Pipe){
num1 = true;
System.out.println("tested block left true");
}
if (world.getBlock(x + 1, y, z) == GunnCraftBlocks.Pipe){
num2 = true;
System.out.println("tested block right true");
}
if (world.getBlock(x, y, z - 1) == GunnCraftBlocks.Pipe){
num3 = true;
System.out.println("tested block front true");
}
if (world.getBlock(x, y, z + 1) == GunnCraftBlocks.Pipe){
num4 = true;
System.out.println("tested block back true");
}
if (world.getBlock(x, y + 1, z) == GunnCraftBlocks.Pipe){
num5 = true;
System.out.println("tested block top true");
}
if (world.getBlock(x, y - 1, z) == GunnCraftBlocks.Pipe){
num6 = true;
System.out.println("tested block bottom true");
}
}
}
If anyone could figure this out it would be greatly appreciated!
0
Im not too sure how to make packets, what I've made so far changes all of the tileentities
In the below attachments you can see that the pipes are treated as a whole not individually when being rendered - any help on this would be nice (not sure if this is related to the packets)
code:
ModelPipe:
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 middle;
ModelRenderer left;
ModelRenderer right;
ModelRenderer front;
ModelRenderer back;
ModelRenderer top;
ModelRenderer bottom;
public ModelPipe()
{
textureWidth = 32;
textureHeight = 32;
middle = new ModelRenderer(this, 0, 0);
middle.addBox(0F, 0F, 0F, 6, 6, 6);
middle.setRotationPoint(-3F, 13F, -3F);
middle.setTextureSize(32, 32);
middle.mirror = true;
setRotation(middle, 0F, 0F, 0F);
left = new ModelRenderer(this, 0, 12);
left.addBox(0F, 0F, 0F, 5, 6, 6);
left.setRotationPoint(3F, 13F, -3F);
left.setTextureSize(32, 32);
left.mirror = true;
setRotation(left, 0F, 0F, 0F);
right = new ModelRenderer(this, 0, 12);
right.addBox(0F, 0F, 0F, 5, 6, 6);
right.setRotationPoint(-3F, 13F, 3F);
right.setTextureSize(32, 32);
right.mirror = true;
setRotation(right, 0F, -3.141593F, 0F);
front = new ModelRenderer(this, 0, 12);
front.addBox(0F, 0F, 0F, 5, 6, 6);
front.setRotationPoint(-3F, 13F, -3F);
front.setTextureSize(32, 32);
front.mirror = true;
setRotation(front, 0F, 1.570796F, 0F);
back = new ModelRenderer(this, 0, 12);
back.addBox(0F, 0F, 0F, 5, 6, 6);
back.setRotationPoint(3F, 13F, 3F);
back.setTextureSize(32, 32);
back.mirror = true;
setRotation(back, 0F, -1.570796F, 0F);
top = new ModelRenderer(this, 0, 12);
top.addBox(0F, 0F, 0F, 5, 6, 6);
top.setRotationPoint(-3F, 13F, -3F);
top.setTextureSize(32, 32);
top.mirror = true;
setRotation(top, 0F, 0F, -1.570796F);
bottom = new ModelRenderer(this, 0, 12);
bottom.addBox(0F, 0F, 0F, 5, 6, 6);
bottom.setRotationPoint(3F, 19F, -3F);
bottom.setTextureSize(32, 32);
bottom.mirror = true;
setRotation(bottom, 0F, 0F, 1.570796F);
}
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);
middle.render(f5);
left.render(f5);
right.render(f5);
front.render(f5);
back.render(f5);
top.render(f5);
bottom.render(f5);
}
public boolean num1 = false;
public boolean num2 = false;
public boolean num3 = false;
public boolean num4 = false;
public boolean num5 = false;
public boolean num6 = false;
public void checkForNeighbors(World world, int x, int y, int z) {
if (world.getBlock(x - 1, y, z) == GunnCraftBlocks.Pipe){
num1 = true;
System.out.println("tested block left true");
}
if (world.getBlock(x + 1, y, z) == GunnCraftBlocks.Pipe){
num2 = true;
System.out.println("tested block right true");
}
if (world.getBlock(x, y, z - 1) == GunnCraftBlocks.Pipe){
num3 = true;
System.out.println("tested block front true");
}
if (world.getBlock(x, y, z + 1) == GunnCraftBlocks.Pipe){
num4 = true;
System.out.println("tested block back true");
}
if (world.getBlock(x, y + 1, z) == GunnCraftBlocks.Pipe){
num5 = true;
System.out.println("tested block top true");
}
if (world.getBlock(x, y - 1, z) == GunnCraftBlocks.Pipe){
num6 = true;
System.out.println("tested block bottom true");
}
}
public void shouldRenderMiddle(float f5){
middle.render(f5);
}
public void shouldRenderLeft(float f5){
if(num1 == true){
left.render(f5);
}
}
public void shouldRenderRight(float f5){
if(num2 == true){
right.render(f5);
}
}
public void shouldRenderFront(float f5){
if(num3 == true){
front.render(f5);
}
}
public void shouldRenderBack(float f5){
if(num4 == true){
back.render(f5);
}
}
public void shouldRenderTop(float f5){
if(num5 == true){
top.render(f5);
}
}
public void shouldRenderBottom(float f5){
if(num6 == true){
bottom.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);
}
}
/*//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;
System.out.println("tested block num1 1 true");
}
if (world.getBlock(x + 1, y, z) == GunnCraftBlocks.Pipe){
num1 = true;
System.out.println("tested block num1 2 true");
}
if (world.getBlock(x, y - 1, z) == GunnCraftBlocks.Pipe){
num2 = true;
System.out.println("tested block num2 1 true");
}
if (world.getBlock(x, y + 1, z) == GunnCraftBlocks.Pipe){
num2 = true;
System.out.println("tested block num2 2 true");
}
if (world.getBlock(x, y, z - 1) == GunnCraftBlocks.Pipe){
num3 = true;
System.out.println("tested block num3 1 true");
}
if (world.getBlock(x, y, z + 1) == GunnCraftBlocks.Pipe){
num3 = true;
System.out.println("tested block num3 2 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;
public RenderPipe(){
this.model = new ModelPipe();
}
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.checkForNeighbors(entity.getWorldObj(), entity.xCoord, entity.yCoord, entity.zCoord);
this.model.shouldRenderMiddle(0.0625F);
this.model.shouldRenderLeft(0.0625F);
this.model.shouldRenderRight(0.0625F);
this.model.shouldRenderFront(0.0625F);
this.model.shouldRenderBack(0.0625F);
this.model.shouldRenderTop(0.0625F);
this.model.shouldRenderBottom(0.0625F);
GL11.glPopMatrix();
GL11.glPopMatrix();
}
}
TileEntityPipe:
package com.gunnthorian.block;
import net.minecraft.network.Packet;
import net.minecraft.tileentity.TileEntity;
public class TileEntityPipe extends TileEntity {
@Override
public Packet getDescriptionPacket(){
returnnull;
}
publicvoid onDataPacket(){
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
markDirty();
}
}
0
To name items:
you need to make a language file, en_US.lang, it will be in assets/[MODID]/lang
in your en_US.lang type
0
alright thanks for the help, ill see what I can do about moving stuff to the tileentity
0
when I place only two down in the world it test each other positive (good news) and only that so the testing works and everything but it just renders it as if every side is positive (like in the picture at the beginning of the thread)
ideas why?
code update:
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 checkForNeighbors(World world, int x, int y, int z) {
if (world.getBlock(x - 1, y, z) == GunnCraftBlocks.Pipe){
num1 = true;
System.out.println("tested block num1 1 true");
}
if (world.getBlock(x + 1, y, z) == GunnCraftBlocks.Pipe){
num1 = true;
System.out.println("tested block num1 2 true");
}
if (world.getBlock(x, y - 1, z) == GunnCraftBlocks.Pipe){
num2 = true;
System.out.println("tested block num2 1 true");
}
if (world.getBlock(x, y + 1, z) == GunnCraftBlocks.Pipe){
num2 = true;
System.out.println("tested block num2 2 true");
}
if (world.getBlock(x, y, z - 1) == GunnCraftBlocks.Pipe){
num3 = true;
System.out.println("tested block num3 1 true");
}
if (world.getBlock(x, y, z + 1) == GunnCraftBlocks.Pipe){
num3 = true;
System.out.println("tested block num3 2 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 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.checkForNeighbors(entity.getWorldObj(), entity.xCoord, entity.yCoord, entity.zCoord);
this.model.shouldRenderModel1(0.0625F);
this.model.shouldRenderModel2(0.0625F);
this.model.shouldRenderModel3(0.0625F);
GL11.glPopMatrix();
GL11.glPopMatrix();
}
}
0
This was the problem, and the coords were off. I thought that entity.xCoord would work but thats not the case
this.model.checkForNeighbors(entity.getWorldObj(), entity.xCoord, entity.yCoord, entity.zCoord);
I have it running the right function now however the only problem is the getBlock under checkForNeighbors is always returning true. Even the ones that don't have a pipe next to them
0
Thanks for the reply I'll try it all out as soon as I can
0
What would I have to do in order to call the right one, I'm really new to modding, I thought that something on the lines of that was the problem thanks for the reply