Jump to content

TileEntity NBTTag Problem


Kloonder

Recommended Posts

Hey, I have some problem with my NBTTag, it doesn't write Research, i mean it does, but it doesn't read it right

You know what's wrong?????

public void readFromNBT(NBTTagCompound nbt)
{
	super.readFromNBT(nbt);
	NBTTagList nbttaglist = nbt.getTagList("Items", 10);
	this.slots = new ItemStack[13];

	if (nbt.hasKey("CustomName", )
	{
		field_94130_e = nbt.getString("CustomName");
	}

	for (int i = 0; i < nbttaglist.tagCount(); ++i)
	{
		NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
		int j = nbttagcompound1.getByte("Slot") & 255;

		if (j >= 0 && j < this.slots.length)
		{
			this.slots[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
		}
	}
	research = nbt.getInteger("Research");
}

public void writeToNBT(NBTTagCompound nbt)
{
	super.writeToNBT(nbt);
	NBTTagList nbttaglist = new NBTTagList();

	for (int i = 0; i < slots.length; i++)
	{
		if (this.slots[i] != null)
		{
			NBTTagCompound nbttagcompound1 = new NBTTagCompound();
			nbttagcompound1.setInteger("Slot", i);
			slots[i].writeToNBT(nbttagcompound1);
			nbttaglist.appendTag(nbttagcompound1);
		}
	}

	nbt.setTag("Items", nbttaglist);

	if (this.hasCustomName())
	{
		nbt.setString("CustomName", field_94130_e);
	}

	nbt.setInteger("Research", research);
}

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

Link to comment
Share on other sites

Why do you think it is not read? What are the symptoms?

 

I used my mighty debug skillz and found out, that it writes it it correctly, but when it reads it, it doesn't use the written integer

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

Link to comment
Share on other sites

Define "your debug skillz". Because the code looks just fine.

 

Ok ok, frankly, I just typed

public void writeToNBT(NBTTagCompound nbt)
{
	super.writeToNBT(nbt);
	NBTTagList nbttaglist = new NBTTagList();

	for (int i = 0; i < slots.length; i++)
	{
		if (this.slots[i] != null)
		{
			NBTTagCompound nbttagcompound1 = new NBTTagCompound();
			nbttagcompound1.setInteger("Slot", i);
			slots[i].writeToNBT(nbttagcompound1);
			nbttaglist.appendTag(nbttagcompound1);
		}
	}

	nbt.setTag("Items", nbttaglist);

	if (this.hasCustomName())
	{
		nbt.setString("CustomName", field_94130_e);
	}

	nbt.setInteger("Research", research);
                System.out.println(nbt.getInteger("Research")); // The correct number comes out
}

public void readFromNBT(NBTTagCompound nbt)
{
	super.readFromNBT(nbt);
	NBTTagList nbttaglist = nbt.getTagList("Items", 10);
	this.slots = new ItemStack[13];

	if (nbt.hasKey("CustomName", )
	{
		field_94130_e = nbt.getString("CustomName");
	}

	for (int i = 0; i < nbttaglist.tagCount(); ++i)
	{
		NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
		int j = nbttagcompound1.getByte("Slot") & 255;

		if (j >= 0 && j < this.slots.length)
		{
			this.slots[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
		}
	}
	research = nbt.getInteger("Research");
	System.out.println(nbt.getInteger("Research")); // 0 comes out
}

 

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

Link to comment
Share on other sites

Then I need to see more of your code, because with just that code that is impossible. Did you register your TileEntity?

 

Yes yes, I mean the slots NBT are working very fine

 

		GameRegistry.registerTileEntity(TileEntityArmorModifier.class, modid + "ArmorModifierTe");

 

My full TileEntity ;D

package de.intektor.modarmor.tileentity;

import de.intektor.modarmor.ModArmMod;
import de.intektor.modarmor.items.ModArmor;
import de.intektor.modarmor.items.ModArmorHelmet;
import de.intektor.modarmor.recipehandler.Recipe;
import de.intektor.modarmor.recipehandler.RecipeHandler;
import de.intektor.modarmor.server.MessageToClient;
import de.intektor.modarmor.server.ResearchMessageStateMessage;
import de.intektor.modarmor.slot.AdvancedSlot;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.server.gui.IUpdatePlayerListBox;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IChatComponent;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import scala.swing.LazyPublisher;

public class TileEntityArmorModifier extends AdvancedTileEntity implements ISidedInventory, IUpdatePlayerListBox{

public TileEntityArmorModifier() {
	super(13);
}

public ItemStack[] saveSlots = new ItemStack[slots.length];

@SideOnly(Side.CLIENT)
public boolean synchronize = true;
@SideOnly(Side.CLIENT)
public boolean areItemStackSaved = false;

public int levelCrafting = 0;
public int research = 0;
private NBTTagCompound finishedNBT;
public EntityPlayer theUser;
private long switchingTimer;
private int switcherNumber;
private int currentShownRecipeID;
private boolean isRecipeinModifierFieldShown;
private ItemStack[] switcher = new ItemStack[]{
		new ItemStack(ModArmMod.ArmorHelmet), new ItemStack(ModArmMod.ArmorChestplate), new ItemStack(ModArmMod.ArmorLeggings), new ItemStack(ModArmMod.ArmorShoes)
};

private RecipeHandler rh2 = new RecipeHandler(this, new ItemStack[10], null);

public static Recipe recipe_armor_helmet = new Recipe("ArmorHelmet", 9, 0, new ItemStack[]{new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.leather_helmet), new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.string)}, false, new ItemStack(ModArmMod.ArmorHelmet));
public static Recipe recipe_armor_chestplate = new Recipe("ArmorChestplate", 9, 0, new ItemStack[]{new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.leather_chestplate), new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.string)}, false, new ItemStack(ModArmMod.ArmorChestplate));
public static Recipe recipe_armor_leggings = new Recipe("ArmorLeggings", 9, 0, new ItemStack[]{new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.leather_leggings), new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.string)}, false, new ItemStack(ModArmMod.ArmorLeggings));
public static Recipe recipe_armor_shoes = new Recipe("ArmorShoes", 9, 0, new ItemStack[]{new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.leather_boots), new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.string)}, false, new ItemStack(ModArmMod.ArmorShoes));
public static Recipe recipe_protection_upgrade = new Recipe("ProtectionoUpgrade", 9, 0, new ItemStack[]{new ItemStack(Items.iron_ingot), new ItemStack(Items.dye, 1, 4), new ItemStack(Items.iron_ingot), new ItemStack(Items.gold_ingot), new ItemStack(Items.diamond), new ItemStack(Items.gold_ingot), new ItemStack(Items.iron_ingot), new ItemStack(Items.dye, 1, 4), new ItemStack(Items.iron_ingot)}, false, new ItemStack(ModArmMod.Protection_Upgrade));

public static Recipe recipe_spring = new Recipe("Spring", 9, 0, new ItemStack[]{null, new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), null, null, new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot)}, false, new ItemStack(ModArmMod.spring));
public static Recipe recipe_stranger_system = new Recipe("Stranger_Protection_System", 9, 0, new ItemStack[]{new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(Items.skull, 1, 1), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot)}, false, new ItemStack(ModArmMod.stranger_protection_system));
public static Recipe recipe_lens = new Recipe("lens", 9, 0, new ItemStack[]{new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(Items.potionitem, 1, 16454), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot)}, false, new ItemStack(ModArmMod.nightvisionlens));
public static Recipe recipe_goggles = new Recipe("goggles", 9, 0, new ItemStack[]{new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(ModArmMod.nightvisionlens), new ItemStack(Items.iron_ingot), new ItemStack(ModArmMod.nightvisionlens), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot)}, false, new ItemStack(ModArmMod.nightvisiongoggles));
public static Recipe recipe_mass_transformer = new Recipe("mass_transformer", 9, 0, new ItemStack[]{new ItemStack(Items.golden_apple, 1, 1), new ItemStack(Items.ender_eye), new ItemStack(Items.golden_apple, 1, 1), new ItemStack(Items.ender_eye), new ItemStack(Items.nether_star), new ItemStack(Items.ender_eye), new ItemStack(Items.golden_apple, 1, 1), new ItemStack(Items.ender_eye), new ItemStack(Items.golden_apple, 1, 1)}, false, new ItemStack(ModArmMod.MassTransformer));

public static Recipe recipe_single_jet = new Recipe("Single Jet", 9, 0, new ItemStack[]{new ItemStack(Items.iron_ingot), new ItemStack(Items.redstone), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(Items.redstone), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(Items.flint_and_steel), new ItemStack(Items.iron_ingot)}, false, new ItemStack(ModArmMod.singleJet));
public static Recipe recipe_dual_jets = new Recipe("Dual Jets", 9, 0, new ItemStack[]{new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(ModArmMod.singleJet), new ItemStack(Items.iron_ingot), new ItemStack(ModArmMod.singleJet), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot)}, false, new ItemStack(ModArmMod.jetDual));
public static Recipe recipe_glider = new Recipe("Glider", 9, 0, new ItemStack[]{new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.iron_ingot), new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.string), new ItemStack(Items.string)}, false, new ItemStack(ModArmMod.Glider));
public static Recipe recipe_gliding_device = new Recipe("Gliding_Device", 9, 0, new ItemStack[]{new ItemStack(ModArmMod.Glider), new ItemStack(ModArmMod.Glider), new ItemStack(ModArmMod.Glider), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(Items.iron_ingot), new ItemStack(ModArmMod.Glider), new ItemStack(ModArmMod.Glider), new ItemStack(ModArmMod.Glider)}, false, new ItemStack(ModArmMod.GlidingModule));

@Override
public void validate() {
	rh2.addRecipe(recipe_armor_helmet);
	rh2.addRecipe(recipe_armor_chestplate);
	rh2.addRecipe(recipe_armor_leggings);
	rh2.addRecipe(recipe_armor_shoes);
	rh2.addRecipe(recipe_glider);
	rh2.addRecipe(recipe_protection_upgrade);
	rh2.addRecipe(recipe_gliding_device);
	rh2.addRecipe(recipe_spring);
	rh2.addRecipe(recipe_stranger_system);
	rh2.addRecipe(recipe_lens);
	rh2.addRecipe(recipe_goggles);
	rh2.addRecipe(recipe_mass_transformer);
	rh2.addRecipe(recipe_single_jet);
	rh2.addRecipe(recipe_dual_jets);
	finishedNBT = new NBTTagCompound();
	finishedNBT.setBoolean("FullNow", true);
	research = getTileData().getInteger("Research");

	super.validate();

}

@Override
public void update() {
	if(theUser != null){
		finishedNBT.setBoolean(theUser.getDisplayNameString(), true);
	}

	Side side = FMLCommonHandler.instance().getEffectiveSide();
	if(side == Side.CLIENT){
		if(System.currentTimeMillis() - 750 >= switchingTimer){
			if(switcherNumber == 3){
				switcherNumber = 0;
			}else{
				switcherNumber++;
			}
			switchingTimer = System.currentTimeMillis();
			if(isRecipeinModifierFieldShown){
				putRecipeinModifierField(currentShownRecipeID);
			}
		}
		if(synchronize){
			if(areItemStackSaved){
				loadSaveBack();
				areItemStackSaved = false;
			}
			handleResearchState();
			if(theUser != null){
				ItemStack[] sl = new ItemStack[10];
				for(int i = 0; i < sl.length; i++){
					sl[i] = slots[i+3];
					slots[12] = rh2.update(sl, theUser);
					if(slots[12] != null){
						if(slots[12].getItem() instanceof ModArmor){
							if(!slots[12].hasTagCompound()){
								slots[12].setTagCompound(new NBTTagCompound());
							}
							slots[12].getTagCompound().setBoolean(theUser.getDisplayNameString(), true);
							slots[12].getTagCompound().setBoolean("FullNow", true);
						}
					}
				}
				slots[2] = null;
				handleModificationSystem();
			}
		}
	}
	if(side == Side.SERVER){
		handleResearchState();
		if(theUser != null){
			ItemStack[] sl = new ItemStack[10];
			for(int i = 0; i < sl.length; i++){
				sl[i] = slots[i+3];
			}
			slots[12] = rh2.update(sl, theUser);
			if(slots[12] != null){
				if(slots[12].getItem() instanceof ModArmor){
					if(!slots[12].hasTagCompound()){
						slots[12].setTagCompound(new NBTTagCompound());
					}
					slots[12].getTagCompound().setBoolean(theUser.getDisplayNameString(), true);
					slots[12].getTagCompound().setBoolean("FullNow", true);
				}
			}
		}
		slots[2] = null;
		handleModificationSystem();
	}
}

public void handleModificationSystem(){
	ItemStack theStack = null;
	boolean b = true;
	if(slots[0] != null){
		if(slots[0].getItem() instanceof ModArmor){
			if(theUser != null){
				if(slots[0].hasTagCompound()){
					if(slots[0].getTagCompound().getBoolean(theUser.getDisplayNameString())){
						if(slots[1] != null){
							if(slots[0].getItem() == ModArmMod.ArmorHelmet){
								handleNightVisionSystem();
								handleBreathing();
							}
							if(slots[0].getItem() == ModArmMod.ArmorChestplate){
								handleGliding();
								handleMining();
								handleStrenght();
								handleSingleJet();
								handleMassTransformer();
							}
							if(slots[0].getItem() == ModArmMod.ArmorLeggings){
								handleSwiftness();
							}
							if(slots[0].getItem() == ModArmMod.ArmorShoes){
								handleWallClimbing();
								handleJumpBoost();
							}
							handleProtectionUpgrade();
							handleStrangerSystem();

						}
					}else{
						if(slots[1] == null){
							if(!slots[0].getTagCompound().getBoolean(theUser.getDisplayNameString())){
								handleUnidentifiedArmor();
							}else{
								b = false;
							}
						}else{
							b = false;
						}
					}
				}else{
					b = false;
				}
			}else{
				b = false;
			}
		}else{
			b = false;
		}
	}else{
		b = false;
	}
	if(!b){
		slots[2] = null;
		levelCrafting = 0;
		specialObject[0] = "";
	}else{
		specialObject[0] = levelCrafting + "";
	}
}


public void handleUnidentifiedArmor(){
	levelCrafting = 5;
	ItemStack stack = null;
	if(theUser.experienceLevel >= levelCrafting){
		stack = slots[0].copy();
		stack.setTagCompound((NBTTagCompound) slots[0].getTagCompound().copy());
		stack.getTagCompound().setString("a", "ha");
		stack.getTagCompound().setBoolean(theUser.getDisplayNameString(), true);

	}
	if(stack != null){
		slots[2] = stack;
	}
}

public void handleProtectionUpgrade(){
	ItemStack theStack = null;
	if(slots[1].getItem() == ModArmMod.Protection_Upgrade && research >= 1){
		float multi = slots[0].getTagCompound().getInteger("Protection_Upgrade_Multiplier") == 0 ? 0.2f : slots[0].getTagCompound().getInteger("Protection_Upgrade_Multiplier");
		levelCrafting = (int) (5 * multi);
		if(theUser.experienceLevel >= levelCrafting){
			ItemStack stack;
			stack = slots[0].copy();
			stack.setTagCompound((NBTTagCompound) slots[0].getTagCompound().copy());
			stack.getTagCompound().setInteger("Protection", stack.getTagCompound().getInteger("Protection")+1);
			stack.getTagCompound().setInteger("Protection_Upgrade_Multiplier", (int) (multi == 0.2f ? 1 : multi*2));
			theStack = stack;
		}
	}
	if(theStack != null){
		slots[2] = theStack;
	}
}

public void handleGliding(){
	ItemStack theStack = null;
	if(slots[1].getItem() == ModArmMod.GlidingModule && research >= 2){
		float multi = slots[0].getTagCompound().getInteger("Gliding_Upgrade_Multiplier") == 0 ? 0.2f : slots[0].getTagCompound().getInteger("Gliding_Upgrade_Multiplier");
		levelCrafting = (int) (1.25 * multi);
		if(theUser.experienceLevel >= levelCrafting){
			ItemStack stack;
			stack = slots[0].copy();
			stack.setTagCompound((NBTTagCompound) slots[0].getTagCompound().copy());
			stack.getTagCompound().setInteger("Gliding", stack.getTagCompound().getInteger("Gliding")-2);
			stack.getTagCompound().setInteger("Gliding_Upgrade_Multiplier", (int) (multi == 0.2f ? 1 : multi*2));
			theStack = stack;
		}
	}
	if(theStack != null){
		slots[2] = theStack;
	}
}

public void handleWallClimbing(){
	ItemStack theStack = null;
	if(slots[1].getItem() == Items.slime_ball && research >= 3){
		float multi = slots[0].getTagCompound().getInteger("Slime_Upgrade_Multiplier") == 0 ? 0.2f : slots[0].getTagCompound().getInteger("Slime_Upgrade_Multiplier");
		levelCrafting = (int) (2 * multi);
		if(theUser.experienceLevel >= levelCrafting){
			ItemStack stack;
			stack = slots[0].copy();
			stack.setTagCompound((NBTTagCompound) slots[0].getTagCompound().copy());
			int dp = stack.getTagCompound().getInteger("Slimy");
			stack.getTagCompound().setInteger("Slimy", ++dp);
			stack.getTagCompound().setDouble("MaxClimbingTime", dp*5000);
			stack.getTagCompound().setDouble("RemainingClimbingTime", dp*5000);
			stack.getTagCompound().setInteger("Slime_Upgrade_Multiplier", (int) (multi == 0.2f ? 1 : multi*2));
			theStack = stack;
		}
	}
	if(theStack != null){
		slots[2] = theStack;
	}
}

public void handleJumpBoost(){
	ItemStack theStack = null;
	if(slots[1].getItem() == ModArmMod.spring && research >= 2){
		float multi = slots[0].getTagCompound().getInteger("JumpBoost_Upgrade_Multiplier") == 0 ? 1 : slots[0].getTagCompound().getInteger("JumpBoost_Upgrade_Multiplier");
		levelCrafting = (int) (5 * multi);
		if(theUser.experienceLevel >= levelCrafting){
			ItemStack stack;
			stack = slots[0].copy();
			stack.setTagCompound((NBTTagCompound) slots[0].getTagCompound().copy());
			stack.getTagCompound().setInteger("JumpBoost", stack.getTagCompound().getInteger("JumpBoost")+1);
			stack.getTagCompound().setInteger("JumpBoost_Upgrade_Multiplier", (int) (multi == 0.2f ? 1 : multi*2));
			theStack = stack;
		}
	}
	if(theStack != null){
		slots[2] = theStack;
	}
}

public void handleStrangerSystem(){
	ItemStack theStack = null;
	if(slots[1].getItem() == ModArmMod.stranger_protection_system && research >= 3 && slots[0].getTagCompound().getBoolean("StrangerSystem")){
		levelCrafting = 30;
		if(theUser.experienceLevel >= levelCrafting){
			ItemStack stack;
			stack = slots[0].copy();
			stack.setTagCompound((NBTTagCompound) slots[0].getTagCompound().copy());
			stack.getTagCompound().setBoolean("StrangerSystem", true);
			stack.getTagCompound().setString("Owner", theUser.getDisplayNameString());
			theStack = stack;
		}
	}
	if(theStack != null){
		slots[2] = theStack;
	}
}

public void handleNightVisionSystem(){
	ItemStack theStack = null;
	if(slots[1].getItem() == ModArmMod.nightvisiongoggles && research >= 4 && !slots[0].getTagCompound().getBoolean("NightVision")){
		levelCrafting = 30;
		if(theUser.experienceLevel >= levelCrafting){
			ItemStack stack;
			stack = slots[0].copy();
			stack.setTagCompound((NBTTagCompound) slots[0].getTagCompound().copy());
			stack.getTagCompound().setBoolean("NightVision", true);
			theStack = stack;
		}
	}
	if(theStack != null){
		slots[2] = theStack;
	}
}

public void handleMining(){
	ItemStack theStack = null;
	if(slots[1].getItem() == Items.diamond_pickaxe && research >= 5){
		float multi = slots[0].getTagCompound().getInteger("Mining_Upgrade_Multiplier") == 0 ? 1 : slots[0].getTagCompound().getInteger("Mining_Upgrade_Multiplier");
		levelCrafting = (int) (5 * multi);
		if(theUser.experienceLevel >= levelCrafting){
			ItemStack stack;
			stack = slots[0].copy();
			stack.setTagCompound((NBTTagCompound) slots[0].getTagCompound().copy());
			stack.getTagCompound().setInteger("Mining", stack.getTagCompound().getInteger("Mining")+1);
			stack.getTagCompound().setInteger("Mining_Upgrade_Multiplier", (int) (multi == 0.2f ? 1 : multi*2));
			stack.getTagCompound().setBoolean("MiningActive", true);
			theStack = stack;
		}
	}
	if(theStack != null){
		slots[2] = theStack;
	}
}

public void handleSwiftness(){
	ItemStack theStack = null;
	if(ItemStack.areItemStacksEqual(slots[1], new ItemStack(Items.potionitem, 1, 16418)) && research >= 6){
		float multi = slots[0].getTagCompound().getInteger("Speed_Upgrade_Multiplier") == 0 ? 1 : slots[0].getTagCompound().getInteger("Speed_Upgrade_Multiplier");
		levelCrafting = (int) (5 * multi);
		if(theUser.experienceLevel >= levelCrafting){
			ItemStack stack;
			stack = slots[0].copy();
			stack.setTagCompound((NBTTagCompound) slots[0].getTagCompound().copy());
			stack.getTagCompound().setInteger("Speed", stack.getTagCompound().getInteger("Speed")+1);
			stack.getTagCompound().setInteger("Speed_Upgrade_Multiplier", (int) (multi == 0.2f ? 1 : multi*2));
			theStack = stack;
		}
	}
	if(theStack != null){
		slots[2] = theStack;
	}
}

public void handleBreathing(){
	ItemStack theStack = null;
	if(ItemStack.areItemStacksEqual(slots[1], new ItemStack(Items.potionitem, 1, 16429)) && research >= 7){
		float multi = slots[0].getTagCompound().getInteger("Br_Upgrade_Multiplier") == 0 ? 1 : slots[0].getTagCompound().getInteger("Br_Upgrade_Multiplier");
		levelCrafting = (int) (5 * multi);
		if(theUser.experienceLevel >= levelCrafting){
			ItemStack stack;
			stack = slots[0].copy();
			stack.setTagCompound((NBTTagCompound) slots[0].getTagCompound().copy());
			stack.getTagCompound().setInteger("Br", stack.getTagCompound().getInteger("Br")+1);
			stack.getTagCompound().setInteger("Br_Upgrade_Multiplier", (int) (multi == 0.2f ? 1 : multi*2));
			theStack = stack;
		}
	}
	if(theStack != null){
		slots[2] = theStack;
	}
}

public void handleStrenght(){
	ItemStack theStack = null;
	if(ItemStack.areItemStacksEqual(slots[1], new ItemStack(Items.potionitem, 1, 16425)) && research >= {
		float multi = slots[0].getTagCompound().getInteger("Strength_Upgrade_Multiplier") == 0 ? 1 : slots[0].getTagCompound().getInteger("Strength_Upgrade_Multiplier");
		levelCrafting = (int) (40 * multi);
		if(theUser.experienceLevel >= levelCrafting){
			ItemStack stack;
			stack = slots[0].copy();
			stack.setTagCompound((NBTTagCompound) slots[0].getTagCompound().copy());
			stack.getTagCompound().setInteger("Strength", stack.getTagCompound().getInteger("Strength")+1);
			stack.getTagCompound().setInteger("Strength_Upgrade_Multiplier", (int) (multi == 0.2f ? 1 : multi*2));
			theStack = stack;
		}
	}
	if(theStack != null){
		slots[2] = theStack;
	}
}

public void handleMassTransformer(){
	ItemStack theStack = null;
	if(slots[1].getItem() == ModArmMod.MassTransformer && research >= 9){
		float multi = slots[0].getTagCompound().getInteger("MassTransformer_Upgrade_Multiplier") == 0 ? 1 : slots[0].getTagCompound().getInteger("MassTransformer_Upgrade_Multiplier");
		levelCrafting = (int) (80 * multi);
		if(theUser.experienceLevel >= levelCrafting){
			ItemStack stack;
			stack = slots[0].copy();
			stack.setTagCompound((NBTTagCompound) slots[0].getTagCompound().copy());
			stack.getTagCompound().setInteger("MassTransformer", stack.getTagCompound().getInteger("MassTransformer")+1);
			stack.getTagCompound().setInteger("MassTransformer_Upgrade_Multiplier", (int) (multi == 0.2f ? 1 : multi*2));
			stack.getTagCompound().setDouble("MaxNoclipTime", stack.getTagCompound().getDouble("MaxNoclipTime") + 2000);
			theStack = stack;
		}
	}
	if(theStack != null){
		slots[2] = theStack;
	}
}

public void handleSingleJet(){
	ItemStack theStack = null;
	if(slots[1].getItem() == ModArmMod.singleJet && research >= 8 && !slots[0].getTagCompound().getBoolean("JetDual")){
		levelCrafting = (int) (30);
		if(theUser.experienceLevel >= levelCrafting){
			ItemStack stack;
			stack = slots[0].copy();
			stack.setTagCompound((NBTTagCompound) slots[0].getTagCompound().copy());
			if(!slots[0].getTagCompound().getBoolean("SingelJet")){
				stack.getTagCompound().setBoolean("SingleJet", true);
			}else{
				stack.getTagCompound().setBoolean("SingleJet", false);
				stack.getTagCompound().setBoolean("JetDual", true);
			}
			theStack = stack;
		}
	}else if(slots[1].getItem() == ModArmMod.jetDual && research >= 8 && !slots[0].getTagCompound().getBoolean("JetDual")){
		levelCrafting = (int) (60);
		if(theUser.experienceLevel >= levelCrafting){
			ItemStack stack;
			stack = slots[0].copy();
			stack.setTagCompound((NBTTagCompound) slots[0].getTagCompound().copy());
			stack.getTagCompound().setBoolean("JetDual", true);
			theStack = stack;
		}
	}
	if(theStack != null){
		slots[2] = theStack;
	}
}

@Override
public void specialEvent(int id, Object object) {
	switch(id){
	case 0:
		if(theUser != null){
			theUser.experienceLevel -= levelCrafting;
			slots[2].getTagCompound().setInteger("Level_Wasted", slots[2].getTagCompound().getInteger("Level_Wasted") + levelCrafting);
		}
		slots[0] = null;
		break;
	case 1:
		for(int i = 0; i < slots.length-4; i++){
			if(slots[i+3] != null){
				slots[i + 3].stackSize--;
				if(slots[i+3].stackSize <= 0){
					slots[i+3] = null;
				}
			}
		}
		break;
	case 2:
		theUser = (EntityPlayer) object;
		break;
	case 10:
		saveSlots();
		synchronize = false;
		allowInteracting = false;
		break;
	case 11:
		stopShowingRecipe();
		break;
	case 12:
		synchronize = false;
		putRecipeinCraftingField((Recipe) object);
		break;
	case 13:
		research += 1;
		try{
			putRecipeinModifierField(research -1);
		}catch(Exception e){

		}
		break;
	case 14:
		currentShownRecipeID = (Integer) object;
		putRecipeinModifierField((Integer) object);
		isRecipeinModifierFieldShown = true;
		break;
	}
}

@SideOnly(Side.CLIENT)
public void putRecipeinCraftingField(Recipe recipe){
	for(int i = 0; i < 9; i++){
		ItemStack stack = recipe.getRecipe()[i];
		if(stack != null){
			if(!recipe.doesCareStackSize()){
				stack.stackSize = 1;
			}
		}
		slots[i + 3] = stack;
	}
	slots[slots.length-1] = recipe.getOutput();
	synchronize = false;
	allowInteracting = false;
}

@SideOnly(Side.CLIENT)
public void putRecipeinModifierField(int ID){
	switch(ID){
	case 0:
		slots[0] = switcher[switcherNumber];
		slots[0].setTagCompound((NBTTagCompound) finishedNBT.copy());
		slots[1] = new ItemStack(ModArmMod.Protection_Upgrade);
		slots[2] = switcher[switcherNumber];
		slots[2].setTagCompound((NBTTagCompound) finishedNBT.copy());
		slots[2].getTagCompound().setInteger("Protection", 1);
		break;
	case 1:
		slots[0] = new ItemStack(ModArmMod.ArmorChestplate);
		slots[0].setTagCompound((NBTTagCompound) finishedNBT.copy());
		slots[1] = new ItemStack(ModArmMod.GlidingModule);
		slots[2] = new ItemStack(ModArmMod.ArmorChestplate);
		slots[2].setTagCompound((NBTTagCompound) finishedNBT.copy());
		slots[2].getTagCompound().setInteger("Gliding", -2);
		break;
	case 2:
		slots[0] = new ItemStack(ModArmMod.ArmorShoes);
		slots[0].setTagCompound((NBTTagCompound) finishedNBT.copy());
		slots[1] = new ItemStack(Items.slime_ball);
		slots[2] = new ItemStack(ModArmMod.ArmorShoes);
		slots[2].setTagCompound((NBTTagCompound) finishedNBT.copy());
		int dp = slots[2].getTagCompound().getInteger("Slimy");
		slots[2].getTagCompound().setInteger("Slimy", ++dp);
		slots[2].getTagCompound().setDouble("MaxClimbingTime", dp*5000);
		slots[2].getTagCompound().setDouble("RemainingClimbingTime", dp*5000);
		break;
	case 3:
		slots[0] = new ItemStack(ModArmMod.ArmorShoes);
		slots[0].setTagCompound((NBTTagCompound) finishedNBT.copy());
		slots[1] = new ItemStack(ModArmMod.spring);
		slots[2] = new ItemStack(ModArmMod.ArmorShoes);
		slots[2].setTagCompound((NBTTagCompound) finishedNBT.copy());
		int dp2 = slots[2].getTagCompound().getInteger("JumpBoost");
		slots[2].getTagCompound().setInteger("JumpBoost", ++dp2);
		break;
	case 4:
		slots[0] = switcher[switcherNumber];
		slots[0].setTagCompound((NBTTagCompound) finishedNBT.copy());
		slots[1] = new ItemStack(ModArmMod.stranger_protection_system);
		slots[2] = switcher[switcherNumber];
		slots[2].setTagCompound((NBTTagCompound) finishedNBT.copy());
		slots[2].getTagCompound().setBoolean("StrangerSystem", true);
		slots[2].getTagCompound().setString("Owner", theUser.getDisplayNameString());
		break;
	case 5:
		slots[0] = new ItemStack(ModArmMod.ArmorHelmet);
		slots[0].setTagCompound((NBTTagCompound) finishedNBT.copy());
		slots[1] = new ItemStack(ModArmMod.nightvisiongoggles);
		slots[2] = new ItemStack(ModArmMod.ArmorHelmet);
		slots[2].setTagCompound((NBTTagCompound) finishedNBT.copy());
		slots[2].getTagCompound().setBoolean("NightVision", true);
		break;
	case 6:
		slots[0] = new ItemStack(ModArmMod.ArmorChestplate);
		slots[0].setTagCompound((NBTTagCompound) finishedNBT.copy());
		slots[1] = new ItemStack(Items.diamond_pickaxe);
		slots[2] = new ItemStack(ModArmMod.ArmorChestplate);
		slots[2].setTagCompound((NBTTagCompound) finishedNBT.copy());
		int dp4 = slots[2].getTagCompound().getInteger("Mining");
		slots[2].getTagCompound().setInteger("Mining", ++dp4);
		break;
	case 7:
		slots[0] = new ItemStack(ModArmMod.ArmorShoes);
		slots[0].setTagCompound((NBTTagCompound) finishedNBT.copy());
		slots[1] = new ItemStack(Items.potionitem, 1, 16418);
		slots[2] = new ItemStack(ModArmMod.ArmorShoes);
		slots[2].setTagCompound((NBTTagCompound) finishedNBT.copy());
		int dp5 = slots[2].getTagCompound().getInteger("Speed");
		slots[2].getTagCompound().setInteger("Speed", ++dp5);
		break;
	case 8:
		slots[0] = new ItemStack(ModArmMod.ArmorHelmet);
		slots[0].setTagCompound((NBTTagCompound) finishedNBT.copy());
		slots[1] = new ItemStack(Items.potionitem, 1, 16429);
		slots[2] = new ItemStack(ModArmMod.ArmorHelmet);
		slots[2].setTagCompound((NBTTagCompound) finishedNBT.copy());
		int dp6 = slots[2].getTagCompound().getInteger("Br");
		slots[2].getTagCompound().setInteger("Br", ++dp6);
		break;
	case 9:
		slots[0] = new ItemStack(ModArmMod.ArmorChestplate);
		slots[0].setTagCompound((NBTTagCompound) finishedNBT.copy());
		slots[1] = new ItemStack(Items.potionitem, 1, 16425);
		slots[2] = new ItemStack(ModArmMod.ArmorChestplate);
		slots[2].setTagCompound((NBTTagCompound) finishedNBT.copy());
		int dp7 = slots[2].getTagCompound().getInteger("Strenght");
		slots[2].getTagCompound().setInteger("Strenght", ++dp7);
		break;
	case 10:
		slots[0] = new ItemStack(ModArmMod.ArmorChestplate);
		slots[0].setTagCompound((NBTTagCompound) finishedNBT.copy());
		slots[1] = new ItemStack(ModArmMod.singleJet);
		slots[2] = new ItemStack(ModArmMod.ArmorChestplate);
		slots[2].setTagCompound((NBTTagCompound) finishedNBT.copy());
		slots[2].getTagCompound().setBoolean("SingleJet", true);
		break;
	case 11:
		slots[0] = new ItemStack(ModArmMod.ArmorChestplate);
		slots[0].setTagCompound((NBTTagCompound) finishedNBT.copy());
		slots[1] = new ItemStack(ModArmMod.jetDual);
		slots[2] = new ItemStack(ModArmMod.ArmorChestplate);
		slots[2].setTagCompound((NBTTagCompound) finishedNBT.copy());
		slots[2].getTagCompound().setBoolean("JetDual", true);
		break;
	case 12:
		slots[0] = new ItemStack(ModArmMod.ArmorChestplate);
		slots[0].setTagCompound((NBTTagCompound) finishedNBT.copy());
		slots[1] = new ItemStack(ModArmMod.MassTransformer);
		slots[2] = new ItemStack(ModArmMod.ArmorChestplate);
		slots[2].setTagCompound((NBTTagCompound) finishedNBT.copy());
		slots[2].getTagCompound().setInteger("MassTransformer", 1);
		break;
	}

}

@SideOnly(Side.CLIENT)
public void saveSlots(){
	for(int i = 0; i < slots.length; i++){
		saveSlots[i] = slots[i];
	}
	areItemStackSaved = true;
}

@SideOnly(Side.CLIENT)
public void loadSaveBack(){
	for(int i = 0; i < slots.length; i++){
		slots[i] = saveSlots[i];
	}
}

public void stopShowingRecipe(){
	synchronize = true;
	allowInteracting = true;
	isRecipeinModifierFieldShown = false;
}



public void readFromNBT(NBTTagCompound nbt)
{
	super.readFromNBT(nbt);
	NBTTagList nbttaglist = nbt.getTagList("Items", 10);
	this.slots = new ItemStack[13];

	if (nbt.hasKey("CustomName", )
	{
		field_94130_e = nbt.getString("CustomName");
	}

	for (int i = 0; i < nbttaglist.tagCount(); ++i)
	{
		NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
		int j = nbttagcompound1.getByte("Slot") & 255;

		if (j >= 0 && j < this.slots.length)
		{
			this.slots[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
		}
	}
	research = nbt.getInteger("Research");
}

public void writeToNBT(NBTTagCompound nbt)
{
	super.writeToNBT(nbt);
	NBTTagList nbttaglist = new NBTTagList();

	for (int i = 0; i < slots.length; i++)
	{
		if (this.slots[i] != null)
		{
			NBTTagCompound nbttagcompound1 = new NBTTagCompound();
			nbttagcompound1.setInteger("Slot", i);
			slots[i].writeToNBT(nbttagcompound1);
			nbttaglist.appendTag(nbttagcompound1);
		}
	}

	nbt.setTag("Items", nbttaglist);

	if (this.hasCustomName())
	{
		nbt.setString("CustomName", field_94130_e);
	}

	nbt.setInteger("Research", research);
}

public void handleResearchState(){
	rh2.setAllRecipesEnabled(false);
	if(research >= 0){
		rh2.getRecipe(0).setEnabled(true);
		rh2.getRecipe(1).setEnabled(true);
		rh2.getRecipe(2).setEnabled(true);
		rh2.getRecipe(3).setEnabled(true);
	}
	if(research >= 1){
		recipe_protection_upgrade.setEnabled(true);
	}
	if(research >= 2){
		recipe_glider.setEnabled(true);
		recipe_gliding_device.setEnabled(true);
	}
	if(research >= 3){
		recipe_spring.setEnabled(true);
	}
	if(research >= 4){
		recipe_stranger_system.setEnabled(true);
	}
	if(research >= 5){
		recipe_lens.setEnabled(true);
		recipe_goggles.setEnabled(true);
	}
	if(research >= {
		recipe_single_jet.setEnabled(true);
		recipe_dual_jets.setEnabled(true);
	}
	if(research >= 9){
		recipe_mass_transformer.setEnabled(true);
	}
}
}

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

Link to comment
Share on other sites

What I can see is that you are doing an awful lot of set/write operations on the client (e.g. in update). Also what is this:

research = getTileData().getInteger("Research")?

 

The most of the set write omn Client is the same thing, that NEI does, so it won't synchro the shown example recipes with the real recipes.

 

research = getTileData().getInteger("Research")

I trieds to do this with that one, but it only does this on server, so the value is saved only at the server, and I need the value also onb the client

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

Link to comment
Share on other sites

Aha, see, now we are getting somewhere. If you need the value on the client you need packets.

 

Yes I tried that,

 

but the first question is here: Why doent the normal way in the readNBT work

second: I am using the simple network system from your tutorial, but what I think I can store only one var in a message, but I need more(world, Block Pos(to get the TileEntity), an integer with the research's value)

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

Link to comment
Share on other sites

Why doent the normal way in the readNBT work
Only the server knows about the world and therefor NBT. Only the server calls readNBT.

second: I am using the simple network system from your tutorial, but what I think I can store only one var in a message, but I need more(world, Block Pos(to get the TileEntity), an integer with the research's value)

You can send as many things as you want in the packet. Also you don't need to send the world, only the position. The client only has one world.

 

Hm that sound good,

 

I tried it now with the package

public BlockPos pos; 
public int r;

public MessageToClient(BlockPos pos, int number){
	this.pos = pos;
	r = number;
}
public MessageToClient(){
}

@Override
public void fromBytes(ByteBuf buf) {
	NBTTagCompound nbt = ByteBufUtils.readTag(buf);
	int[] integer = nbt.getIntArray("Array");
	pos = new BlockPos(integer[0], integer[1], integer[2]);
	r = integer[3];
}

@Override
public void toBytes(ByteBuf buf) {
	NBTTagCompound nbt = new NBTTagCompound();
	nbt.setIntArray("Array", (new int[]{pos.getX(), pos.getY(), pos.getZ(), r}));
	ByteBufUtils.writeTag(buf, nbt);
}

 

@Override
public IMessage onMessage(MessageToClient message, MessageContext ctx) {

	TileEntityArmorModifier tileEntity = (TileEntityArmorModifier) Minecraft.getMinecraft().theWorld.getTileEntity(message.pos);
	System.out.println(message.r);
	tileEntity.research = message.r;
	return null;
}

public void update() {
	ModArmMod.network.sendToAll(new MessageToClient(this.getPos(), research));
}

But I get this error every time it loops

 

Aug 02, 2015 5:24:10 PM io.netty.channel.embedded.EmbeddedChannel recordException

WARNUNG: More than one exception was raised. Will report only the first one and log others.

java.lang.NullPointerException

at net.minecraftforge.fml.common.network.FMLOutboundHandler$OutboundTarget$5.selectNetworks(FMLOutboundHandler.java:132)

at net.minecraftforge.fml.common.network.FMLOutboundHandler.write(FMLOutboundHandler.java:276)

at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:645)

at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:699)

at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:638)

at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:115)

at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116)

at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:645)

at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:699)

at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:689)

at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:718)

at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:893)

at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:240)

at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendToAll(SimpleNetworkWrapper.java:182)

at de.intektor.modarmor.tileentity.TileEntityArmorModifier.update(TileEntityArmorModifier.java:105)

at net.minecraft.world.World.updateEntities(World.java:1879)

at net.minecraft.client.Minecraft.runTick(Minecraft.java:2184)

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1087)

at net.minecraft.client.Minecraft.run(Minecraft.java:376)

at net.minecraft.client.main.Main.main(Main.java:117)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)

at GradleStart.main(Unknown Source)

 

[17:24:10] [Client thread/ERROR] [FML]: FMLIndexedMessageCodec exception caught

java.lang.NullPointerException

at net.minecraftforge.fml.common.network.FMLOutboundHandler$OutboundTarget$5.selectNetworks(FMLOutboundHandler.java:132) ~[FMLOutboundHandler$OutboundTarget$5.class:?]

at net.minecraftforge.fml.common.network.FMLOutboundHandler.write(FMLOutboundHandler.java:276) ~[FMLOutboundHandler.class:?]

at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:645) ~[DefaultChannelHandlerContext.class:4.0.15.Final]

at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:699) ~[DefaultChannelHandlerContext.class:4.0.15.Final]

at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:638) ~[DefaultChannelHandlerContext.class:4.0.15.Final]

at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:115) ~[MessageToMessageEncoder.class:4.0.15.Final]

at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) ~[MessageToMessageCodec.class:4.0.15.Final]

at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:645) ~[DefaultChannelHandlerContext.class:4.0.15.Final]

at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:699) ~[DefaultChannelHandlerContext.class:4.0.15.Final]

at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:689) ~[DefaultChannelHandlerContext.class:4.0.15.Final]

at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:718) ~[DefaultChannelHandlerContext.class:4.0.15.Final]

at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:893) ~[DefaultChannelPipeline.class:4.0.15.Final]

at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:240) ~[AbstractChannel.class:4.0.15.Final]

at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendToAll(SimpleNetworkWrapper.java:182) [simpleNetworkWrapper.class:?]

at de.intektor.modarmor.tileentity.TileEntityArmorModifier.update(TileEntityArmorModifier.java:105) [TileEntityArmorModifier.class:?]

at net.minecraft.world.World.updateEntities(World.java:1879) [World.class:?]

at net.minecraft.client.Minecraft.runTick(Minecraft.java:2184) [Minecraft.class:?]

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1087) [Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:376) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_51]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_51]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_51]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]

at GradleStart.main(Unknown Source) [start/:?]

[17:24:10] [Client thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

Link to comment
Share on other sites

O.o Why are you using NBT in the packet? Just write the data to the ByteBuf...

 

As for the error, you are just sending the packet every time your TE updates (this is a bad idea, only send it when the data changes!) and you don't check if you are on the server. You obviously cannot send a packet to the client when you are on the client.

 

Thats fucking annoying, I won't work right

 

public BlockPos pos; 
public int r;

public MessageToClient(BlockPos pos, int number){
	this.pos = pos;
	r = number;
}
public MessageToClient(){
}

@Override
public void fromBytes(ByteBuf buf) {
	pos = new BlockPos(buf.getInt(0), buf.getInt(1), buf.getInt(2));
	r = buf.getInt(3);
}

@Override
public void toBytes(ByteBuf buf) {
	buf.writeInt(pos.getX());
	buf.writeInt(pos.getY());
	buf.writeInt(pos.getZ());
	buf.writeInt(r);
}

 

@Override
public IMessage onMessage(MessageToClient message, MessageContext ctx) {

	TileEntityArmorModifier tileEntity = (TileEntityArmorModifier) Minecraft.getMinecraft().theWorld.getTileEntity(message.pos);
	System.out.println(message.r);
	tileEntity.research = message.r;

	return null;
}

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

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.