Jump to content

TheA13X

Members
  • Posts

    30
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • Location
    Germany
  • Personal Text
    Hi, I'm an Alex!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

TheA13X's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. No. No they are not. I Debugged Forge's building process line by line, so I know that the all registry events are fired after the FMLPreInitializationEvent. Also if the Registry Events were fired before the lists are populated, there would be no exception in the first place.
  2. Hi there! I'm currently updating one of my mods to 1.12 (and 1.12.2). While doing that I ran into this exception: Here's what I found out so far: The exception is caused, because the Lambda Functions, given to the Search Tree as an argument, returned null: //Citing Minecraft.java /*618*/SearchTree<ItemStack> searchtree = new SearchTree<ItemStack>( /* */(p_193988_0_) -> /*619*/{ /*620*/ return (List)p_193988_0_.getTooltip((EntityPlayer)null, ITooltipFlag.TooltipFlags.NORMAL).stream().map(TextFormatting::getTextWithoutFormattingCodes).map(String::trim).filter((p_193984_0_) -> { /*621*/ return !p_193984_0_.isEmpty(); /*622*/ }).collect(Collectors.toList()); /*623*/}, /* */(p_193985_0_) -> /*624*/{ /*625*/ return Collections.singleton(Item.REGISTRY.getNameForObject(p_193985_0_.getItem())); /*626*/}); -> Item.REGISTRY.getNameForObject(ItemStack.getItem) returned null. The question that remains is, why? It must have something to do with the registration process. Therefore I have to tell you How the Registration works: 1.Loading When the FMLPreInitializationEvent is fired, all blocks/"pure" Items get constructed and loaded into static lists located in my ModBlocks/ModItems class 2. Registering On the Register<Item>-Event the following code is executed: //Citing Registrator.java /*17*/@SubscribeEvent /*18*/public static void registerItems(RegistryEvent.Register<Item> event){ /*19*/ event.getRegistry().register(ModItems.parcelInstance()); //Register the only "pure" Item in this Mod. Does not throw the NullPointerException in the Search Tree /*20*/ ModBlocks.registerAllItems(event.getRegistry());//Register all the Block Items in this Mod } RegisterAllItems: public static void registerAllItems(IForgeRegistry<Item> reg) { registerAllLogItems(reg); registerAllLeavesItems(reg); registerAllSaplingItems(reg); registerAllWoodItems(reg); registerAllStairsItems(reg); registerAllDoorItems(reg); registerAllSingleSlabItems(reg); } Example for a Registering function: //Citing ModBlocks.java /*208*/private static void registerAllLogItems(IForgeRegistry<Item> reg) //It crashed on the Log Block Item btw. /*209*/{ /*210*/ int logCount = 0; /*211*/ for (final LogBlock block : logBlocks)//for every Log Block... /*212*/ { /*213*/ String name = String.format("log%d", logCount);//...define registry name... /*214*/ ImmutableList<String> subblockNames = block.getSubBlockNames();//...get all the Subblock names... /*215*/ if(block instanceof ModLogBlock){//... if type 1... /*216*/ reg.register(new ModLogItem(block,(ModLogBlock)block,subblockNames.toArray(new String[subblockNames.size()])).setRegistryName(name));//...register Item using the Type 1 item constructor after setting the registry name /*217*/ } /*218*/ else if(block instanceof ModLog2Block){//... if type 2... /*219*/ reg.register(new ModLogItem(block,(ModLog2Block)block,subblockNames.toArray(new String[subblockNames.size()])).setRegistryName(name));//...register Item using the Type 2 item constructor after setting the registry name /*220*/ } /*221*/ else if(block instanceof ModLog3Block){//... if type 3... /*222*/ reg.register(new ModLogItem(block,(ModLog3Block)block,subblockNames.toArray(new String[subblockNames.size()])).setRegistryName(name));//...register Item using the Type 3 item constructor after setting the registry name /*223*/ } /*224*/ else{//... if type 4... /*225*/ reg.register(new ModLogItem(block,(ModLog4Block)block,subblockNames.toArray(new String[subblockNames.size()])).setRegistryName(name));//...register Item using the Type 4 item constructor after setting the registry name /*226*/ } /*227*/ logCount++; /*228*/ } /*229*/} The Block registration works in the same way, only with on the Register<Block>-Event, instead of the item one. I guess it's also important How the Block Classes look like Essentially I have a mod (Koresample) containing all the "basic" block/item classes and my specialized Mod (Dendrology) containing Classes with logic for the specific tree types. Pasting all of them would be way to much so I'll just link my GitHub. Koresample Dendrology: I know it's a bit much, but this problem seems quite unusual... Thanks for trying and help me out. I got nothin'
  3. So there's an abstract function called getWoodtype which returns a BlockPlanks.EnumType and I wanted to return the enum type of my Mod's Planks, but that's completely unnecessary. I extended the class and it works now (apart from a visual glich due to the transparency, but that's another story) Thanks
  4. Yes I can. Sure it's a matter of trust since it could break if someone calls the function outside of a client-only class, but I'm the only author, so it won't happen. It's in the part of the class I left out and replaced it with I don't even know anymore. Let me check this
  5. You misunderstood me. They do NOT Decay, but I want them to. Also I just noticed I forgot to paste the properties in there. It's fixed now. I just updated 1.7.10 code from another author. I thought about recoding it completely to make it more uncomplicated, but this can wait. Also registerBlockModelsis called from the client proxy. It's just positioned in the block class to allow different behaviour for every single block. It's just clearer that way. Like the comments say I cloned MCs BlockLeaves Class and cut out the old functions, since they are the same, as the ones from the original. The randomTick function is there.
  6. Wow that was fast. Thanks man ^^ Well, first we have the Superclass: public abstract class LeavesBlock extends Block implements net.minecraftforge.common.IShearable { public static final int CAPACITY = 4; private static final int METADATA_MASK = CAPACITY - 1; int[] surroundings; private final ImmutableList<DefinesLeaves> subBlocks; protected LeavesBlock(Collection<? extends DefinesLeaves> subBlocks) { super(Material.LEAVES); checkArgument(!subBlocks.isEmpty()); checkArgument(subBlocks.size() <= CAPACITY); this.subBlocks = ImmutableList.copyOf(subBlocks); this.setTickRandomly(true); this.setHardness(0.2F); this.setLightOpacity(1); this.setSoundType(SoundType.PLANT); setUnlocalizedName("leaves"); } private static int mask(int metadata) {return metadata & METADATA_MASK;} protected static String getUnwrappedUnlocalizedName(String unlocalizedName) { return unlocalizedName.substring(unlocalizedName.indexOf('.') + 1); } protected final List<DefinesLeaves> subBlocks() { return Collections.unmodifiableList(subBlocks); } @Override public final Item getItemDropped(IBlockState state, Random unused, int unused2) { return Item.getItemFromBlock(subBlocks.get(mask(this.getMetaFromState(state))).saplingDefinition().saplingBlock()); } @Override public int damageDropped(IBlockState state) { return subBlocks.get(mask(this.getMetaFromState(state))).saplingDefinition().saplingSubBlockVariant().ordinal(); } public final String[] getSpeciesNames() //func_150125_e { final List<String> names = Lists.newArrayList(); for (final DefinesLeaves subBlock : subBlocks) names.add(subBlock.speciesName()); return names.toArray(new String[names.size()]); } public final String getUnlocalizedName() { return String.format("tile.%s%s", resourcePrefix(), getUnwrappedUnlocalizedName(super.getUnlocalizedName())); } public final int getDamageValue(World world, BlockPos pos) { return this.getMetaFromState(world.getBlockState(pos)) & 3; } public final void getSubBlocks(Item item, CreativeTabs unused, List subBlocks) { for (int i = 0; i < this.subBlocks.size(); i++) subBlocks.add(new ItemStack(item, 1, i)); } public void registerBlockModels() { for (DefinesLeaves define : subBlocks()) { ModelResourceLocation typeLocation = new ModelResourceLocation(getRegistryName(),"check_decay=true,decayable=true,variant="+define.leavesSubBlockVariant().name().toLowerCase()); Item blockItem = Item.getItemFromBlock(define.leavesBlock()); ModelLoader.setCustomModelResourceLocation(blockItem,define.leavesSubBlockVariant().ordinal(),typeLocation); } } protected abstract String resourcePrefix(); //Stuff cloned from BlockLeaves... public abstract Enum getWoodType(int meta); //Stuff cloned from BlockLeaves... } And then several Mod Classes which only difference is the Enum used for getWoodType() Here is one of them public final class ModLeavesBlock extends LeavesBlock { public static final PropertyEnum VARIANT = PropertyEnum.create("variant", ModLogBlock.EnumType.class); public ModLeavesBlock(Iterable<? extends DefinesLeaves> subBlocks) { super(ImmutableList.copyOf(subBlocks)); setCreativeTab(TheMod.INSTANCE.creativeTab()); this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, ModLogBlock.EnumType.ACEMUS).withProperty(CHECK_DECAY, Boolean.TRUE).withProperty(DECAYABLE, Boolean.TRUE)); } @Override public int quantityDropped(Random random) { final int rarity = Settings.INSTANCE.saplingDropRarity(); return rarity == 0 || random.nextInt(rarity) != 0 ? 0 : 1; } @Override protected BlockStateContainer createBlockState(){ BlockStateContainer bs = new BlockStateContainer(this, new IProperty[]{VARIANT,CHECK_DECAY,DECAYABLE}); return bs; } @Override public ModLogBlock.EnumType getWoodType(int meta) { return ModLogBlock.EnumType.fromId(meta); } @Override protected String resourcePrefix() { return TheMod.getResourcePrefix(); } @Override public List<ItemStack> onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) { ArrayList<ItemStack> list=new ArrayList<ItemStack>(); list.add(new ItemStack(Item.getItemFromBlock(this),1,getMetaFromState(world.getBlockState(pos)))); return list; } @Override public IBlockState getStateFromMeta(int meta) { IBlockState state = getDefaultState(); switch(meta/4){ case 0: state = state.withProperty(CHECK_DECAY,true).withProperty(DECAYABLE,true); break; case 1: state = state.withProperty(CHECK_DECAY,true).withProperty(DECAYABLE,false); break; case 2: state = state.withProperty(CHECK_DECAY,false).withProperty(DECAYABLE,true); break; case 3: state = state.withProperty(CHECK_DECAY,false).withProperty(DECAYABLE,false); break; } state = state.withProperty(VARIANT,ModLogBlock.EnumType.fromId(meta%4)); return state; } @Override public int getMetaFromState(IBlockState state) { ModLogBlock.EnumType type = (ModLogBlock.EnumType) state.getValue(ModLogBlock.VARIANT); boolean check = (Boolean) state.getValue(CHECK_DECAY); boolean dcable = (Boolean) state.getValue(CHECK_DECAY); int par = check?dcable?0:1:dcable?2:3; return par*4+type.ordinal(); } protected boolean needMask(){ return false; } @Override public int damageDropped(IBlockState state) { return getMetaFromState(state.withProperty(CHECK_DECAY,true).withProperty(DECAYABLE,true)); } @Override protected int getSaplingDropChance(IBlockState state) { return Settings.INSTANCE.saplingDropRarity(); } }
  7. Hello world. I'm making a Tree Mod and it turns out, that my leaves won't decay. When a tree get generated, all leaves are set with the standard block state (aka with decayable and check_decay set to true). After the generation most leaves have check_dekay set to false. Since this is also the case with vanilla leaves I guess that's normal though. When chopping down a tree (minecraft style) the leaves won't decay and after restarting the game the leaves have both decayable and check_decay set to false Things that may be important to notice, is that my Leaves are multitextured. The Blockstate also contains a variant variable. I also don't really know what code I should post here. Any Suggestions?
  8. Oh, sorry. I used the wrong jars. Starting the mod with the obfuscated versions worked.
  9. Hello world. Another error I don't understand, but may be easy to solve if knowing how forge works. When starting the mod on forge 2228 in IDE everything is fine, but if its loaded in the client I get There was a severe problem during mod loading that has caused the game to fail net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Ancient Trees (dendrology) Caused by: java.lang.NoSuchFieldError: CHESTS_VILLAGE_BLACKSMITH CHESTS_VILLAGE_BLACKSMITH is a static field from the LootTableList, which definitely does exist. Code where the error is thrown: final Map<ResourceLocation, Integer> map = Maps.newHashMap(); map.put(CHESTS_VILLAGE_BLACKSMITH, 0); map.put(CHESTS_SPAWN_BONUS_CHEST, 0); map.put(CHESTS_DESERT_PYRAMID, 1); map.put(CHESTS_SIMPLE_DUNGEON, 1); map.put(CHESTS_JUNGLE_TEMPLE, 1); map.put(CHESTS_JUNGLE_TEMPLE_DISPENSER, 0); map.put(CHESTS_ABANDONED_MINESHAFT, 1); map.put(CHESTS_STRONGHOLD_CORRIDOR, 1); map.put(CHESTS_STRONGHOLD_CROSSING, 1); map.put(CHESTS_STRONGHOLD_LIBRARY, 1); map.put(CHESTS_END_CITY_TREASURE, 5); map.put(CHESTS_NETHER_BRIDGE, 5); map.put(CHESTS_IGLOO_CHEST, 1); return map; It seems that none of these Fields exist in client. If I remove CHESTS_VILLAGE_BLACKSMITH, I get the same error on CHESTS_SPAWN_BONUS_CHEST ...
  10. Great. I'll switch to that method, when making the mod for 1.10+
  11. Oops. I'm sorry for making you so much work. At least the outdated build.gradle and the obsolete ProvidesPotionEffect implementation could be avoided if I had a Git client I can handle. Thank you for the tips though. My code is pretty chaotic regarding the location of proxied functions, but I works. I never had a crash because of some non-server code. Well that's interesting. I'll keep it in mind. See, I implemented the Item spawning on both the common and the client proxy. The common one just returns the Item, the client side adds a translation first. Maybe it isn't ought to be used this way, but it seemed to work.
  12. I know. That's what I normally do, I just had to do it this way, because the client told me that "everything is up to date"
  13. Oh yeah. Didn't notice, sorry. I fixed it now (for 1.9) Not in the git repository. I have a multi-project-workspace in IntelliJ, so the settings file is in the superdirectory. I'll add the KoreSample repository as a submodule after I figured out how, but you'll have to create the settings.gradle yourself. I just didn't know it's possible back then.
  14. IntelliJ's output directory is project/build/classes I have a git repository for the mod LOOK Wait. it hasn't updated to 1.9... Now it has. (1.9 branch) You'll also need it's dependency. Found here (1.9 branch)
  15. Are you sure? It's a FileNotFoundException which usually contains the path used for an I/O operation which is usually the real path. Anyways. The assets folder is in src/main/resources like it should. It's also included in to the root folder of the mod's jar file. I've run the mod only over the IDE though and while the assets folder does exists in build/resources/main the IDE's output folder is build/classes/main. But it should work anyway right? I mean the assets is copied to the build folder. Also I have a custom LanguageMapper who reads the lang files on pre-init and if the assets were missing, minecraft would crash here. if(test.getLocation().toString().startsWith("jar:")) fallback = Optional.of(new LangMap(TheMod.class.getResourceAsStream("/assets/dendrology/lang/en_US.lang"))); else{ String pathToCode = "../build/resources/main"; File test2 = new File(pathToCode); fallback = Optional.of(new LangMap(new FileInputStream(pathToCode+"/assets/dendrology/lang/en_US.lang"))); }
×
×
  • Create New...

Important Information

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