Skip to content

Commit

Permalink
fix translation stuff, new icon
Browse files Browse the repository at this point in the history
  • Loading branch information
LemmaEOF committed Jul 14, 2019
1 parent 8f71f33 commit 7da646f
Show file tree
Hide file tree
Showing 16 changed files with 223 additions and 64 deletions.
Binary file modified icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 4 additions & 13 deletions src/main/java/io/github/cottonmc/dynagear/DynaGearClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import com.swordglowsblue.artifice.api.Artifice;
import com.swordglowsblue.artifice.api.builder.assets.ModelBuilder;
import com.swordglowsblue.artifice.api.util.Processor;
import io.github.cottonmc.dynagear.util.ResourceBuilders;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.impl.client.render.ColorProviderRegistryImpl;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.item.ItemConvertible;
import net.minecraft.util.Identifier;
import net.minecraft.util.Pair;
Expand All @@ -16,30 +16,21 @@
import java.util.HashMap;
import java.util.Map;

@Environment(EnvType.CLIENT)
public class DynaGearClient implements ClientModInitializer {

//TODO: figure out a sane way to get translations for materials
public static final Map<String, Pair<String, String>> ITEM_TRANSLATIONS = new HashMap<>();
//TODO: figure out a sane way to get translations for material types
public static final Map<Identifier, Processor<ModelBuilder>> MODELS = new HashMap<>();

@Override
public void onInitializeClient() {
for (EquipmentSet set : MaterialConfig.EQUIPMENT.values()) {
ResourceBuilders.createModels(set);
ResourceBuilders.createTranslations(set);
}
Artifice.registerAssets(new Identifier(DynaGear.MODID, "dynagear_assets"), assets -> {
for (Identifier id : MODELS.keySet()) {
assets.addItemModel(id, MODELS.get(id));
}
//TODO: figure out a sane way to generate translations for other locales
assets.addTranslations(new Identifier(DynaGear.MODID, "en_us"), lang -> {
for (String key : ITEM_TRANSLATIONS.keySet()) {
Pair<String, String> tl = ITEM_TRANSLATIONS.get(key);
String value = I18n.translate(tl.getLeft(), tl.getRight());
lang.entry(key, value);
}
});
});
if (FabricLoader.getInstance().isDevelopmentEnvironment()) {
String path = FabricLoader.getInstance().getGameDirectory().toPath().resolve("dynagear_export").toString();
Expand Down
18 changes: 8 additions & 10 deletions src/main/java/io/github/cottonmc/dynagear/EquipmentSet.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package io.github.cottonmc.dynagear;


import io.github.cottonmc.dynagear.util.DynaAxeItem;
import io.github.cottonmc.dynagear.util.DynaPickaxeItem;
import io.github.cottonmc.dynagear.util.ResourceBuilders;
import io.github.cottonmc.dynagear.item.*;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.*;
import net.minecraft.util.Identifier;
Expand All @@ -26,15 +24,15 @@ private static Item.Settings getSettings() {
private EquipmentSet(ConfiguredMaterial material) {
this.name = material.getMaterialName();
this.material = material;
equipment.put(name+"_sword", new SwordItem(material, 3, -2.4f, getSettings()));
equipment.put(name+"_shovel", new ShovelItem(material, 1.5F, -3.0F, getSettings()));
equipment.put(name+"_sword", new DynaSwordItem(material, 3, -2.4f, getSettings()));
equipment.put(name+"_shovel", new DynaShovelItem(material, 1.5F, -3.0F, getSettings()));
equipment.put(name+"_pickaxe", new DynaPickaxeItem(material, 1, -2.8F, getSettings()));
equipment.put(name+"_axe", new DynaAxeItem(material, 6.0F, -3.2F, getSettings()));
equipment.put(name+"_hoe", new HoeItem(material, material.getMiningLevel()-3, getSettings()));
equipment.put(name+"_helmet", new ArmorItem(material, EquipmentSlot.HEAD, getSettings()));
equipment.put(name+"_chestplate", new ArmorItem(material, EquipmentSlot.CHEST, getSettings()));
equipment.put(name+"_leggings", new ArmorItem(material, EquipmentSlot.LEGS, getSettings()));
equipment.put(name+"_boots", new ArmorItem(material, EquipmentSlot.FEET, getSettings()));
equipment.put(name+"_hoe", new DynaHoeItem(material, material.getMiningLevel()-3, getSettings()));
equipment.put(name+"_helmet", new DynaArmorItem(material, "helmet", EquipmentSlot.HEAD, getSettings()));
equipment.put(name+"_chestplate", new DynaArmorItem(material, "chestplate", EquipmentSlot.CHEST, getSettings()));
equipment.put(name+"_leggings", new DynaArmorItem(material, "leggings", EquipmentSlot.LEGS, getSettings()));
equipment.put(name+"_boots", new DynaArmorItem(material, "boots", EquipmentSlot.FEET, getSettings()));
}

private void registerAll() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.cottonmc.dynagear.util;
package io.github.cottonmc.dynagear;

import com.swordglowsblue.artifice.api.builder.assets.ModelBuilder;
import com.swordglowsblue.artifice.api.builder.data.recipe.ShapedRecipeBuilder;
Expand Down Expand Up @@ -48,17 +48,6 @@ public static void createModels(EquipmentSet set) {
}
}

@Environment(EnvType.CLIENT)
public static void createTranslations(EquipmentSet set) {
ConfiguredMaterial material = set.getMaterial();
for (String piece : PATTERNS.keySet()) {
String id = "item.dynagear." + material.getMaterialName() + "_" + piece;
String name = material.getMaterialName().substring(0,1).toUpperCase() + material.getMaterialName().substring(1);

DynaGearClient.ITEM_TRANSLATIONS.put(id, new Pair<>("translation.dynagear."+piece, name));
}
}

public static ModelBuilder applyModel(ModelBuilder builder, String part, boolean tool) {
if (tool) {
builder.texture("layer0", new Identifier(DynaGear.MODID, "item/" + part + "_head"));
Expand Down
35 changes: 35 additions & 0 deletions src/main/java/io/github/cottonmc/dynagear/item/DynaArmorItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.github.cottonmc.dynagear.item;

import io.github.cottonmc.dynagear.ConfiguredMaterial;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;

public class DynaArmorItem extends ArmorItem {
private ConfiguredMaterial material;
private String type;
public DynaArmorItem(ConfiguredMaterial material, String type, EquipmentSlot slot, Settings settings) {
super(material, slot, settings);
this.material = material;
this.type = type;
}

@Override
public String getTranslationKey() {
return "item.dynagear." + type;
}

@Override
public Text getName() {
String mat = material.getMaterialName().substring(0, 1).toUpperCase() + material.getMaterialName().substring(1);
return new TranslatableText(getTranslationKey(), mat);
}

@Override
public Text getName(ItemStack stack) {
String mat = material.getMaterialName().substring(0, 1).toUpperCase() + material.getMaterialName().substring(1);
return new TranslatableText(getTranslationKey(), mat);
}
}
32 changes: 32 additions & 0 deletions src/main/java/io/github/cottonmc/dynagear/item/DynaAxeItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.github.cottonmc.dynagear.item;

import io.github.cottonmc.dynagear.ConfiguredMaterial;
import net.minecraft.item.AxeItem;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;

public class DynaAxeItem extends AxeItem {
private ConfiguredMaterial material;
public DynaAxeItem(ConfiguredMaterial material, float baseAttackDamage, float attackSpeed, Settings settings) {
super(material, baseAttackDamage, attackSpeed, settings);
this.material = material;
}

@Override
public String getTranslationKey() {
return "item.dynagear.axe";
}

@Override
public Text getName() {
String mat = material.getMaterialName().substring(0, 1).toUpperCase() + material.getMaterialName().substring(1);
return new TranslatableText(getTranslationKey(), mat);
}

@Override
public Text getName(ItemStack stack) {
String mat = material.getMaterialName().substring(0, 1).toUpperCase() + material.getMaterialName().substring(1);
return new TranslatableText(getTranslationKey(), mat);
}
}
32 changes: 32 additions & 0 deletions src/main/java/io/github/cottonmc/dynagear/item/DynaHoeItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.github.cottonmc.dynagear.item;

import io.github.cottonmc.dynagear.ConfiguredMaterial;
import net.minecraft.item.HoeItem;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;

public class DynaHoeItem extends HoeItem {
private ConfiguredMaterial material;
public DynaHoeItem(ConfiguredMaterial material, float attackSpeed, Settings settinggs) {
super(material, attackSpeed, settinggs);
this.material = material;
}

@Override
public String getTranslationKey() {
return "item.dynagear.hoe";
}

@Override
public Text getName() {
String mat = material.getMaterialName().substring(0, 1).toUpperCase() + material.getMaterialName().substring(1);
return new TranslatableText(getTranslationKey(), mat);
}

@Override
public Text getName(ItemStack stack) {
String mat = material.getMaterialName().substring(0, 1).toUpperCase() + material.getMaterialName().substring(1);
return new TranslatableText(getTranslationKey(), mat);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.github.cottonmc.dynagear.item;

import io.github.cottonmc.dynagear.ConfiguredMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.item.PickaxeItem;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;

public class DynaPickaxeItem extends PickaxeItem {
private ConfiguredMaterial material;
public DynaPickaxeItem(ConfiguredMaterial material, int baseAttackDamage, float attackSpeed, Settings settings) {
super(material, baseAttackDamage, attackSpeed, settings);
this.material = material;
}

@Override
public String getTranslationKey() {
return "item.dynagear.pickaxe";
}

@Override
public Text getName() {
String mat = material.getMaterialName().substring(0, 1).toUpperCase() + material.getMaterialName().substring(1);
return new TranslatableText(getTranslationKey(), mat);
}

@Override
public Text getName(ItemStack stack) {
String mat = material.getMaterialName().substring(0, 1).toUpperCase() + material.getMaterialName().substring(1);
return new TranslatableText(getTranslationKey(), mat);
}
}
32 changes: 32 additions & 0 deletions src/main/java/io/github/cottonmc/dynagear/item/DynaShovelItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.github.cottonmc.dynagear.item;

import io.github.cottonmc.dynagear.ConfiguredMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ShovelItem;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;

public class DynaShovelItem extends ShovelItem {
private ConfiguredMaterial material;
public DynaShovelItem(ConfiguredMaterial material, float baseAttackDamage, float attackSpeed, Settings settings) {
super(material, baseAttackDamage, attackSpeed, settings);
this.material = material;
}

@Override
public String getTranslationKey() {
return "item.dynagear.shovel";
}

@Override
public Text getName() {
String mat = material.getMaterialName().substring(0, 1).toUpperCase() + material.getMaterialName().substring(1);
return new TranslatableText(getTranslationKey(), mat);
}

@Override
public Text getName(ItemStack stack) {
String mat = material.getMaterialName().substring(0, 1).toUpperCase() + material.getMaterialName().substring(1);
return new TranslatableText(getTranslationKey(), mat);
}
}
32 changes: 32 additions & 0 deletions src/main/java/io/github/cottonmc/dynagear/item/DynaSwordItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.github.cottonmc.dynagear.item;

import io.github.cottonmc.dynagear.ConfiguredMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SwordItem;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;

public class DynaSwordItem extends SwordItem {
private ConfiguredMaterial material;
public DynaSwordItem(ConfiguredMaterial material, int baseAttackDamage, float attackSpeed, Settings settings) {
super(material, baseAttackDamage, attackSpeed, settings);
this.material = material;
}

@Override
public String getTranslationKey() {
return "item.dynagear.sword";
}

@Override
public Text getName() {
String mat = material.getMaterialName().substring(0, 1).toUpperCase() + material.getMaterialName().substring(1);
return new TranslatableText(getTranslationKey(), mat);
}

@Override
public Text getName(ItemStack stack) {
String mat = material.getMaterialName().substring(0, 1).toUpperCase() + material.getMaterialName().substring(1);
return new TranslatableText(getTranslationKey(), mat);
}
}
10 changes: 0 additions & 10 deletions src/main/java/io/github/cottonmc/dynagear/util/DynaAxeItem.java

This file was deleted.

This file was deleted.

Binary file modified src/main/resources/assets/dynagear/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions src/main/resources/assets/dynagear/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"itemGroup.dynagear.dynagear": "DynaGear",
"translation.dynagear.sword": "%s Sword",
"translation.dynagear.shovel": "%s Shovel",
"translation.dynagear.pickaxe": "%s Pickaxe",
"translation.dynagear.axe": "%s Axe",
"translation.dynagear.hoe": "%s Hoe",
"translation.dynagear.helmet": "%s Helmet",
"translation.dynagear.chestplate": "%s Chestplate",
"translation.dynaear.leggings": "%s Leggings",
"translation.dynagear.boots": "%s Boots"
"item.dynagear.sword": "%s Sword",
"item.dynagear.shovel": "%s Shovel",
"item.dynagear.pickaxe": "%s Pickaxe",
"item.dynagear.axe": "%s Axe",
"item.dynagear.hoe": "%s Hoe",
"item.dynagear.helmet": "%s Helmet",
"item.dynagear.chestplate": "%s Chestplate",
"item.dynagear.leggings": "%s Leggings",
"item.dynagear.boots": "%s Boots"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "dynagear:item/icon.png"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7da646f

Please sign in to comment.