Skip to content

Commit

Permalink
Separate armor into its own module, rename features module to melter,…
Browse files Browse the repository at this point in the history
… separate bucket cast to just commons

Makes it easier to deal with modules here instead of them feeling just tacked on
  • Loading branch information
KnightMiner committed Jan 7, 2019
1 parent 7b2535f commit c8c42ee
Show file tree
Hide file tree
Showing 50 changed files with 292 additions and 313 deletions.
6 changes: 4 additions & 2 deletions src/main/java/knightminer/tcomplement/TinkersComplement.java
Expand Up @@ -3,9 +3,10 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import knightminer.tcomplement.armor.ModuleArmor;
import knightminer.tcomplement.common.Config;
import knightminer.tcomplement.common.TCompNetwork;
import knightminer.tcomplement.feature.ModuleFeature;
import knightminer.tcomplement.melter.ModuleMelter;
import knightminer.tcomplement.plugin.ceramics.CeramicsPlugin;
import knightminer.tcomplement.plugin.chisel.ChiselPlugin;
import knightminer.tcomplement.plugin.exnihilo.ExNihiloPlugin;
Expand Down Expand Up @@ -50,7 +51,8 @@ public class TinkersComplement {

static {
pulseManager.registerPulse(new ModuleCommons());
pulseManager.registerPulse(new ModuleFeature());
pulseManager.registerPulse(new ModuleMelter());
pulseManager.registerPulse(new ModuleArmor());
pulseManager.registerPulse(new CeramicsPlugin());
pulseManager.registerPulse(new ChiselPlugin());
pulseManager.registerPulse(new ExNihiloPlugin());
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/knightminer/tcomplement/armor/ArmorClientProxy.java
@@ -0,0 +1,23 @@
package knightminer.tcomplement.armor;

import static slimeknights.tconstruct.common.ModelRegisterUtil.registerItemModel;

import knightminer.tcomplement.common.ClientProxy;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public class ArmorClientProxy extends ClientProxy {
@SubscribeEvent
public void registerModels(ModelRegistryEvent event) {
// armor
registerItemModel(ModuleArmor.manyullynHelmet);
registerItemModel(ModuleArmor.manyullynChestplate);
registerItemModel(ModuleArmor.manyullynLeggings);
registerItemModel(ModuleArmor.manyullynBoots);

registerItemModel(ModuleArmor.knightSlimeHelmet);
registerItemModel(ModuleArmor.knightSlimeChestplate);
registerItemModel(ModuleArmor.knightSlimeLeggings);
registerItemModel(ModuleArmor.knightSlimeBoots);
}
}
94 changes: 94 additions & 0 deletions src/main/java/knightminer/tcomplement/armor/ModuleArmor.java
@@ -0,0 +1,94 @@
package knightminer.tcomplement.armor;

import com.google.common.eventbus.Subscribe;

import knightminer.tcomplement.armor.items.ItemArmorBase;
import knightminer.tcomplement.armor.items.ItemKnightSlimeArmor;
import knightminer.tcomplement.common.CommonProxy;
import knightminer.tcomplement.common.ModIds;
import knightminer.tcomplement.common.PulseBase;
import knightminer.tcomplement.library.Util;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.event.RegistryEvent.Register;
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.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.registries.IForgeRegistry;
import slimeknights.mantle.pulsar.pulse.Pulse;

@Pulse(id = ModuleArmor.pulseID, description = "Adds KnightSlime and Manyullyn vanilla style armors")
public class ModuleArmor extends PulseBase {
public static final String pulseID = "ModuleArmor";

@SidedProxy(clientSide = "knightminer.tcomplement.armor.ArmorClientProxy", serverSide = "knightminer.tcomplement.common.CommonProxy")
public static CommonProxy proxy;

// armor
public static ArmorMaterial manyullynArmor;
public static Item manyullynHelmet;
public static Item manyullynChestplate;
public static Item manyullynLeggings;
public static Item manyullynBoots;

public static ArmorMaterial knightSlimeArmor;
public static Item knightSlimeHelmet;
public static Item knightSlimeChestplate;
public static Item knightSlimeLeggings;
public static Item knightSlimeBoots;

@Subscribe
public void preInit(FMLPreInitializationEvent event) {
manyullynArmor = EnumHelper.addArmorMaterial(Util.prefix("manyullyn"), Util.resource("manyullyn"),
15, new int[]{3, 6, 8, 3}, 7, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 3.0F);
knightSlimeArmor = EnumHelper.addArmorMaterial(Util.prefix("knightslime"), Util.resource("knightslime"),
12, new int[]{2, 5, 6, 2}, 4, SoundEvents.BLOCK_SLIME_PLACE, 1.0F);

proxy.preInit();
}

@SubscribeEvent
public void registerItems(Register<Item> event) {
IForgeRegistry<Item> r = event.getRegistry();

// manyullyn armor
manyullynHelmet = registerItem(r, new ItemArmorBase(manyullynArmor, EntityEquipmentSlot.HEAD), "manyullyn_helmet");
manyullynChestplate = registerItem(r, new ItemArmorBase(manyullynArmor, EntityEquipmentSlot.CHEST), "manyullyn_chestplate");
manyullynLeggings = registerItem(r, new ItemArmorBase(manyullynArmor, EntityEquipmentSlot.LEGS), "manyullyn_leggings");
manyullynBoots = registerItem(r, new ItemArmorBase(manyullynArmor, EntityEquipmentSlot.FEET), "manyullyn_boots");
ItemStack manyullyn = GameRegistry.makeItemStack(ModIds.TConstruct.ingots, ModIds.TConstruct.manyullynMeta, 1, null);
if(!manyullyn.isEmpty()) {
manyullynArmor.setRepairItem(manyullyn);
}

// knight slime armor
knightSlimeHelmet = registerItem(r, new ItemKnightSlimeArmor(EntityEquipmentSlot.HEAD), "knightslime_helmet");
knightSlimeChestplate = registerItem(r, new ItemKnightSlimeArmor(EntityEquipmentSlot.CHEST), "knightslime_chestplate");
knightSlimeLeggings = registerItem(r, new ItemKnightSlimeArmor(EntityEquipmentSlot.LEGS), "knightslime_leggings");
knightSlimeBoots = registerItem(r, new ItemKnightSlimeArmor(EntityEquipmentSlot.FEET), "knightslime_boots");
ItemStack knightSlime = GameRegistry.makeItemStack(ModIds.TConstruct.ingots, ModIds.TConstruct.knightSlimeMeta, 1, null);
if(!knightSlime.isEmpty()) {
knightSlimeArmor.setRepairItem(knightSlime);
}
}

@Subscribe
public void init(FMLInitializationEvent event) {
proxy.init();
}

@Subscribe
public void postInit(FMLPostInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(ItemKnightSlimeArmor.class);

proxy.postInit();
}
}
@@ -1,4 +1,4 @@
package knightminer.tcomplement.feature.items;
package knightminer.tcomplement.armor.items;

import knightminer.tcomplement.library.TCompRegistry;
import net.minecraft.inventory.EntityEquipmentSlot;
Expand Down
@@ -1,6 +1,6 @@
package knightminer.tcomplement.feature.items;
package knightminer.tcomplement.armor.items;

import knightminer.tcomplement.feature.ModuleFeature;
import knightminer.tcomplement.armor.ModuleArmor;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.EntityEquipmentSlot;
Expand All @@ -15,7 +15,7 @@
public class ItemKnightSlimeArmor extends ItemArmorBase {

public ItemKnightSlimeArmor(EntityEquipmentSlot slot) {
super(ModuleFeature.knightSlimeArmor, slot);
super(ModuleArmor.knightSlimeArmor, slot);
}

// stolen from RUBBERY BOUNCY BOUNCERY WOOOOO
Expand All @@ -26,7 +26,7 @@ public static void onFall(LivingFallEvent event) {
return;
}
ItemStack feet = entity.getItemStackFromSlot(EntityEquipmentSlot.FEET);
if(feet.getItem() != ModuleFeature.knightSlimeBoots) {
if(feet.getItem() != ModuleArmor.knightSlimeBoots) {
return;
}

Expand Down
25 changes: 25 additions & 0 deletions src/main/java/knightminer/tcomplement/common/Config.java
Expand Up @@ -3,6 +3,7 @@
import java.util.function.BooleanSupplier;

import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;

import knightminer.tcomplement.TinkersComplement;
import net.minecraft.util.JsonUtils;
Expand All @@ -20,6 +21,10 @@ public class Config {
@Ignore
public static ForgeCFG pulseConfig = new ForgeCFG("TComplementModules", "Modules");

@Comment("General configuration options")
@LangKey("tcomplement.config.general")
public static General general = new General();

@Comment("Options to configure the melter")
@LangKey("tcomplement.config.melter")
public static Melter melter = new Melter();
Expand All @@ -28,6 +33,13 @@ public class Config {
@LangKey("tcomplement.config.jei")
public static JEI jei = new JEI();

public static class General {
@RequiresMcRestart
@Comment("Enables the bucket cast: allows casting buckets using a casting table.")
@LangKey("tcomplement.config.general.bucketCast")
public boolean bucketCast = true;
}

public static class Melter {
@RequiresMcRestart
@Comment("Ratio of ore to material produced in the melter.")
Expand All @@ -51,6 +63,19 @@ public static class JEI {
public boolean separateMelterTab = true;
}

public static class ConfigProperty implements IConditionFactory {
@Override
public BooleanSupplier parse(JsonContext context, JsonObject json) {
String option = JsonUtils.getString(json, "option");
return () -> {
switch(option) {
case "bucket_cast": return general.bucketCast;
}
throw new JsonSyntaxException("Config option '" + option + "' does not exist");
};
}
}

public static class PulseLoaded implements IConditionFactory {
@Override
public BooleanSupplier parse(JsonContext context, JsonObject json) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/knightminer/tcomplement/common/PulseBase.java
Expand Up @@ -3,8 +3,8 @@
import java.util.Locale;

import knightminer.tcomplement.TinkersComplement;
import knightminer.tcomplement.feature.ModuleFeature;
import knightminer.tcomplement.library.Util;
import knightminer.tcomplement.melter.ModuleMelter;
import knightminer.tcomplement.plugin.ceramics.CeramicsPlugin;
import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty;
Expand Down Expand Up @@ -39,8 +39,8 @@ protected boolean isSmelteryLoaded() {
return TConstruct.pulseManager.isPulseLoaded(TinkerSmeltery.PulseId);
}

protected boolean isFeaturesLoaded() {
return TinkersComplement.pulseManager.isPulseLoaded(ModuleFeature.pulseID);
protected boolean isMelterLoaded() {
return TinkersComplement.pulseManager.isPulseLoaded(ModuleMelter.pulseID);
}

protected boolean isCeramicsPluginLoaded() {
Expand Down
@@ -1,8 +1,8 @@
package knightminer.tcomplement.common;

import knightminer.tcomplement.TinkersComplement;
import knightminer.tcomplement.feature.network.FluidUpdatePacket;
import knightminer.tcomplement.feature.network.MelterFuelUpdatePacket;
import knightminer.tcomplement.melter.network.FluidUpdatePacket;
import knightminer.tcomplement.melter.network.MelterFuelUpdatePacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.math.BlockPos;
Expand Down
@@ -1,8 +1,8 @@
package knightminer.tcomplement.library.tanks;

import knightminer.tcomplement.common.TCompNetwork;
import knightminer.tcomplement.feature.network.FluidUpdatePacket;
import knightminer.tcomplement.feature.tileentity.TileMelter;
import knightminer.tcomplement.melter.network.FluidUpdatePacket;
import knightminer.tcomplement.melter.tileentity.TileMelter;
import slimeknights.tconstruct.library.fluid.FluidTankAnimated;

public class MelterTank extends FluidTankAnimated {
Expand Down
@@ -1,14 +1,14 @@
package knightminer.tcomplement.feature;
package knightminer.tcomplement.melter;

import static slimeknights.tconstruct.common.ModelRegisterUtil.registerItemModel;

import knightminer.tcomplement.common.ClientProxy;
import knightminer.tcomplement.feature.blocks.BlockAlloyTank;
import knightminer.tcomplement.feature.blocks.BlockMelter;
import knightminer.tcomplement.feature.blocks.BlockMelter.MelterType;
import knightminer.tcomplement.feature.client.MelterRenderer;
import knightminer.tcomplement.feature.tileentity.TileAlloyTank;
import knightminer.tcomplement.feature.tileentity.TileMelter;
import knightminer.tcomplement.melter.blocks.BlockAlloyTank;
import knightminer.tcomplement.melter.blocks.BlockMelter;
import knightminer.tcomplement.melter.blocks.BlockMelter.MelterType;
import knightminer.tcomplement.melter.client.MelterRenderer;
import knightminer.tcomplement.melter.tileentity.TileAlloyTank;
import knightminer.tcomplement.melter.tileentity.TileMelter;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
Expand All @@ -28,31 +28,20 @@
import slimeknights.tconstruct.smeltery.client.TankItemModel;
import slimeknights.tconstruct.smeltery.client.TankRenderer;

public class FeatureClientProxy extends ClientProxy {
public class MelterClientProxy extends ClientProxy {
@SubscribeEvent
public void registerModels(ModelRegistryEvent event) {
StateMap alloyTankMap = new StateMap.Builder().ignore(BlockAlloyTank.POWERED).build();
setModelStateMapper(ModuleFeature.alloyTank, alloyTankMap);
setModelStateMapper(ModuleFeature.porcelainAlloyTank, alloyTankMap);
setModelStateMapper(ModuleMelter.alloyTank, alloyTankMap);
setModelStateMapper(ModuleMelter.porcelainAlloyTank, alloyTankMap);

registerMelterModel(ModuleFeature.melter);
registerItemModel(ModuleFeature.alloyTank);
registerMelterModel(ModuleFeature.porcelainMelter);
registerItemModel(ModuleFeature.porcelainAlloyTank);

// armor
registerItemModel(ModuleFeature.manyullynHelmet);
registerItemModel(ModuleFeature.manyullynChestplate);
registerItemModel(ModuleFeature.manyullynLeggings);
registerItemModel(ModuleFeature.manyullynBoots);

registerItemModel(ModuleFeature.knightSlimeHelmet);
registerItemModel(ModuleFeature.knightSlimeChestplate);
registerItemModel(ModuleFeature.knightSlimeLeggings);
registerItemModel(ModuleFeature.knightSlimeBoots);
registerMelterModel(ModuleMelter.melter);
registerItemModel(ModuleMelter.alloyTank);
registerMelterModel(ModuleMelter.porcelainMelter);
registerItemModel(ModuleMelter.porcelainAlloyTank);

// porcelain tank items
Item tank = Item.getItemFromBlock(ModuleFeature.porcelainTank);
Item tank = Item.getItemFromBlock(ModuleMelter.porcelainTank);
if(tank != null && tank != Items.AIR) {
for(BlockTank.TankType type : BlockTank.TankType.values()) {
ModelLoader.setCustomModelResourceLocation(tank, type.meta, new ModelResourceLocation(tank.getRegistryName(), type.getName()));
Expand All @@ -75,16 +64,16 @@ public void registerItemColors(ColorHandlerEvent.Item event) {
return fluid.getFluid().getColor(fluid);
}
return 0xFFFFFF;
}, ModuleFeature.porcelainTank, ModuleFeature.alloyTank, (Block)null, ModuleFeature.porcelainAlloyTank);
}, ModuleMelter.porcelainTank, ModuleMelter.alloyTank, ModuleMelter.porcelainAlloyTank);
}

@SubscribeEvent
public void onModelBake(ModelBakeEvent event) {
for (BlockTank.TankType type : BlockTank.TankType.values()) {
replaceTankModel(event, ModuleFeature.porcelainTank, type.getName());
replaceTankModel(event, ModuleMelter.porcelainTank, type.getName());
}
replaceTankModel(event, ModuleFeature.alloyTank, "inventory");
replaceTankModel(event, ModuleFeature.porcelainAlloyTank, "inventory");
replaceTankModel(event, ModuleMelter.alloyTank, "inventory");
replaceTankModel(event, ModuleMelter.porcelainAlloyTank, "inventory");
}

private void registerMelterModel(Block block) {
Expand Down

0 comments on commit c8c42ee

Please sign in to comment.