Skip to content

Commit

Permalink
Add scorched bricks and blocks, make the high oven using them
Browse files Browse the repository at this point in the history
Also includes scorched faucets, drains, channels, and casting blocks
  • Loading branch information
KnightMiner committed Mar 14, 2019
1 parent 36d0761 commit 88ee883
Show file tree
Hide file tree
Showing 110 changed files with 2,227 additions and 76 deletions.
16 changes: 11 additions & 5 deletions src/main/java/knightminer/tcomplement/common/ClientProxy.java
Expand Up @@ -6,17 +6,21 @@
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.IStateMapper;
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.client.renderer.color.ItemColors;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.Fluid;
import slimeknights.tconstruct.shared.client.BakedTableModel;

public class ClientProxy extends CommonProxy {
@Override
Expand Down Expand Up @@ -68,14 +72,16 @@ protected static void registerItemColors(ItemColors colors, IItemColor handler,
}
}

private static class FluidStateMapper extends StateMapperBase implements ItemMeshDefinition {
protected static void wrapTableModel(ModelBakeEvent event, ModelResourceLocation loc) {
IBakedModel model = event.getModelRegistry().getObject(loc);
if(model != null) {
event.getModelRegistry().putObject(loc, new BakedTableModel(model, null, DefaultVertexFormats.BLOCK));
}
}

public final Fluid fluid;
private static class FluidStateMapper extends StateMapperBase implements ItemMeshDefinition {
public final ModelResourceLocation location;

public FluidStateMapper(Fluid fluid) {
this.fluid = fluid;

// have each block hold its fluid per nbt? hm
this.location = new ModelResourceLocation(Util.getResource("fluid_block"), fluid.getName());
}
Expand Down
Expand Up @@ -4,13 +4,10 @@

import knightminer.tcomplement.common.ClientProxy;
import knightminer.tcomplement.library.Util;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import slimeknights.tconstruct.shared.client.BakedTableModel;

public class CeramicsPluginClientProxy extends ClientProxy {

Expand All @@ -29,14 +26,7 @@ protected void registerModels(ModelRegistryEvent event) {
@SubscribeEvent
public void onModelBake(ModelBakeEvent event) {
// convert casting table and basin to bakedTableModel for the item-rendering on/in them
wrap(event, locPorcelainCastingTable);
wrap(event, locPorcelainCastingBasin);
}

private static void wrap(ModelBakeEvent event, ModelResourceLocation loc) {
IBakedModel model = event.getModelRegistry().getObject(loc);
if(model != null) {
event.getModelRegistry().putObject(loc, new BakedTableModel(model, null, DefaultVertexFormats.ITEM));
}
wrapTableModel(event, locPorcelainCastingTable);
wrapTableModel(event, locPorcelainCastingBasin);
}
}
Expand Up @@ -7,10 +7,15 @@
import knightminer.tcomplement.common.PulseBase;
import knightminer.tcomplement.library.TCompRegistry;
import knightminer.tcomplement.plugin.chisel.items.ItemChisel;
import knightminer.tcomplement.steelworks.SteelworksModule;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
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.FMLInterModComms;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.registries.IForgeRegistry;
Expand All @@ -19,10 +24,12 @@
import slimeknights.tconstruct.library.materials.Material;
import slimeknights.tconstruct.library.tools.ToolCore;
import slimeknights.tconstruct.library.tools.ToolPart;
import slimeknights.tconstruct.smeltery.block.BlockSeared.SearedType;
import slimeknights.tconstruct.tools.TinkerMaterials;

@Pulse(id = ChiselPlugin.pulseID, description = "Add a Tinkers version of the Chisel Chisel", modsRequired = "chisel")
public class ChiselPlugin extends PulseBase {
public static final String modid = "chisel";
public static final String pulseID = "ChiselPlugin";

@SidedProxy(clientSide = "knightminer.tcomplement.plugin.chisel.ChiselPluginClientProxy", serverSide = "knightminer.tcomplement.common.CommonProxy")
Expand Down Expand Up @@ -55,6 +62,28 @@ public void init(FMLInitializationEvent event) {

TCompRegistry.tabTools.setDisplayIcon(chisel.buildItem(ImmutableList.of(TinkerMaterials.wood, TinkerMaterials.iron)));
}

// allow chiseling scorched blocks
if(isSteelworksLoaded()) {
for(SearedType type : SearedType.values()) {
// skip cobble since its a bit out of place
if(type != SearedType.COBBLE) {
addChiselVariation(SteelworksModule.scorchedBlock, type.getMeta(), "scorched_block");
}
}
}

proxy.init();
}

protected void addChiselVariation(Block block, int meta, String groupName) {
if(block != null) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("group", groupName);
nbt.setTag("stack", new ItemStack(block, 1, meta).writeToNBT(new NBTTagCompound()));
nbt.setString("block", block.getRegistryName().toString());
nbt.setInteger("meta", meta);
FMLInterModComms.sendMessage(modid, "add_variation", nbt);
}
}
}
Expand Up @@ -39,7 +39,7 @@ public class CommonsModule extends PulseBase {
public static CastCustom cast, castClay;
public static ItemStack stoneBucket;
public static ItemStack castBucket, castBucketClay;
public static ItemStack steelIngot, steelNugget;
public static ItemStack scorchedBrick, steelIngot, steelNugget;

@Subscribe
public void preInit(FMLPreInitializationEvent event) {
Expand Down Expand Up @@ -68,6 +68,7 @@ public void registerItems(Register<Item> event) {
}

if(isSteelworksLoaded()) {
scorchedBrick = materials.addMeta(1, "scorched_brick");
steelIngot = materials.addMeta(10, "steel_ingot");
steelNugget = materials.addMeta(20, "steel_nugget");
}
Expand Down
@@ -1,16 +1,86 @@
package knightminer.tcomplement.steelworks;

import static knightminer.tcomplement.steelworks.SteelworksModule.highOvenController;
import static knightminer.tcomplement.steelworks.SteelworksModule.highOvenIO;
import static knightminer.tcomplement.steelworks.SteelworksModule.scorchedBlock;
import static knightminer.tcomplement.steelworks.SteelworksModule.scorchedCasting;
import static knightminer.tcomplement.steelworks.SteelworksModule.scorchedChannel;
import static knightminer.tcomplement.steelworks.SteelworksModule.scorchedFaucet;
import static knightminer.tcomplement.steelworks.SteelworksModule.scorchedSlab;
import static knightminer.tcomplement.steelworks.SteelworksModule.scorchedSlab2;
import static knightminer.tcomplement.steelworks.SteelworksModule.scorchedStairsBrick;
import static knightminer.tcomplement.steelworks.SteelworksModule.scorchedStairsBrickCracked;
import static knightminer.tcomplement.steelworks.SteelworksModule.scorchedStairsBrickFancy;
import static knightminer.tcomplement.steelworks.SteelworksModule.scorchedStairsBrickSmall;
import static knightminer.tcomplement.steelworks.SteelworksModule.scorchedStairsBrickSquare;
import static knightminer.tcomplement.steelworks.SteelworksModule.scorchedStairsBrickTriangle;
import static knightminer.tcomplement.steelworks.SteelworksModule.scorchedStairsCobble;
import static knightminer.tcomplement.steelworks.SteelworksModule.scorchedStairsCreeper;
import static knightminer.tcomplement.steelworks.SteelworksModule.scorchedStairsPaver;
import static knightminer.tcomplement.steelworks.SteelworksModule.scorchedStairsRoad;
import static knightminer.tcomplement.steelworks.SteelworksModule.scorchedStairsStone;
import static knightminer.tcomplement.steelworks.SteelworksModule.scorchedStairsTile;
import static knightminer.tcomplement.steelworks.SteelworksModule.storage;
import static slimeknights.tconstruct.common.ModelRegisterUtil.registerItemBlockMeta;
import static slimeknights.tconstruct.common.ModelRegisterUtil.registerItemModel;

import knightminer.tcomplement.common.ClientProxy;
import knightminer.tcomplement.library.Util;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import slimeknights.tconstruct.smeltery.block.BlockSmelteryIO;

public class SteelworksClientProxy extends ClientProxy {
@SubscribeEvent
public void registerModels(ModelRegistryEvent event) {
registerItemBlockMeta(SteelworksModule.storage);
registerItemModel(SteelworksModule.highOvenController);
registerItemBlockMeta(storage);

// High Oven Blocks
registerItemModel(highOvenController);
registerItemModel(scorchedFaucet);
registerItemModel(scorchedChannel);
registerItemBlockMeta(scorchedCasting);

// Scorched
registerItemBlockMeta(scorchedBlock);
registerItemBlockMeta(scorchedSlab);
registerItemBlockMeta(scorchedSlab2);
// Scorched Stairs
registerItemModel(scorchedStairsStone);
registerItemModel(scorchedStairsCobble);
registerItemModel(scorchedStairsPaver);
registerItemModel(scorchedStairsBrick);
registerItemModel(scorchedStairsBrickCracked);
registerItemModel(scorchedStairsBrickFancy);
registerItemModel(scorchedStairsBrickSquare);
registerItemModel(scorchedStairsBrickTriangle);
registerItemModel(scorchedStairsBrickSmall);
registerItemModel(scorchedStairsRoad);
registerItemModel(scorchedStairsTile);
registerItemModel(scorchedStairsCreeper);

// High Oven IO
// TODO: ducts
Item io = Item.getItemFromBlock(highOvenIO);
for(BlockSmelteryIO.IOType type : BlockSmelteryIO.IOType.values()) {
String variant = String.format("facing=south,type=%s", type.getName());
ModelLoader.setCustomModelResourceLocation(io, type.meta, new ModelResourceLocation(io.getRegistryName(), variant));
}
}

private static final ResourceLocation SCORCHED_CASTING = Util.getResource("scorched_casting");
private static final ModelResourceLocation SCORCHED_CASTING_TABLE = new ModelResourceLocation(SCORCHED_CASTING, "type=table");
private static final ModelResourceLocation SCORCHED_CASTING_BASIN = new ModelResourceLocation(SCORCHED_CASTING, "type=basin");

@SubscribeEvent
public void onModelBake(ModelBakeEvent event) {
// convert casting table and basin to bakedTableModel for the item-rendering on/in them
wrapTableModel(event, SCORCHED_CASTING_TABLE);
wrapTableModel(event, SCORCHED_CASTING_BASIN);
}
}

0 comments on commit 88ee883

Please sign in to comment.