Everything posted by brsgamer
-
[SOLVED] [1.7.10] TileEntity does not update after leaving world.
Thanks! That was it.
-
[SOLVED] [1.7.10] TileEntity does not update after leaving world.
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.
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.
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; } }
-
[SOLVED] [1.7.10] TileEntity does not update after leaving world.
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; } }
-
[1.8] Model files and texture issues
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.
-
[1.8] Model files and texture issues
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
-
[1.7.10] need help with NBT and TileEntity
Okay Thanks
-
[1.7.10] need help with NBT and TileEntity
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.
-
[1.7.10] need help with NBT and TileEntity
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.
-
[1.7.10] need help with NBT and TileEntity
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
It Worked! Thanks again
-
[1.7.10] (Solved) setContainerItem for item with metadata
Thanks for reply. I think that should work. How didn't I think about that? I'll post the results later.
-
[1.7.10] (Solved) setContainerItem for item with metadata
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?
-
[1.8] Conflicting Entity Id's
Okay!
-
[1.8] Conflicting Entity Id's
I read the last post and by latest version do you mean 11.14.3.1450?
-
[1.8] Conflicting Entity Id's
public static void registerMonsters(Class entityClass, String name, int entityId){ EntityRegistry.registerModEntity(entityClass, name, entityId, References.instance, 64, 1, true); } My new method for registering. Yes there aren't more spawn eggs, but I really don't need them cause I have items for spawning them
-
[1.8] Conflicting Entity Id's
Okay Thanks!
-
[1.8] Conflicting Entity Id's
So I don't need to registerGlobalEntityId. Just use registerModEntity and still use findGlobalUniqueEntityId or just give any random number with generator or something?
-
[1.8] Conflicting Entity Id's
A guy wanted to use my mod in modpack, but there was a conflict with entity id's. Here's my entity handler class: public class EntityHandler { public static void registerMonsters(Class entityClass, String name){ int entityId = EntityRegistry.findGlobalUniqueEntityId(); long x = name.hashCode(); Random random = new Random(x); int mainColor = random.nextInt() * 16777215; int subColor = random.nextInt() * 16777215; EntityRegistry.registerGlobalEntityID(entityClass, name, entityId); EntityRegistry.registerModEntity(entityClass, name, entityId, References.instance, 64, 1, true); EntityList.entityEggs.put(Integer.valueOf(entityId), new EntityList.EntityEggInfo(entityId, mainColor, subColor)); } } I'm using EntityRegistry.findGlobalUniqueEntityId();. Should it be anything else? or is the conflict caused by other mod?
-
[1.8] Strange color issues with custom leaves (SOLVED)
It needed some work but did a trick. Thanks!
-
[1.8] Strange color issues with custom leaves (SOLVED)
That fixed it. Thanks! Do you have any suggestions about coloring leaves in inventory?
-
[1.8] Strange color issues with custom leaves (SOLVED)
That fixed the transparency, but here comes another issue
-
[1.8] Strange color issues with custom leaves (SOLVED)
I'm updating my mod and I have a strange issue. I have 11 types of leaves. I finally got the coloring to work on placed block, but I noticed that leaves are not transparent,colors are little bit off and also they aren't colored in inventory(water level is another mod): Why is this happening? Here's my leaf class: package com.lessoner.treeores.trees; import java.util.List; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockLeaves; import net.minecraft.block.BlockPlanks; import net.minecraft.block.BlockPlanks.EnumType; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.stats.StatList; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.world.ColorizerFoliage; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import com.google.common.base.Predicate; import com.lessoner.treeores.TreeOresBlocks; public class TreeOresLeaf1 extends BlockLeaves { public static final PropertyEnum VARIANT = PropertyEnum.create("variant", TreeOresLog1.EnumType.class, new Predicate() { public boolean apply(TreeOresLog1.EnumType type) { return type.getMetadata() < 4; } public boolean apply(Object p_apply_1_) { return this.apply((TreeOresLog1.EnumType) p_apply_1_); } }); public TreeOresLeaf1() { this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, TreeOresLog1.EnumType.IRON) .withProperty(CHECK_DECAY, Boolean.valueOf(true)).withProperty(DECAYABLE, Boolean.valueOf(true))); } public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Item.getItemFromBlock(TreeOresBlocks.Saplings1); } @SideOnly(Side.CLIENT) public int getRenderColor(IBlockState state) { if (state.getBlock() != this) { return super.getRenderColor(state); } else { TreeOresLog1.EnumType enumtype = (TreeOresLog1.EnumType) state.getValue(VARIANT); return enumtype == TreeOresLog1.EnumType.GOLD ? LeaveColours.gold() : (enumtype == TreeOresLog1.EnumType.COAL ? LeaveColours.coal() : (enumtype == TreeOresLog1.EnumType.IRON ? LeaveColours.iron() : (enumtype == TreeOresLog1.EnumType.REDSTONE ? LeaveColours .redstone() : super.getRenderColor(state)))); } } @SideOnly(Side.CLIENT) public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) { IBlockState iblockstate = worldIn.getBlockState(pos); if (iblockstate.getBlock() == this) { TreeOresLog1.EnumType enumtype = (TreeOresLog1.EnumType) iblockstate.getValue(VARIANT); if (enumtype == TreeOresLog1.EnumType.IRON) { return LeaveColours.iron(); } if (enumtype == TreeOresLog1.EnumType.GOLD) { return LeaveColours.gold(); } if (enumtype == TreeOresLog1.EnumType.COAL) { return LeaveColours.coal(); } if (enumtype == TreeOresLog1.EnumType.REDSTONE) { return LeaveColours.redstone(); } } return super.colorMultiplier(worldIn, pos, renderPass); } protected void dropApple(World worldIn, BlockPos pos, IBlockState state, int chance) { if (state.getValue(VARIANT) == TreeOresLog1.EnumType.IRON && worldIn.rand.nextInt(chance) == 0) { spawnAsEntity(worldIn, pos, new ItemStack(Items.iron_ingot, 1, 0)); } if (state.getValue(VARIANT) == TreeOresLog1.EnumType.GOLD && worldIn.rand.nextInt(chance) == 0) { spawnAsEntity(worldIn, pos, new ItemStack(Items.gold_ingot, 1, 0)); } if (state.getValue(VARIANT) == TreeOresLog1.EnumType.COAL && worldIn.rand.nextInt(chance) == 0) { spawnAsEntity(worldIn, pos, new ItemStack(Items.coal, 1, 0)); } if (state.getValue(VARIANT) == TreeOresLog1.EnumType.REDSTONE && worldIn.rand.nextInt(chance) == 0) { spawnAsEntity(worldIn, pos, new ItemStack(Items.redstone, 1, 0)); } } protected int getSaplingDropChance(IBlockState state) { return state.getValue(VARIANT) == TreeOresLog1.EnumType.REDSTONE ? 40 : super.getSaplingDropChance(state); } @SideOnly(Side.CLIENT) public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) { list.add(new ItemStack(itemIn, 1, TreeOresLog1.EnumType.IRON.getMetadata())); list.add(new ItemStack(itemIn, 1, TreeOresLog1.EnumType.GOLD.getMetadata())); list.add(new ItemStack(itemIn, 1, TreeOresLog1.EnumType.COAL.getMetadata())); list.add(new ItemStack(itemIn, 1, TreeOresLog1.EnumType.REDSTONE.getMetadata())); } protected ItemStack createStackedBlock(IBlockState state) { return new ItemStack(Item.getItemFromBlock(this), 1, ((TreeOresLog1.EnumType) state.getValue(VARIANT)).getMetadata()); } public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(VARIANT, TreeOresLog1.EnumType.byMetadata((meta & 3) % 4)) .withProperty(DECAYABLE, Boolean.valueOf((meta & 4) == 0)).withProperty(CHECK_DECAY, Boolean.valueOf((meta & > 0)); } public int getMetaFromState(IBlockState state) { byte b0 = 0; int i = b0 | ((TreeOresLog1.EnumType) state.getValue(VARIANT)).getMetadata(); if (!((Boolean) state.getValue(DECAYABLE)).booleanValue()) { i |= 4; } if (((Boolean) state.getValue(CHECK_DECAY)).booleanValue()) { i |= 8; } return i; } protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { VARIANT, CHECK_DECAY, DECAYABLE }); } public int damageDropped(IBlockState state) { return ((TreeOresLog1.EnumType) state.getValue(VARIANT)).getMetadata(); } public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te) { if (!worldIn.isRemote && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears) { player.triggerAchievement(StatList.mineBlockStatArray[block.getIdFromBlock(this)]); spawnAsEntity(worldIn, pos, new ItemStack(Item.getItemFromBlock(this), 1, ((TreeOresLog1.EnumType) state.getValue(VARIANT)).getMetadata())); } else { super.harvestBlock(worldIn, player, pos, state, te); } } @Override public List<ItemStack> onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) { IBlockState state = world.getBlockState(pos); return new java.util.ArrayList( java.util.Arrays.asList(new ItemStack(this, 1, ((TreeOresLog1.EnumType) state.getValue(VARIANT)).getMetadata()))); } @Override public EnumType getWoodType(int meta) { return null; } } LeaveColours class just has 11 integers with rgb values. (this class just has 4 leaves) Thanks in advance.
-
[1.8] How are map colors generated?
Well... I tried RGB but it came up with different color. I don't know, is it really just rgb values?
IPS spam blocked by CleanTalk.