Jump to content

Recommended Posts

Posted

Read The Below to understand Solution

 

BLOCK Class

 

package com.kitsu.medievalcraft.block.wood;

 

import net.minecraft.block.BlockContainer;

import net.minecraft.block.material.Material;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.world.World;

 

import com.kitsu.medievalcraft.Main;

import com.kitsu.medievalcraft.block.ModBlocks;

import com.kitsu.medievalcraft.item.ModItems;

import com.kitsu.medievalcraft.renderer.RenderId;

import com.kitsu.medievalcraft.tileents.TileEntitySmallLid;

import com.kitsu.medievalcraft.tileents.ingots.TileEntityDamascusIngot;

import com.kitsu.medievalcraft.util.CustomTab;

 

public class SmallBarrelLid extends BlockContainer {

 

public SmallBarrelLid(String unlocalizedName, Material material) {

super(material);

this.setBlockName(unlocalizedName);

this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);

this.setCreativeTab(CustomTab.MedievalCraftTab);

this.setHardness(1.0F);

this.setResistance(1.0F);

this.setHarvestLevel(null, 0);

this.setStepSound(soundTypeWood);

//xmin, ymin, zmin,

//xmax, ymax, zmax

//this.setBlockBounds(0.17F, 0.0F,  0.315F,

// 0.8F,  0.15F, 0.725F);

}

 

public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {

 

if(!world.isRemote){

TileEntitySmallLid tileLid = (TileEntitySmallLid) world.getTileEntity(x, y, z);

if(player.inventory.getCurrentItem()!=null){

if((player.getCurrentEquippedItem().getItem().equals(ModItems.splitBoard))){

if(tileLid.nbt.getInteger("LOGS")<8){

player.inventory.decrStackSize(player.inventory.currentItem, 1);

tileLid.nbt.setInteger("LOGS", tileLid.nbt.getInteger("LOGS")+1);

world.markBlockForUpdate(x, y, z);

return true;

}

}

}

if(player.inventory.getCurrentItem()!=null){

if((player.getCurrentEquippedItem().getItem().equals(ModItems.saplingRing))){

if(tileLid.nbt.getInteger("LOGS")==8){

player.inventory.decrStackSize(player.inventory.currentItem, 1);

tileLid.nbt.setInteger("RING", tileLid.nbt.getInteger("RING")+1);

world.markBlockForUpdate(x, y, z);

if(tileLid.nbt.getInteger("RING")==2){

if(!world.isRemote){

world.setBlock(x, y, z, ModBlocks.smallBarrel, 0, 2);

return true;

}

}

}

}

}

}

return false;

}

 

@Override

public TileEntity createNewTileEntity(World world, int i) {

 

return new TileEntitySmallLid();

}

 

@Override

public int getRenderType() {

return RenderId.smallLidID;

}

 

@Override

public boolean renderAsNormalBlock() {

return false;

}

 

@Override

public boolean isOpaqueCube() {

return false;

}

}

 

 

 

 

 

 

TILE ENTITY Class

 

package com.kitsu.medievalcraft.tileents;

 

import com.kitsu.medievalcraft.block.ModBlocks;

 

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.network.NetworkManager;

import net.minecraft.network.Packet;

import net.minecraft.network.play.server.S35PacketUpdateTileEntity;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.world.World;

 

public class TileEntitySmallLid extends TileEntity {

 

private String smallLidName;

private int logs;

private int ring;

//public static boolean hitGood = false;

public NBTTagCompound nbt = new NBTTagCompound();

 

public void smallLidName(String string){

this.smallLidName = string;

}

 

@Override

public void updateEntity() {

World world = this.getWorldObj();

int x = this.xCoord;

int y = this.yCoord;

int z = this.zCoord;

if(!world.isRemote){

if(nbt.getInteger("RINGS")==2){

world.setBlock(x, y, z, ModBlocks.smallBarrel, 0, 2);

}

}

}

 

@Override

public void readFromNBT(NBTTagCompound nbt)

{

super.readFromNBT(nbt);

if (nbt.hasKey("CustomName", 8)) {

this.smallLidName = nbt.getString("CustomName");

}

this.logs = nbt.getInteger("LOGS");

this.ring = nbt.getInteger("RING");

}

 

@Override

public void writeToNBT(NBTTagCompound nbt)

{

super.writeToNBT(nbt);

nbt.setInteger("LOGS", logs);

nbt.setInteger("RING", ring);

 

}

 

@Override

public Packet getDescriptionPacket() {

    //NBTTagCompound nbt = new NBTTagCompound();

    writeToNBT(nbt);

    return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 10, nbt);

}

 

@Override

public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {

    readFromNBT(pkt.func_148857_g());

    worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);

}

//func_148857_g()

}

 

 

Posted

Remove the NBTTagCompound field from your TE. It should not be there.

 

How do i change the NBT of the tileEntity then from the block class?

 

do i need to declare a NBTTagCompound nbt = new NBTTagCompound();

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

×
×
  • Create New...

Important Information

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