Jump to content

[1.8] Reconfigurable Sides


Tikaji

Recommended Posts

I'm creating a mod that uses the RF API and would like to implement reconfigurable sides for power and item transfer. I know that Thermal Expansion, Ender IO, and Immersive Engineering do that and I was curious if someone could point me in the right direction on where to start. I'm not asking for a full tutorial on here but more of a resource on where to start or any ideas.

 

Any help is greatly appreciated.

Link to comment
Share on other sites

Oh gosh, I just did this but for 1.7.10 a few days ago and it drove me nuts. Basically, I first get the orientation of my block and save a integer for left, right, back, front, top, bottom, according to the relationship to the direction I place my block:

 

i.e. if my block is facing direction 4, then left = 2, right = 3, back = 5, top = 1, bot = 0, and front of course always = the .getBlockMetadata

 

Then you more integers for each side (I just called it sLeft, etc for "sideLeft") and this is where you'll stray from me. I had a custom machine that based on my own slots for determining what side is what, but you of course would hook into the mod's api to get what texture is supposed to be there, and assign the "sLeft" or whatever side it in correlation to the mod api, and assign it values between 0-#of textures possible - 1 (because 0 is texture 1).

 

Basically, for my mod I check for an Item in a certain slot, and assign number 0-2 based on what item it is, but once again, you have to check for what picture is clicked or whatever the mod does in API.

 

remember at the end of the method that you got those values, to markDirty().

You need to call this method that gets the sides in relation to the orientation at the beginning of your updateEntity class.

 

These are integers inside the tile entity.

 

You need to write those (should be 12) to NBT, and read them from NBT.

 

When they are writing and reading correctly (check with print statements), then you will need to add 3 more methods to your tile entity to handle packets and block updates.

 

 

 

@Override

public Packet getDescriptionPacket()

{

NBTTagCompound tag = new NBTTagCompound();

writeToNBT(tag);

return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, tag);

}

 

@Override

public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)

{

readFromNBT(pkt.func_148857_g());

 

if (!getWorldObj().isRemote)

{

Minecraft.getMinecraft().renderGlobal.markBlockForRenderUpdate(xCoord, yCoord, zCoord);

worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);

}

}

 

public void updateBlock()

{

if (getWorldObj().isRemote)

{

Minecraft.getMinecraft().renderGlobal.markBlockForRenderUpdate(xCoord, yCoord, zCoord);

worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);

}

}

 

 

 

Then make sure you call the updateBlock method right after you call the side integers getting method inside the updateEntity. You need to check that worldObj.isRemote though, so remember that.

 

Then in the Block class, you need to go to wherever 1.8 defines the side textures, and do

 

if side == block.getTileEntity(x,y,z).left for left side (or .top for top, etc) and then inside of that if statement, if (block.getTileEntity(x,y,z).sLeft == 0 for left side texture 0 (or the first texture)

and then in that if statement, put what the texture should return. Repeat process with all the possible .sLeft values, and then do more if statements for each side of the block.

 

Once again, I haven't messed with 1.8 yet, so I don't know what has changed there, sorry for that. Honestly, if you want to see my code, I would be happy to show you. It was a PAIN for me to figure all of this out. It literally took me 3 days of coding straight and redoing things to get it to work. There is literally, like nothing out there to learn something like this. I know I explained this HORRIBLY, but there is really a lot of stuff going on. Maybe I'll make a proper video tutorial, but that is probably not going to happen. Maybe though. If I do, I'll post the link in here, but otherwise feel free to keep asking me questions and even ask for the code to look at, I honestly don't mind. I wish I could have had some proper documentation when I was trying this a few days ago.

Link to comment
Share on other sites

Thanks for the response. I'll see what I can do. The only issue I'm seeing right off the bat is that in 1.8 all the textures are handled in a JSON file and Minecraft finds that JSON off of the unlocalized name. I'm sure I can get it working in the tile entity but then changing textures might be a whole other beast to handle.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.