Jump to content

Zootaxz

Members
  • Posts

    14
  • Joined

  • Last visited

Everything posted by Zootaxz

  1. Hey, some time ago ive started with modding in 1.7. Now.. some months/years? later ill want to continue with 1.10.2. Something changed .. but i want to use my existing "core"-classes, which are written in 1.7. With some changes everything works fine, but .. some of these changed are weird and confuse me. I've started with a new tileentity and some gui stuff. The problem is, if i code like i learned in 1.7, my gui does nothing (e.g. no progressbar). --- readFromNBT gets called before writeToNBT: The method call readFromNBT overrides the initial-values of my class attributes which are set in constructor. I changed the readFromNBT: read only if the key exists in compound. In 1.7 (i tried it) the writeFromNBT gets called before readFromNBT. Now.. is it possible that my "base"-nbt methods in 1.10.2 are wrong? @Override public SPacketUpdateTileEntity getUpdatePacket () { // Sorry, ive added these in 1.10.2 .. do i need them? //NBTTagCompound nbtTag = new NBTTagCompound(); //writeToNBT(nbtTag); return new SPacketUpdateTileEntity(this.pos, getBlockMetadata(), getUpdateTag()); } @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt){ if(net.getDirection() == EnumPacketDirection.CLIENTBOUND){ readFromNBT(pkt.getNbtCompound()); } } Or in one of my base tileentities (TileEntityMachine) i need to comment some code out.. because it still not exists in 1.10: @Override public void update() { if (this.worldObj.isRemote) return; //if (this.hasWorldObj()) // this.getWorldObj().markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); } the "this.worldObj.isRemote .. return" only if there is no gui data in this class or? If i should post my whole code.. ask.. buts its incomplete and wont confuse you with this Thanks
  2. Hey, Thanks @ Choonster Works perfectly!
  3. Hey, What is the best way to create "tons" of same items / blocks with different names/colors? Example: Ingots, Dusts, Plates and so on have always the same texture, but another color - Currently ~ 23 different ingots, and in my project 23 different json files and 23 different textures. The same for dust, 23 different dusts > 23 json's > 23 dust textures. Is this the way i "should" do it? I tried something with 1 texture for each base (ingot, dust, plate) and pass the color in constructor for the different classes. The problems were: 1. To use only one json i need the same name for all ingots!? 2. How i can apply the color, i saved in the item class, to the texture? I dont think this is the right way, i read something about "Blockstates" for Blocks and MetaData(Damage) for Items, but with the blockstates for blocks i need all textures, too, or not? I tried something and reduces my 10 blockstate.json, 10 block.json, 10 itemblock.json and 10 block.png to 1 blockstate.json, 10 block.json, 10 itemblock.json, 10 block.png. A small reduce of files.. i think i did it wrong! And for the items, i need the same amount of json files and textures as before. I hope someone can comprehend my problem. The writing of the json files and textures is not the problem (wrote a util class which do it automatically for me), but the amount of files is in my mind not the best way. Thanks
  4. Yes others classes exists and no its not 1.10.2 because i'm very very bad and should sometimes use my brain while coding. You two got a "Thanks", because its my fail. In my first try i extraced the 1.10.2 package, but after some "gradlew intellij" tries (I wanted to change my IDE) ive deleted all the files and extraced it again. But i extraced the 1.7.1 zip file... Sorry for that guys Thanks again
  5. The problem is that neither "ModelLoader.class" nor "getRenderItem" exists!
  6. Hey (I some time ago i started developing a mod for 1.7.x. Now i want to upgrade the mod to 1.10.2. I've downloaded the recommened 1.10.2 forge version, like in 1.7.x i executes "gradlew setupDecompWorkspace eclipse" and opened it in eclipse. First time i copied all my files to the new workspace, that was a mistake, i should firstly learn more about the newer versions and watched some tutorials for 1.8/1.9 on youtube. That helped me a lot and i started to recreate some of my basic classes for the new model-support via json files. But i got an error, i have already reinstalled everythink from forge (gradlew) but got always the same errors. Different videos or forum-posts saying that i need to register the item-model json files via "Minecraft.getMinecraft().getRenderItem().getItemModelMesher()....." or with "ModelLoader..." but the method "getRenderItem()" not exists in my minecraft, and the class ModelLoader not exists. What am i doing wrong? Thanks
  7. Ummm... Redstone signal power reached 15. Lamp: On. Damn.. thats crap! Thats means if i have more than 16 different ores i should save the type in the meta-id and create for each ore a block hm? But then i need for each block a single blockstate json file.. Thank you again!
  8. Hmm.. my code follows.. but first: There are two options.. a) I'm stupid.. b) I'm stupid and haven't realized what you want say me in my last post. I tried a little bit more and.. hmpf i have only 4 different blocks in game. My inventory says there are up to 34 different blocks with 17 variants and 2 types, but by placing them i got only four different.. and two of them have complete other id oO .. they are transformed into other blocks My block code: http://pastebin.com/VKajm53K Update to the type: Each variant can be a ore block or a "block" .. like the iron block, gold block e.g., and later i want to add different ores "poor", "normal", "rich" ...
  9. Hey all, in my last post i had a few problems with the subblocks in 1.8 (http://www.minecraftforge.net/forum/index.php/topic,29405.msg151797.html#msg151797). I solved it with some greath answers Some months later i've found some time to work more on my mod and the method "placeBlockAt" in ItemBlock.class is trolling me oO. Heres a debug-Picture: http://www.screencourier.com/image/40E464535139C595jajvj3l7p8.jpg 1) I picked an ore from the inventory "Unknown Ore (Its a test 'ore')". 2) I place it on the ground 3) The placed block is vanadium ore You see the first line in the method is setting the 'newState' on the 'pos' in the world. It returns true, otherwise the method will be canceled; The next line is getting the state of the position, which should be the last set .. i think! Buts it is another oO.. why? The setBlockState Method is called with a 3rd Parameter 'flags'. I already tried to change these value to others or removing it, by override the method, but it still not works. Sry for my bad english Edit: You can see two Property Values in the BlockState. This are both PropertyEnum values. If you need some more informations please ask Thanks for help! Zootaxz
  10. Sometimes i should use my brain... thanks a lot! Solution: Add this to your block class @SideOnly(Side.CLIENT) public EnumWorldBlockLayer getBlockLayer() { return EnumWorldBlockLayer.CUTOUT; }
  11. Hey, it's me.. again! I tried to make a part of my block texture transparent, but the transparency is rendering black! Is it possible to render transparency in textures via the .json files? Thanks
  12. Okay.. i found some minutes to implement the Property into my blocks... and yes! it works! Thanks again you two [Can be closed]
  13. Thanks for your answers... i will try it and response again in some days (no really much time at the moment )
  14. Hey Forge-Community, first of all i want to excusme me for my bad english, but i will try it The thread will be divided into three parts, first my problem, second my solution and at least my research why the problem exists!? If it is not possible to read, please write it.. and i retry it! Problem I want to create one block with 18 different subtypes. This should be a ore, an ore with always the same texture but different ore colors (coloring by code), and also diffent hardness values, harvestLevels and dropRates. The problem is the meta... i have in game 18 different items with diffent colors.. yay! But if i place one of these items i place always the same block with it. Always the block with meta = 0! Solution (I write my full code..!) 1) Create a base class for all my blocks which inherits from Block (I need it for easier .json registration!) public class BlockBase extends Block{ public BlockBase(Material material){ super(material); } } 2) Create a base class for all my meta-based blocks which inherits from BlockBase. This class has a abstract method to get the item color for the ItemBlock! (I know, i can do it by the same way as for the block, but i will need it for later use!!). The enum "JSON" is for my different registration types.. i can say:"Only one json for the block (by name)" or "For each meta in the block, ignore base-name, one json" or "one json for each name + subtype"! This shouldnt be relevant for this thread, but if anyone asks.. this is why i do this! The methods "getSubTypes()", "getJSON()", "getBasicName()" and "getMetaName()" are also relevant for my own json registering and the ItemBlock class! At last this blockClass overwrites the methods "damageDropped(IBlockState state)" and "getSubBlocks(Item item, CreativeTabs tab, List list)" like in 1.7! public abstract class BlockBaseMeta extends BlockBase{ @SideOnly(Side.CLIENT) public abstract int getColorFromItemStack(ItemStack itemStack, int layer); public enum JSON{ /** Requires for each basic name plus subType a json file. * The file is located at items/[basicname + subType].json*/ BASICNAME_AND_SUBTYPE, /** Requires only for each basicname a json file. * The file is located at items/[basicname].json */ BASICNAME, /** Requires for each subType a json file, basic name will be ignored. * The file is located at items/[subType].json */ SUBTYPE; } private JSON json; private String[] subTypes; private String basicName; public BlockBaseMeta(Material material, String basicName, String[] subTypes, JSON json){ super(material); this.setUnlocalizedName(this.basicName = basicName); this.subTypes = subTypes; this.json = json; } public String[] getSubTypes(){ return this.subTypes; } public JSON getJSON(){ return this.json; } public String getBasicName(){ return this.basicName; } public String getMetaName(int meta){ return this.subTypes[meta]; } @Override public int damageDropped(IBlockState state) { return this.getMetaFromState(state); } @Override public Item getItemDropped(IBlockState state, Random random, int fortune){ return new ItemStack(this).getItem(); } @Override public void getSubBlocks(Item item, CreativeTabs tab, List list) { for(int i = 0; i < this.subTypes.length; i++) { list.add(new ItemStack(item, 1, i)); } } } 3) Create a class which inherits from ItemBlock, for the different items for the meta-block! (Here you can the calls to the methods to the class before!) public class BlockBaseMetaItem extends ItemBlock { private final BlockBaseMeta blockBaseMeta; public BlockBaseMetaItem(Block blockBaseMeta){ super(blockBaseMeta); this.setHasSubtypes(true); this.blockBaseMeta = (BlockBaseMeta)blockBaseMeta; if (this.blockBaseMeta.getJSON() == BlockBaseMeta.JSON.SUBTYPE){ for(String subType : this.blockBaseMeta.getSubTypes()){ ModelBakery.addVariantName(this, subType); } } if (this.blockBaseMeta.getJSON() == BlockBaseMeta.JSON.BASICNAME_AND_SUBTYPE){ for(String subType : this.blockBaseMeta.getSubTypes()){ ModelBakery.addVariantName(this, this.blockBaseMeta.getBasicName() + subType); } } } @Override public String getUnlocalizedName(ItemStack itemStack){ return this.blockBaseMeta.getUnlocalizedName() + this.blockBaseMeta.getSubTypes()[MathHelper.clamp_int(itemStack.getItemDamage(), 0, this.blockBaseMeta.getSubTypes().length - 1)]; } @Override public void getSubItems(Item item, CreativeTabs creativeTabs, List list){ for (int i = 0; i < this.blockBaseMeta.getSubTypes().length; i++){ list.add(new ItemStack(this, 1, i)); } } @Override public int getMetadata(int meta){ return meta; } @SideOnly(Side.CLIENT) @Override public int getColorFromItemStack(ItemStack itemStack, int layer){ return this.blockBaseMeta.getColorFromItemStack(itemStack, layer); } public String getBasicName(){ return this.blockBaseMeta.getBasicName(); } public String getSimpleName(int meta){ return this.blockBaseMeta.getMetaName(meta); } } 4) Create a base block class for my "Minerals" (I need the same for a later use!) This class sets overwrites now the methods "getColorFromItemStack(ItemStack itemStack, int renderPass)", "quantityDropped(IBlockState state, int fortune, Random random)", "getHarvestLevel(IBlockState state)", "getBlockHardness(World world, BlockPos pos)", "colorMultiplier(IBlockAccess blockAccess, BlockPos pos, int renderPass)" to set the block exact to this meta i want! To do this i write another class, which saves my meta values for this.. see it at point 5! public class BlockMineral extends BlockBaseMeta { private BlockMineralMetaData[] blockMetaDatas; public BlockMineral(String name, BlockMineralMetaData[] blockMetaDatas){ super(Material.rock, name, BlockMineralMetaData.getNameArray(blockMetaDatas), JSON.BASICNAME); this.blockMetaDatas = blockMetaDatas; this.setCreativeTab(ZCreativeTabs.blocks); this.setHardness(10); this.setResistance(10); this.setHarvestLevel("pickaxe", 10); this.setStepSound(Block.soundTypeStone); ZRegistry.registerBlock(this, BlockBaseMetaItem.class); } @Override public int getColorFromItemStack(ItemStack itemStack, int renderPass) { int meta = itemStack.getItemDamage(); if (meta > this.blockMetaDatas.length){ return 16777215; } return blockMetaDatas[meta].getColor(renderPass); } @Override public int quantityDropped(IBlockState state, int fortune, Random random) { int meta = this.getMetaFromState(state); if (blockMetaDatas[meta].quantityDropMin == blockMetaDatas[meta].quantityDropMax) return blockMetaDatas[meta].quantityDropMin; int quantity = blockMetaDatas[meta].quantityDropMin + (fortune == 0 ? 0 : random.nextInt(fortune)); return quantity > this.blockMetaDatas[meta].quantityDropMax ? this.blockMetaDatas[meta].quantityDropMin : quantity; } @Override public int getHarvestLevel(IBlockState state) { return this.blockMetaDatas[this.getMetaFromState(state)].harvestLevel; } @Override public float getBlockHardness(World world, BlockPos pos) { return this.blockMetaDatas[this.getMetaFromState(world.getBlockState(pos))].hardness; } @SideOnly(Side.CLIENT) @Override public int colorMultiplier(IBlockAccess blockAccess, BlockPos pos, int renderPass) { return this.getColor(this.getMetaFromState(blockAccess.getBlockState(pos)), renderPass); } private int getColor(int meta, int renderPass){ if (meta > this.blockMetaDatas.length){ return 16777215; } return blockMetaDatas[meta].getColor(renderPass); } } 5) This class only saves the different values for one meta value public class BlockMineralMetaData extends BlockMetaData{ public final float hardness; public final int harvestLevel; public final int quantityDropMin; public final int quantityDropMax; public BlockMineralMetaData(String name, float hardness, int harvestLevel, int quantityDropMin, int quantityDropMax, int...colors){ super(name, colors); this.hardness = hardness; this.harvestLevel = harvestLevel; this.quantityDropMin = quantityDropMin; this.quantityDropMax = quantityDropMax; } } 6) At last i only need to create an Block class for my ores.. i also can now create a class for MineralBlocks (Like IronBlock, GoldBlock e.g.). This class inherits from my BlockMineral.class! (You see there are currently one 6 different colors... this are only test-colors.. i dont wanna create a pink vanadium ore! ) public class BlockMineralOre extends BlockMineral{ /** * This enumeration exists only to get the meta id (== ordinal) * and to get a better overview over the code, in recipes e.g. */ public enum Meta{ MANGANESE(new BlockMineralMetaData("Manganese", 5, 2, 1, 4, Color.BLUE.getRGB())), NICKEL(new BlockMineralMetaData("Nickel", 5, 2, 1, 4, Color.DARK_GRAY.getRGB())), COBALT(new BlockMineralMetaData("Cobalt", 5, 2, 1, 4, Color.GRAY.getRGB())), TUNGSTEN(new BlockMineralMetaData("Tungsten", 5, 2, 1, 4, Color.CYAN.getRGB())), MOLYBDENUM(new BlockMineralMetaData("Molybdenum", 5, 2, 1, 4, Color.GREEN.getRGB())), VANADIUM(new BlockMineralMetaData("Vanadium", 5, 2, 1, 4, Color.pink.getRGB())), COPPER(new BlockMineralMetaData("Copper", 5, 2, 1, 4)), SILVER(new BlockMineralMetaData("Silver", 5, 2, 1, 4)), LEAD(new BlockMineralMetaData("Lead", 5, 2, 1, 4)), TIN(new BlockMineralMetaData("Tin", 5, 2, 1, 4)), ZINC(new BlockMineralMetaData("Zinc", 5, 2, 1, 4)), ALUMINUM(new BlockMineralMetaData("Aluminum", 5, 2, 1, 4)), MAGNESIUM(new BlockMineralMetaData("Magnesium", 5, 2, 1, 4)), BERYLLIUM(new BlockMineralMetaData("Beryllium", 5, 2, 1, 4)), LITHIUM(new BlockMineralMetaData("Lithium", 5, 2, 1, 4)), MITHRIL(new BlockMineralMetaData("Mithril", 5, 2, 1, 4)); private final BlockMineralMetaData blockMineralMetaData; Meta(BlockMineralMetaData blockMineralMetaData) { this.blockMineralMetaData = blockMineralMetaData; } public static BlockMineralMetaData[] getMetaDataArray() { ArrayList<BlockMineralMetaData> result = new ArrayList(Meta.values().length); for(Meta meta : Meta.values()){ result.add(meta.blockMineralMetaData); } result.trimToSize(); return result.toArray(new BlockMineralMetaData[result.size()]); } } public BlockMineralOre(){ super("blockOre", Meta.getMetaDataArray()); } } Why exists my problem? Now.. firstly i debugged through the methods and .. what is this.. my meta in the block is always 0. Here are some suggestions from my side!!! 1. I inherits in my BlockBaseMetaItem.class from ItemBlock .. and not from ItemBlockWithMetaData (like 1.7.. becauce it doesnt exists!) 2. In the "onItemUse" method in the ItemBlock.class isnt set the meta id to the block which is placed! 3. The "damageDropped(IBlockState state)" method in Block class, which i have overwritten in my BlockBaseMeta.class give me only a IBlockState... and how i can return the meta.. i found the method "getMetaFromState(IBlockState state)" in the Block class.. but the content of this method is .. i dont know.. it checks only if if the state is null and not empty, return an error - otherwise always 0... but this is not right or? Now.. i will finish this thread.. and if you think.. omg learn english or omg youre are fcking n00b... then say it! Thanks for your help. Greeting Zootaxz
×
×
  • Create New...

Important Information

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