Jump to content

Recommended Posts

Posted (edited)

Hello i am making a colored planks block and i have some issues with it. I think i done the whole code-side thing right because when i place the block and click it (debug way of switching colors) the text on it changes but there is no texture

you can find code here:

https://github.com/lukas2005/MultiCraft-Mod

i used Choonsters Test Mod 3 as a example: https://github.com/Choonster-Minecraft-Mods/TestMod3/blob/1.12.2/src/main/java/choonster/testmod3/block/BlockVariants.java

and mc log

  Reveal hidden contents

 

2017-11-05_16.44.09.png

2017-11-05_16.44.18.png

2017-11-05_16.44.20.png

Edited by lukas2005
Posted

Learn how to read the log:


Caused by: java.io.FileNotFoundException: multic:blockstates/colored_plank.json

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)
  On 11/5/2017 at 3:52 PM, Draco18s said:

Learn how to read the log:


Caused by: java.io.FileNotFoundException: multic:blockstates/colored_plank.json

Expand  

ohh i my file is called colored_plankS.json dont know how did i missed it 

Edited by lukas2005
Posted

wait its still unsolved now i get diffrent errors in the log 

its MissingVariantException and i have no idea what does that mean

  Reveal hidden contents

 

Posted
  On 11/5/2017 at 4:32 PM, diesieben07 said:

It depends on how the rest of the file looks.

Expand  

rest of the file looks like this

{
	"forge_marker": 1,
	"defaults": {
		"model": "minecraft:cube_all"
	},
	"variants": {
		"variant": {
			"black": {
				"textures": {
					"all": "multic:blocks/colored_planks/colored_planks_black"
				}
			},
			"blue": {
				"textures": {
					"all": "multic:blocks/colored_planks/colored_planks_blue"
				}
			},
			"brown": {
				"textures": {
					"all": "multic:blocks/colored_planks/colored_planks_brown"
				}
			},
			"cyan": {
				"textures": {
					"all": "multic:blocks/colored_planks/colored_planks_cyan"
				}
			},
			"grey": {
				"textures": {
					"all": "multic:blocks/colored_planks/colored_planks_grey"
				}
			},
			"green": {
				"textures": {
					"all": "multic:blocks/colored_planks/colored_planks_green"
				}
			},
			"light_blue": {
				"textures": {
					"all": "multic:blocks/colored_planks/colored_planks_light_blue"
				}
			},
			"light_gray": {
				"textures": {
					"all": "multic:blocks/colored_planks/colored_planks_light_gray"
				}
			},
			"lime": {
				"textures": {
					"all": "multic:blocks/colored_planks/colored_planks_lime"
				}
			},
			"magenta": {
				"textures": {
					"all": "multic:blocks/colored_planks/colored_planks_magenta"
				}
			},
			"orange": {
				"textures": {
					"all": "multic:blocks/colored_planks/colored_planks_orange"
				}
			},
			"pink": {
				"textures": {
					"all": "multic:blocks/colored_planks/colored_planks_pink"
				}
			},
			"purple": {
				"textures": {
					"all": "multic:blocks/colored_planks/colored_planks_purple"
				}
			},
			"red": {
				"textures": {
					"all": "multic:blocks/colored_planks/colored_planks_red"
				}
			},
			"white": {
				"textures": {
					"all": "multic:blocks/colored_planks/colored_planks_white"
				}
			},
			"yellow": {
				"textures": {
					"all": "multic:blocks/colored_planks/colored_planks_yellow"
				}
			}			
		}
	}
}

 

Posted
  On 11/5/2017 at 5:02 PM, diesieben07 said:
  • ModelLoader.setCustomModelResourceLocation must be used in ModelRegistryEvent, not RegistryEvent.Register.
  • You tell the game to use the "inventory" variant for the item, but there is no such variant in your blockstate and there is no model with the name in the models/item folder either.
Expand  

how do i make it so it will have "dynamic" look (diffrent metadata = diffrent color in inventory)

Posted

Because you're using the base ItemBlock class which returns 0 in getMetadata()...

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
  On 11/5/2017 at 8:09 PM, lukas2005 said:

what shloud i change in it?

Expand  

You need to return the metadata (hint: the integer argument is the metadata).

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted
  On 11/6/2017 at 1:26 AM, larsgerrits said:

You need to return the metadata (hint: the integer argument is the metadata).

Expand  

ok now when in creative mode and i have my colored planks in the hotbar and i try to grab a diffrent color using middle click it doesnt allow me to do so how to fix that?

 

Posted
  On 11/6/2017 at 1:35 PM, larsgerrits said:

Override Block#getPickBlock to return the correct ItemStack based on the IBlockState.

Expand  

i got this code:

    @Override
    public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
        return new ItemStack(this, 1, getMetaFromState(state));
    }

but it doesnt seem to work

Posted (edited)
  On 11/7/2017 at 2:13 PM, diesieben07 said:

You must call setHasSubtypes(true) for your ItemBlock if it has different subtypes.

 

On an unrelated note, what the fork is this?

Expand  

ye that is a bit hacky solution for custom drops from vanilla mobs :P

i would appreciate if you would suggest something better to me

Edited by lukas2005
Posted

if(entity instanceof EntityParrot) { ... }

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)
  On 11/7/2017 at 4:02 PM, Draco18s said:

if(entity instanceof EntityParrot) { ... }

Expand  

nah i like switch better instead of big if-else block what is wrong with it? (heard that switch blocks have better performance but idt that matters in a drop event)

 

Also how do i register a crafting recipe for each variant of my block it shloud look like this for each dye color (i did it so that block metadata matches dye metadata to make this easier)

image.png

Edited by lukas2005
Posted
  On 11/7/2017 at 4:04 PM, lukas2005 said:

nah i like switch better instead of big if-else block what is wrong with it? (heard that switch blocks have better performance but idt that matters in a drop event)

Expand  

Because string comparison is awful.

  8 minutes ago, lukas2005 said:

Also how do i register a crafting recipe for each variant of my block it shloud look like this for each dye color (i did it so that block metadata matches dye metadata to make this easier)

image.png

Expand  

You will have to either:

a) make a recipe for each variant

b) create a new IRecipe implementation that gets the metadata of the dye and applies it to the recipe output.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
  On 11/7/2017 at 4:13 PM, Draco18s said:

Because string comparison is awful.

You will have to either:

a) make a recipe for each variant

b) create a new IRecipe implementation that gets the metadata of the dye and applies it to the recipe output.

Expand  

how to use the IRecipe interface (what shloud all of these methods return?)

Posted
  On 11/8/2017 at 3:33 PM, lukas2005 said:

how to use the IRecipe interface (what shloud all of these methods return?)

Expand  

Well....let's see here...

matches returns....if what's in the crafting grid matches the recipe

getCraftingResult returns....the result of the recipe

getRecipeOutput returns....the output item of the recipe (this will be the basic item with no knowledge of the grid, but you need to return something)

getRemainingItems returns....the items remaining in the crafting grid after the result is taken

canFit returns....if the recipe fits within a given grid (2x2, 3x3, etc)

 

Look at some existing implementations to snaggle most of those methods already implemented. All you'd have to do is fluff up the getRecipeOutput method to grab the metadata you want from the items in the grid.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • You are using Create 6 - some addons are not compatible with it Remove all addons and add these one by one littlecontraptions is mentioned - keep this one removed
    • Different problem now. https://paste.ee/p/iDo8lS35
    • I would like to have a BoP sapling drop from my block if it is also installed. I think I have done everything and I cannot pinpoint the problem, which is the error in the logs that appears when joining a world:   [Worker-Main-11/ERROR] [ne.mi.co.ForgeHooks/]: Couldn't parse element loot_tables:grasses:blocks/leaves_block com.google.gson.JsonSyntaxException: Expected name to be an item, was unknown string 'biomesoplenty:magic_sapling' My code:   LootItemConditions.CONDITIONS.register(modEventBus); public class LootItemConditions { public static final DeferredRegister<LootItemConditionType> CONDITIONS = DeferredRegister.create(Registries.LOOT_CONDITION_TYPE, Grasses.MOD_ID); public static final RegistryObject<LootItemConditionType> IS_MOD_LOADED = CONDITIONS.register("is_mod_loaded", () -> new LootItemConditionType(new IsModLoaded.ConditionSerializer())); } public class IsModLoaded implements LootItemCondition { private final boolean exists; private final String modID; public IsModLoaded(String modID) { this.exists = ModList.get().isLoaded(modID); this.modID = modID; } @Override public LootItemConditionType getType() { return LootItemConditions.IS_MOD_LOADED.get(); } @Override public boolean test(LootContext context) { return this.exists; } public static LootItemCondition.Builder builder(String modid) { return () -> new IsModLoaded(modid); } public static class ConditionSerializer implements Serializer<IsModLoaded> { @Override public void serialize(JsonObject json, IsModLoaded instance, JsonSerializationContext ctx) { json.addProperty("modid", instance.modID); } @Override public IsModLoaded deserialize(JsonObject json, JsonDeserializationContext ctx) { return new IsModLoaded(GsonHelper.getAsString(json, "modid")); } } } protected LootTable.Builder createLeavesDropsWithModIDCheck(Block selfBlock, Item sapling, Property<?>[] properties, String modIDToCheck, float... chances) { CopyBlockState.Builder blockStateCopyBuilder = CopyBlockState.copyState(selfBlock); for(Property<?> property : properties) { blockStateCopyBuilder.copy(property); } return LootTable.lootTable() .withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1.0F)) .add(LootItem.lootTableItem(selfBlock) .when(HAS_SHEARS_OR_SILK_TOUCH) .apply(blockStateCopyBuilder))) .withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1.0F)) .add(this.applyExplosionCondition(selfBlock, LootItem.lootTableItem(sapling)) .when(IsModLoaded.builder(modIDToCheck))) .when(BonusLevelTableCondition.bonusLevelFlatChance(Enchantments.BLOCK_FORTUNE, chances)) .when(HAS_NO_SHEARS_OR_SILK_TOUCH)) .withPool(LootPool.lootPool().name("sticks").setRolls(ConstantValue.exactly(1.0F)) .add(this.applyExplosionDecay(selfBlock, LootItem.lootTableItem(Items.STICK). apply(SetItemCountFunction.setCount(UniformGenerator.between(1.0F, 2.0F)))) .when(BonusLevelTableCondition.bonusLevelFlatChance(Enchantments.BLOCK_FORTUNE, NORMAL_LEAVES_STICK_CHANCES)) .when(HAS_NO_SHEARS_OR_SILK_TOUCH))); } I don't know. Am I making a mistake somewhere? Am I forgetting something? Should there be something else?
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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