
brsgamer
Members-
Posts
29 -
Joined
-
Last visited
Converted
-
Gender
Undisclosed
-
Personal Text
I am new!
brsgamer's Achievements

Tree Puncher (2/8)
0
Reputation
-
[SOLVED] [1.7.10] TileEntity does not update after leaving world.
brsgamer replied to brsgamer's topic in Modder Support
Thanks! That was it. -
[SOLVED] [1.7.10] TileEntity does not update after leaving world.
brsgamer replied to brsgamer's topic in Modder Support
1) isn't needed, removed. 2) as said isn't needed anymore. 3) will change that. 4) yes i have registered it. -
[SOLVED] [1.7.10] TileEntity does not update after leaving world.
brsgamer replied to brsgamer's topic in Modder Support
1) isn't needed, removed. 2) as said isn't needed anymore. 3) will change that. 4) yes i have registered it. -
[SOLVED] [1.7.10] TileEntity does not update after leaving world.
brsgamer replied to brsgamer's topic in Modder Support
Hello, I have a TileEntity in my mod. It's main objective is to detect if certain player is in range and if it's true, then change an int. It works well when it's first placed, but after log off log on into world, it does not update till i hit it with something. Any ideas why is it so? Here's code: package com.lessoner.angelsdemons.TileEntities; import com.lessoner.angelsdemons.Blocks.AVDBlocks; import com.lessoner.angelsdemons.IEEP.AVDPlayerStats; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; /** * Created by Anguarmas on 1/15/2016. */ public class TileEntityAltar extends TileEntity { private static final String ALTAR_NBT = "altar"; private static EntityPlayer player; /* Rotation */ public float rotation = 0; /* Scale */ public float scale = 0; private int altarLevel; private float altarExperience; public static String owner; private int activatingRangeFromPlayer = 20; private int cooldown = 21; public TileEntityAltar(){ this.player = Minecraft.getMinecraft().thePlayer; altarLevel = 0; } @Override public void updateEntity() { super.updateEntity(); if (worldObj.isRemote){ rotation += 0.5f; scale = 0.5f; } if (!worldObj.isRemote) { if(cooldown > 0 ){ --cooldown; if(cooldown <= 1) { System.out.println(isActivated()); if (isActivated()) { AVDPlayerStats props = AVDPlayerStats.get(this.worldObj.getPlayerEntityByName(owner)); props.changeAVD(0.1f); AVDPlayerStats.get(this.worldObj.getPlayerEntityByName(owner)).sync(); System.out.println(props.getCurrentAVDLevel()); } cooldown = 21; } } } } public boolean isActivated() { if(this.worldObj.getClosestPlayer((double)this.xCoord + 0.5D,(double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D, (double)this.activatingRangeFromPlayer) != null){ if(this.worldObj.getClosestPlayer((double)this.xCoord + 0.5D,(double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D, (double)this.activatingRangeFromPlayer) == this.worldObj.getPlayerEntityByName(owner)){ return true; } } return false; } public void readFromNBT(NBTTagCompound tagCompound) { NBTTagCompound stats = (NBTTagCompound) tagCompound.getTag(ALTAR_NBT); this.altarLevel = stats.getInteger("Level"); this.owner = stats.getString("Owner"); this.altarExperience = stats.getFloat("Experience"); } public void writeToNBT(NBTTagCompound tagCompound) { NBTTagCompound stats = new NBTTagCompound(); stats.setInteger("Level", altarLevel); stats.setString("Owner", owner); stats.setFloat("Experience", altarExperience); tagCompound.setTag(ALTAR_NBT,stats); } public void changeXP(float amount) { this.altarExperience= this.altarExperience + amount; } } -
Hello, I have a TileEntity in my mod. It's main objective is to detect if certain player is in range and if it's true, then change an int. It works well when it's first placed, but after log off log on into world, it does not update till i hit it with something. Any ideas why is it so? Here's code: package com.lessoner.angelsdemons.TileEntities; import com.lessoner.angelsdemons.Blocks.AVDBlocks; import com.lessoner.angelsdemons.IEEP.AVDPlayerStats; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; /** * Created by Anguarmas on 1/15/2016. */ public class TileEntityAltar extends TileEntity { private static final String ALTAR_NBT = "altar"; private static EntityPlayer player; /* Rotation */ public float rotation = 0; /* Scale */ public float scale = 0; private int altarLevel; private float altarExperience; public static String owner; private int activatingRangeFromPlayer = 20; private int cooldown = 21; public TileEntityAltar(){ this.player = Minecraft.getMinecraft().thePlayer; altarLevel = 0; } @Override public void updateEntity() { super.updateEntity(); if (worldObj.isRemote){ rotation += 0.5f; scale = 0.5f; } if (!worldObj.isRemote) { if(cooldown > 0 ){ --cooldown; if(cooldown <= 1) { System.out.println(isActivated()); if (isActivated()) { AVDPlayerStats props = AVDPlayerStats.get(this.worldObj.getPlayerEntityByName(owner)); props.changeAVD(0.1f); AVDPlayerStats.get(this.worldObj.getPlayerEntityByName(owner)).sync(); System.out.println(props.getCurrentAVDLevel()); } cooldown = 21; } } } } public boolean isActivated() { if(this.worldObj.getClosestPlayer((double)this.xCoord + 0.5D,(double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D, (double)this.activatingRangeFromPlayer) != null){ if(this.worldObj.getClosestPlayer((double)this.xCoord + 0.5D,(double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D, (double)this.activatingRangeFromPlayer) == this.worldObj.getPlayerEntityByName(owner)){ return true; } } return false; } public void readFromNBT(NBTTagCompound tagCompound) { NBTTagCompound stats = (NBTTagCompound) tagCompound.getTag(ALTAR_NBT); this.altarLevel = stats.getInteger("Level"); this.owner = stats.getString("Owner"); this.altarExperience = stats.getFloat("Experience"); } public void writeToNBT(NBTTagCompound tagCompound) { NBTTagCompound stats = new NBTTagCompound(); stats.setInteger("Level", altarLevel); stats.setString("Owner", owner); stats.setFloat("Experience", altarExperience); tagCompound.setTag(ALTAR_NBT,stats); } public void changeXP(float amount) { this.altarExperience= this.altarExperience + amount; } }
-
I have done this in past, released other mod on 1.8, but now I started new project and did everything like in old one and I can't get models working.
-
Hello people, Having strange issue, which I never had in the past. Console says that Model definition for location angelsvsdemons:item.sacrificial_dagger#inventory not found I checked everything and it should be correct, searched alot on google and forums, couldn't fix this. Maybe you can figure it out Here's Classes: public class AVDItems { public static Item sacrificial_dagger; public static void init(){ sacrificial_dagger = new ItemSacrificialDagger().setUnlocalizedName("sacrificial_dagger").setCreativeTab(AVDMod.AVDTab); } public static void register(){ GameRegistry.registerItem(sacrificial_dagger, sacrificial_dagger.getUnlocalizedName()); } public static void registerRender(){ registerRenderers(sacrificial_dagger,0); } private static void registerRenderers(Item item, int metadata){ Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, metadata, new ModelResourceLocation(References.MODID + ":" + item.getUnlocalizedName().substring(5), "inventory")); } } public class ClientProxy extends CommonProxy { @Override public void registerRenderers(){ AVDItems.registerRender(); } } @Mod(modid = References.MODID, name = References.NAME, version = References.VERSION) public class AVDMod { @SidedProxy(clientSide = References.ClientProxy, serverSide = References.CommonProxy) public static CommonProxy proxy; public static CreativeTabs AVDTab; @Mod.EventHandler public void preInit(FMLPreInitializationEvent e){ AVDTab = new CreativeTabs("avdtab") { @Override public Item getTabIconItem() { return Items.apple; } }; AVDBlocks.init(); AVDItems.init(); } @Mod.EventHandler public void init(FMLInitializationEvent e){ AVDItems.register(); AVDBlocks.register(); proxy.registerRenderers(); } @Mod.EventHandler public void postInit(FMLPostInitializationEvent e){ MinecraftForge.EVENT_BUS.register(new EventHandler()); } } I have my model file in assets/modid/models/item/sacrificial_dagger.json
-
Okay Thanks
-
That maybe true too. For example i want to be like starting book in tinkers construct. The book is given to you for the first time only.
-
I'm doing that. When you break the block it gives you the items, but i want the block to be given to player only once.
-
I'm currently making the new year's update for my mod. The update just fixes some bugs and adds a gift block. The idea is simple, when you login into game, you get the gift block and when you place it and break it you get some items, that's the easy part. I want the gift to be given to player only once. I made a tile entity, and read write nbt functions and a boolean. I made the boolean false when the block gets clicked, but the block still spawns in the inventory every time i login. : PlayerLoggedInEvent: if(TileEntityChristmasGift.canGiveGift){ e.player.inventory.addItemStackToInventory(new ItemStack(TreeOresBlocks.TreeOresChristmasGift,1,0)); } TileEntityChristmasGift: public static boolean canGiveGift = true; @Override public void writeToNBT(NBTTagCompound nbtTagCompound) { super.writeToNBT(nbtTagCompound); nbtTagCompound.setBoolean("canGiveGift", canGiveGift); } @Override public void readFromNBT(NBTTagCompound nbtTagCompound) { super.readFromNBT(nbtTagCompound); this.canGiveGift = nbtTagCompound.getBoolean("canGiveGift"); } Block Class: public TreeOresChristmasGift(Material mat) { super(mat); } public TileEntity createTileEntity(World world, int metadata) { return new TileEntityChristmasGift(); } public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) { ArrayList<ItemStack> ret = new ArrayList<ItemStack>(); for(int i = 0; i <4; i++) { ret.add(new ItemStack(TreeOresBlocks.TreeOresBossSaplings1,1,i)); ret.add(new ItemStack(TreeOresBlocks.TreeOresBossSaplings2,1,i)); }for(int i = 0; i <3; i++) { ret.add(new ItemStack(TreeOresBlocks.TreeOresBossSaplings3,1,i)); } return ret; } public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) { if(world.isRemote){ TileEntity te = world.getTileEntity(x, y, z); //Get the TileEntity at this location if(te instanceof TileEntityChristmasGift){ ((TileEntityChristmasGift) te).canGiveGift=false; world.setTileEntity(x,y,z,te); } } } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { this.blockIcon = iconRegister.registerIcon(References.MODID + ":" + this.getTextureName()); } Thanks in advance for any help
-
[1.7.10] (Solved) setContainerItem for item with metadata
brsgamer replied to brsgamer's topic in Modder Support
It Worked! Thanks again -
[1.7.10] (Solved) setContainerItem for item with metadata
brsgamer replied to brsgamer's topic in Modder Support
Thanks for reply. I think that should work. How didn't I think about that? I'll post the results later. -
package com.lessoner.treeores.Items; import com.lessoner.treeores.References; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import java.util.List; /** * Created by Anguarmas on 9/23/2015. */ public class TreeOresTransformers extends Item { public static final String[] types = new String[]{"normal", "nether", "reinforced"}; @SideOnly(Side.CLIENT) private IIcon[] iicon; public TreeOresTransformers() { this.setHasSubtypes(true); this.setMaxDamage(0); this.setContainerItem(this); } /** * Gets an icon index based on an item's damage value */ @SideOnly(Side.CLIENT) public IIcon getIconFromDamage(int damage) { int j = MathHelper.clamp_int(damage, 0, 2); return this.iicon[j]; } /** * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have * different names based on their damage or NBT. */ public String getUnlocalizedName(ItemStack is) { int i = MathHelper.clamp_int(is.getItemDamage(), 0, 2); return super.getUnlocalizedName() + "." + types[i]; } /** * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) */ @SideOnly(Side.CLIENT) public void getSubItems(Item item, CreativeTabs creativeTabs, List list) { for (int i = 0; i < 3; ++i) { list.add(new ItemStack(item, 1, i)); } } @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { this.iicon = new IIcon[types.length]; for (int i = 0; i < types.length; ++i) { this.iicon[i] = iconRegister.registerIcon(References.MODID + ":" + this.getIconString() + "_" + types[i]); } } } ^That's my code for item. I want it to not destroy when used in crafting recipe. if I set container item like I have, it always gives me the item with metadata 0 while crafting. how can I fix this?
-
Okay!