Jump to content

Armor in 1.8


Wooden_Brick

Recommended Posts

Does armor now have only 1 layer or 2? Cause i have 2 layers - one for the top part and 1 for the bottom part of the armor. Im using this code and it doesnt work -

 

@Override

public String getArmorTexture(ItemStack stack,Entity entity, int slot, String type)

{

if(this.armorType == 2) {

return "tm:textures/models/armor/cheese_layer_2.png";

}

 

return "tm:textures/models/armor/cheese_layer_1.png";

}

 

Link to comment
Share on other sites

Main:

 

package com.Babuska;

 

import net.minecraftforge.fml.common.Mod;

import net.minecraftforge.fml.common.Mod.EventHandler;

import net.minecraftforge.fml.common.SidedProxy;

import net.minecraftforge.fml.common.event.FMLInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

import net.minecraftforge.fml.common.registry.GameRegistry;

 

import com.Babuska.init.TutorialBlocks;

import com.Babuska.init.TutorialItems;

import com.Babuska.proxy.CommonProxy;

 

 

@Mod(modid = References.MOD_ID, name = References.MOD_NAME, version = References.VERSION)

public class TutorialMod {

@SidedProxy(clientSide = References.CLIENT_PROXY_CLASS, serverSide = References.SERVER_PROXY_CLASS)

public static CommonProxy proxy;

 

@EventHandler

public void preInit(FMLPreInitializationEvent event){

TutorialBlocks.init();

TutorialBlocks.register();

TutorialItems.init();

TutorialItems.register();

TutorialItems.registerRecipes();

}

@EventHandler

public void init(FMLInitializationEvent event){

proxy.registerRenders();

 

}

 

@EventHandler

public void postInit(FMLPostInitializationEvent event){

 

}

 

 

 

}

 

ItemGemArmour class:

 

package com.Babuska.items;

 

import net.minecraft.entity.Entity;

import net.minecraft.item.ItemArmor;

import net.minecraft.item.ItemStack;

 

public class ItemGemArmor extends ItemArmor {

 

public ItemGemArmor(ArmorMaterial material, int renderIndex,

int armorType) {

super(material, renderIndex, armorType);

// TODO Auto-generated constructor stub

}

@Override

public String getArmorTexture(ItemStack stack,Entity entity, int slot, String type)

{

if(this.armorType == 2) {

return "tm:textures/models/armor/cheese_layer_2.png";

}

 

return "tm:textures/models/armor/cheese_layer_1.png";

}

 

}

 

Where all my items are class:

 

package com.Babuska.init;

 

import net.minecraft.client.Minecraft;

import net.minecraft.client.resources.model.ModelResourceLocation;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.item.ItemArmor;

import net.minecraft.item.ItemStack;

import net.minecraftforge.common.util.EnumHelper;

import net.minecraftforge.fml.common.registry.GameRegistry;

 

import com.Babuska.References;

import com.Babuska.items.ItemGemArmor;

import com.Babuska.items.ItemGemPickaxe;

 

 

public class TutorialItems {

 

public static Item test_item;

public static Item gem_1;

public static Item gem_pickaxe;

public static Item gem_helmet;

public static Item gem_chest;

public static Item gem_legs;

public static Item gem_boots;

 

public static final Item.ToolMaterial gemToolMaterial = EnumHelper.addToolMaterial("gemToolMaterial", 2, 512, 7.0F, 2.0F, 10);

public static final ItemArmor.ArmorMaterial gemArmorMaterial = EnumHelper.addArmorMaterial("gemArmorMaterial" , null, 1024,new int[]{5,9,7,5}, 30);

 

public static void init(){

test_item = new Item().setUnlocalizedName("test_item");

gem_1 = new Item().setUnlocalizedName("gem_1");

gem_pickaxe = new ItemGemPickaxe(gemToolMaterial).setUnlocalizedName("gem_pickaxe");

gem_helmet = new ItemGemArmor(gemArmorMaterial, 0, 0).setUnlocalizedName("gem_helmet");

gem_chest = new ItemGemArmor(gemArmorMaterial, 0, 1).setUnlocalizedName("gem_chest");

gem_legs = new ItemGemArmor(gemArmorMaterial, 0, 2).setUnlocalizedName("gem_legs");

gem_boots = new ItemGemArmor(gemArmorMaterial, 0, 3).setUnlocalizedName("gem_boots");

 

 

}

 

public static void register() {

GameRegistry.registerItem(test_item, test_item.getUnlocalizedName().substring(5)); //"tile.test_item"

GameRegistry.registerItem(gem_1, gem_1.getUnlocalizedName().substring(5));

GameRegistry.registerItem(gem_pickaxe, gem_pickaxe.getUnlocalizedName().substring(5));

GameRegistry.registerItem(gem_helmet, gem_helmet.getUnlocalizedName().substring(5));

GameRegistry.registerItem(gem_chest, gem_chest.getUnlocalizedName().substring(5));

GameRegistry.registerItem(gem_legs, gem_legs.getUnlocalizedName().substring(5));

GameRegistry.registerItem(gem_boots, gem_boots.getUnlocalizedName().substring(5));

 

}

 

public static void registerRenders() {

 

registerRender(test_item);

registerRender(gem_1);

registerRender(gem_pickaxe);

registerRender(gem_helmet);

registerRender(gem_chest);

registerRender(gem_legs);

registerRender(gem_boots);

 

}

 

 

public static void registerRender(Item item) {

 

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(References.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));

 

}

 

public static void registerRecipes() {

recipePickaxe();

recipeHelmet();

recipeChest();

recipeLegs();

recipeBoots();

}

 

public static void recipePickaxe()

{

GameRegistry.addRecipe(new ItemStack(gem_pickaxe, 1), new Object[]{"TTT",

                                                              " S ",

                                                              " S ",'T',TutorialItems.gem_1,'S',Items.stick});

}

 

public static void recipeHelmet()

{

GameRegistry.addRecipe(new ItemStack(gem_helmet, 1), new Object[]{"GGG",

                                                              "G G ",

                                                              "  ",'G',TutorialItems.gem_1});

}

 

public static void recipeChest()

{

GameRegistry.addRecipe(new ItemStack(gem_chest, 1), new Object[]{"G G",

                                                            "GGG",

                                                            "GGG",'G',TutorialItems.gem_1});

}

 

public static void recipeLegs()

{

GameRegistry.addRecipe(new ItemStack(gem_legs, 1), new Object[]{"GGG",

                                                            "G G",

                                                            "G G",'G',TutorialItems.gem_1});

}

 

public static void recipeBoots()

{

GameRegistry.addRecipe(new ItemStack(gem_boots, 1), new Object[]{"  ",

                                                            "G G",

                                                            "G G",'G',TutorialItems.gem_1});

}

 

 

}

 

 

the armor pngs are in Assets.tm/models/armor

Link to comment
Share on other sites

Are you sure that pngs are correct? (I mean that leg png has legs, etc...)

Also, how exactly is it rendered: black&purple or wierd missplaced squares?

If all above is correct, add printin to this method, and check for item - type - texture...

Link to comment
Share on other sites

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

    • I have a tool that harvests multiple crops at once, that either replants or harvests the crops depending on an enchant on the tool. The harvesting and loot dropping works fine, but when it comes to updating what block is rendering, only the clicked block is updated properly, while the others drop the loot but appear to say as the fully grown crop, until right clicked again. The normal path for the tool is to just break the crop, as if the player harvested the crop. The other path is to reset the growth of the crop and drop the crop's loot, minus one seed. I have already tried all combinations of method parameters for setBlock() and destroyBlock(), and the updateing of the crop blocks still does not happen.  The code thus far: public class ScytheItem extends HoeItem { public ScytheItem(Tier tier, int atkBase, float atkSpeed) { super(tier, atkBase, atkSpeed, new Item.Properties().stacksTo(1)); } @Override public @NotNull InteractionResult useOn(@NotNull UseOnContext context) { Level level = context.getLevel(); Player player = context.getPlayer(); InteractionHand hand = context.getHand(); ItemStack stack = context.getItemInHand(); if (!level.isClientSide() && player != null) { BlockPos pos = context.getClickedPos(); Block block = level.getBlockState(pos).getBlock(); if(block instanceof CropBlock) { level.playSound(null, pos, block.getSoundType(level.getBlockState(pos), level, pos, player).getBreakSound(), SoundSource.BLOCKS, 1.0F, AOTMain.RANDOM.nextFloat()); Map<Enchantment, Integer> enchantments = stack.getAllEnchantments(); int harvestSize = 1 + enchantments.getOrDefault(EnchantmentInit.HARVESTING_SIZE.get(), 0); for (int xOff = -harvestSize; xOff <= harvestSize; xOff++) { for (int zOff = -harvestSize; zOff <= harvestSize; zOff++) { BlockPos newPos = pos.offset(xOff, 0, zOff); Block blockAt = level.getBlockState(newPos).getBlock(); if (blockAt instanceof CropBlock crop) { if (crop.isMaxAge(level.getBlockState(newPos))) { if (enchantments.containsKey(EnchantmentInit.AUTO_PLANTER.get())) { dropLoot(level, newPos, level.getBlockState(newPos), block); level.setBlock(newPos, crop.getStateForAge(0), Block.UPDATE_CLIENTS); // the broken bit } else level.destroyBlock(newPos, true); // the broken bit } } } } stack.hurtAndBreak(1, player, (p) -> p.broadcastBreakEvent(hand)); } } return super.useOn(context); } private void dropLoot(@NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull Block block) { List<ItemStack> drops = getDrops(level, pos, state); findSeeds(block, drops).ifPresent(seed -> seed.shrink(1)); drops.forEach((drop) -> Block.popResource(level, pos, drop)); } private List<ItemStack> getDrops(@NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState state) { return Block.getDrops(state, (ServerLevel) level, pos, null); } private Optional<ItemStack> findSeeds(@NotNull Block block, final Collection<ItemStack> stacks) { Item seedsItem = block.asItem(); return stacks.stream().filter((stack) -> stack.getItem() == seedsItem).findAny(); } }  
    • Hello!  After I build e my mod in .jar, then when starting minecraft, it gives me an error that the dependency was not found. In the minecraft log the following is written:   java.lang.NoClassDefFoundError: org/json/simple/parser/JSONParser at com.example.examplemod.JsonUtil.getConfig(JsonUtil.java:14) In build.gradle I have next dependencies: dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'com.googlecode.json-simple:json-simple:1.1.1' } But if I run minecraft from IDE (using the runClient), then these dependencies are installed, and my mod is work. Please, help me with this problem. UPD: Full build.gradle file   plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' } version = mod_version group = mod_group_id base { archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(8) println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { // applies to all the run configs below configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' mods { "${mod_id}" { source sourceSets.main } } } client { // this block needs to be here for runClient to exist } server { args '--nogui' } data { // example of overriding the workingDirectory set in configureEach above workingDirectory project.file('run-data') // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } // Include resources generated by data generators. sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'com.googlecode.json-simple:json-simple:1.1.1' } tasks.named('processResources', ProcessResources).configure { var replaceProperties = [ minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range, forge_version: forge_version, forge_version_range: forge_version_range, loader_version_range: loader_version_range, mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version, mod_authors: mod_authors, mod_description: mod_description, ] inputs.properties replaceProperties filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) { expand replaceProperties + [project: project] } } tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', // We are version 1 of ourselves 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ]) } finalizedBy 'reobfJar' } //tasks.named('publish').configure { // dependsOn 'reobfJar' //} publishing { publications { register('mavenJava', MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } } tasks.withType(JavaCompile).configureEach { options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation }  
    • I want to render shapes through blocks. I found this code in minecraft source  public static void renderShape(PoseStack poseStack, VertexConsumer vertexConsumer, VoxelShape shape, double minX, double minY, double minZ, float red, float green, float blue, float alpha) { PoseStack.Pose pose = poseStack.last(); shape.forAllEdges((x1, y1, z1, x2, y2, z2) -> { float dx = (float)(x2 - x1); float dy = (float)(y2 - y1); float dz = (float)(z2 - z1); float length = Mth.sqrt(dx * dx + dy * dy + dz * dz); dx /= length; dy /= length; dz /= length; vertexConsumer.vertex(pose.pose(), (float)(x1 + minX), (float)(y1 + minY), (float)(z1 + minZ)).color(red, green, blue, alpha).normal(pose.normal(), dx, dy, dz).endVertex(); vertexConsumer.vertex(pose.pose(), (float)(x2 + minX), (float)(y2 + minY), (float)(z2 + minZ)).color(red, green, blue, alpha).normal(pose.normal(), dx, dy, dz).endVertex(); }); } that draws a rectangle around the block, but it is not visible through other blocks. Could someone point me in the right direction on how one renders things through blocks? Thanks in advance 🙏
    • I wish I could replace optifine, when i remove optifine and put on Embeddium, the game crashes too with exit code 1, or could that also be a forge version problem?   edit: rubidium getsauto downloaded with embeddium and oculus, removing rubidium solved it, thanks
    • Looks like an issue with Optifine - to get Optifine to work, you will need Forge 43.2.14 You can downgrade Forge (which may break other mods) or replace Optifine With Embeddium + Oculus
  • Topics

×
×
  • Create New...

Important Information

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