A good bit of work

- Fixed infuse sprites
- Fixed liquid sprites
- Fixed Plastic Fence block states
- got Plastic Fence to render in block form
This commit is contained in:
aidancbrady committed 2016-05-04 23:37:21 -04:00
1 parent 115443f5f9
commit 13893bd705
24 files changed
+474 -88

No files matched your search

-2
View File
@@ -147,9 +147,7 @@ public class Gas
public Gas setIcon(TextureMap map, String location)
{
iconLocation = new ResourceLocation(location);
sprite = map.registerSprite(iconLocation);
from_fluid = false;
return this;
@@ -11,29 +11,27 @@ import net.minecraft.util.StatCollector;
*/
public final class InfuseType
{
/** The name of this infusion */
/** The name of this infusion. */
public String name;
/** This infuse GUI's icon */
public ResourceLocation icon;
public ResourceLocation iconResource;
/** The texture representing this infuse type. */
public TextureAtlasSprite sprite;
/** The location of this infuse GUI's icon */
public String textureLocation;
/** The unlocalized name of this type. */
public String unlocalizedName;
public InfuseType(String s, String tex)
public InfuseType(String s, ResourceLocation res)
{
name = s;
textureLocation = tex;
iconResource = res;
}
public void setIcon(ResourceLocation i)
public void setIcon(TextureAtlasSprite tex)
{
icon = i;
sprite = tex;
}
public InfuseType setUnlocalizedName(String name)
@@ -10,6 +10,8 @@ import mekanism.api.EnumColor;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.OreGas;
import mekanism.api.infuse.InfuseRegistry;
import mekanism.api.infuse.InfuseType;
import mekanism.api.transmitters.TransmissionType;
import mekanism.client.render.tileentity.RenderConfigurableMachine;
import mekanism.client.render.tileentity.RenderDynamicTank;
@@ -102,26 +104,26 @@ public class MekanismRenderer
overlays.put(type, event.map.registerSprite(new ResourceLocation("mekanism:blocks/overlay/" + type.getTransmission() + "Overlay")));
}
energyIcon = event.map.registerSprite(new ResourceLocation("mekanism:blocks/LiquidEnergy"));
heatIcon = event.map.registerSprite(new ResourceLocation("mekanism:blocks/LiquidHeat"));
energyIcon = event.map.registerSprite(new ResourceLocation("mekanism:blocks/liquid/LiquidEnergy"));
heatIcon = event.map.registerSprite(new ResourceLocation("mekanism:blocks/liquid/LiquidHeat"));
GasRegistry.getGas("hydrogen").setIcon(event.map, "mekanism:blocks/LiquidHydrogen");
GasRegistry.getGas("oxygen").setIcon(event.map,"mekanism:blocks/LiquidOxygen");
GasRegistry.getGas("water").setIcon(event.map,"mekanism:blocks/LiquidSteam");
GasRegistry.getGas("chlorine").setIcon(event.map,"mekanism:blocks/LiquidChlorine");
GasRegistry.getGas("sulfurDioxideGas").setIcon(event.map,"mekanism:blocks/LiquidSulfurDioxide");
GasRegistry.getGas("sulfurTrioxideGas").setIcon(event.map,"mekanism:blocks/LiquidSulfurTrioxide");
GasRegistry.getGas("sulfuricAcid").setIcon(event.map,"mekanism:blocks/LiquidSulfuricAcid");
GasRegistry.getGas("hydrogenChloride").setIcon(event.map,"mekanism:blocks/LiquidHydrogenChloride");
GasRegistry.getGas("liquidOsmium").setIcon(event.map,"mekanism:blocks/LiquidOsmium");
GasRegistry.getGas("liquidStone").setIcon(event.map,"mekanism:blocks/LiquidStone");
GasRegistry.getGas("ethene").setIcon(event.map,"mekanism:blocks/LiquidEthene");
GasRegistry.getGas("brine").setIcon(event.map,"mekanism:blocks/LiquidBrine");
GasRegistry.getGas("sodium").setIcon(event.map,"mekanism:blocks/LiquidSodium");
GasRegistry.getGas("deuterium").setIcon(event.map,"mekanism:blocks/LiquidDeuterium");
GasRegistry.getGas("tritium").setIcon(event.map,"mekanism:blocks/LiquidTritium");
GasRegistry.getGas("fusionFuelDT").setIcon(event.map,"mekanism:blocks/LiquidDT");
GasRegistry.getGas("lithium").setIcon(event.map,"mekanism:blocks/LiquidLithium");
GasRegistry.getGas("hydrogen").setIcon(event.map, "mekanism:blocks/liquid/LiquidHydrogen");
GasRegistry.getGas("oxygen").setIcon(event.map,"mekanism:blocks/liquid/LiquidOxygen");
GasRegistry.getGas("water").setIcon(event.map,"mekanism:blocks/liquid/LiquidSteam");
GasRegistry.getGas("chlorine").setIcon(event.map,"mekanism:blocks/liquid/LiquidChlorine");
GasRegistry.getGas("sulfurDioxideGas").setIcon(event.map,"mekanism:blocks/liquid/LiquidSulfurDioxide");
GasRegistry.getGas("sulfurTrioxideGas").setIcon(event.map,"mekanism:blocks/liquid/LiquidSulfurTrioxide");
GasRegistry.getGas("sulfuricAcid").setIcon(event.map,"mekanism:blocks/liquid/LiquidSulfuricAcid");
GasRegistry.getGas("hydrogenChloride").setIcon(event.map,"mekanism:blocks/liquid/LiquidHydrogenChloride");
GasRegistry.getGas("liquidOsmium").setIcon(event.map,"mekanism:blocks/liquid/LiquidOsmium");
GasRegistry.getGas("liquidStone").setIcon(event.map,"mekanism:blocks/liquid/LiquidStone");
GasRegistry.getGas("ethene").setIcon(event.map,"mekanism:blocks/liquid/LiquidEthene");
GasRegistry.getGas("brine").setIcon(event.map,"mekanism:blocks/liquid/LiquidBrine");
GasRegistry.getGas("sodium").setIcon(event.map,"mekanism:blocks/liquid/LiquidSodium");
GasRegistry.getGas("deuterium").setIcon(event.map,"mekanism:blocks/liquid/LiquidDeuterium");
GasRegistry.getGas("tritium").setIcon(event.map,"mekanism:blocks/liquid/LiquidTritium");
GasRegistry.getGas("fusionFuelDT").setIcon(event.map,"mekanism:blocks/liquid/LiquidDT");
GasRegistry.getGas("lithium").setIcon(event.map,"mekanism:blocks/liquid/LiquidLithium");
for(Gas gas : GasRegistry.getRegisteredGasses())
{
@@ -129,14 +131,19 @@ public class MekanismRenderer
{
if(gas.getUnlocalizedName().contains("clean"))
{
gas.setIcon(event.map,"mekanism:liquid/LiquidCleanOre");
gas.setIcon(event.map,"mekanism:blocks/liquid/LiquidCleanOre");
}
else {
gas.setIcon(event.map,"mekanism:liquid/LiquidOre");
gas.setIcon(event.map,"mekanism:blocks/liquid/LiquidOre");
}
}
}
for(InfuseType type : InfuseRegistry.getInfuseMap().values())
{
type.setIcon(event.map.registerSprite(type.iconResource));
}
/*
if(RenderPartTransmitter.getInstance() != null)
{
@@ -184,33 +191,45 @@ public class MekanismRenderer
textureMap.clear();
for (FluidType type : FluidType.values()) {
for(FluidType type : FluidType.values())
{
textureMap.put(type, new HashMap<Fluid, TextureAtlasSprite>());
}
for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) {
for(Fluid fluid : FluidRegistry.getRegisteredFluids().values())
{
// TextureAtlasSprite toUse = null;
if (fluid.getFlowing() != null) {
if(fluid.getFlowing() != null)
{
String flow = fluid.getFlowing().toString();
TextureAtlasSprite sprite;
if (map.getTextureExtry(flow) != null) {
if(map.getTextureExtry(flow) != null)
{
sprite = map.getTextureExtry(flow);
} else {
}
else {
sprite = map.registerSprite(fluid.getStill());
}
// toUse = sprite;
textureMap.get(FluidType.FLOWING).put(fluid, sprite);
}
if (fluid.getStill() != null) {
if(fluid.getStill() != null)
{
String still = fluid.getStill().toString();
TextureAtlasSprite sprite;
if (map.getTextureExtry(still) != null) {
if(map.getTextureExtry(still) != null)
{
sprite = map.getTextureExtry(still);
} else {
}
else {
sprite = map.registerSprite(fluid.getStill());
}
// toUse = sprite;
textureMap.get(FluidType.STILL).put(fluid, sprite);
}
@@ -220,12 +239,15 @@ public class MekanismRenderer
}
}
public static TextureAtlasSprite getFluidTexture(Fluid fluid, FluidType type) {
if (fluid == null || type == null) {
public static TextureAtlasSprite getFluidTexture(Fluid fluid, FluidType type)
{
if(fluid == null || type == null)
{
return missingIcon;
}
Map<Fluid, TextureAtlasSprite> map = textureMap.get(type);
return map.containsKey(fluid) ? map.get(fluid) : missingIcon;
}
+9 -9
View File
@@ -1269,8 +1269,8 @@ public class Mekanism
GasRegistry.register(new Gas("fusionFuelDT")).registerFluid();
GasRegistry.register(new Gas("lithium")).registerFluid();
FluidRegistry.registerFluid(new Fluid("heavyWater", new ResourceLocation("mekanism:heavy_water"), new ResourceLocation("mekanism:heavy_water")));
FluidRegistry.registerFluid(new Fluid("steam", new ResourceLocation("mekanism:steam"), new ResourceLocation("mekanism:steam")).setGaseous(true));
FluidRegistry.registerFluid(new Fluid("heavyWater", new ResourceLocation("mekanism:blocks/liquid/LiquidHeavyWater"), new ResourceLocation("mekanism:blocks/liquid/LiquidHeavyWater")));
FluidRegistry.registerFluid(new Fluid("steam", new ResourceLocation("mekanism:blocks/liquid/LiquidSteam"), new ResourceLocation("mekanism:blocks/liquid/LiquidSteam")).setGaseous(true));
for(Resource resource : Resource.values())
{
@@ -1287,13 +1287,13 @@ public class Mekanism
Mekanism.proxy.preInit();
//Register infuses
InfuseRegistry.registerInfuseType(new InfuseType("CARBON", "mekanism:infuse/Carbon").setUnlocalizedName("carbon"));
InfuseRegistry.registerInfuseType(new InfuseType("TIN", "mekanism:infuse/Tin").setUnlocalizedName("tin"));
InfuseRegistry.registerInfuseType(new InfuseType("DIAMOND", "mekanism:infuse/Diamond").setUnlocalizedName("diamond"));
InfuseRegistry.registerInfuseType(new InfuseType("REDSTONE", "mekanism:infuse/Redstone").setUnlocalizedName("redstone"));
InfuseRegistry.registerInfuseType(new InfuseType("FUNGI", "mekanism:infuse/Fungi").setUnlocalizedName("fungi"));
InfuseRegistry.registerInfuseType(new InfuseType("BIO", "mekanism:infuse/Bio").setUnlocalizedName("bio"));
InfuseRegistry.registerInfuseType(new InfuseType("OBSIDIAN", "mekanism:infuse/Obsidian").setUnlocalizedName("obsidian"));
InfuseRegistry.registerInfuseType(new InfuseType("CARBON", new ResourceLocation("mekanism:blocks/infuse/Carbon")).setUnlocalizedName("carbon"));
InfuseRegistry.registerInfuseType(new InfuseType("TIN", new ResourceLocation("mekanism:blocks/infuse/Tin")).setUnlocalizedName("tin"));
InfuseRegistry.registerInfuseType(new InfuseType("DIAMOND", new ResourceLocation("mekanism:blocks/infuse/Diamond")).setUnlocalizedName("diamond"));
InfuseRegistry.registerInfuseType(new InfuseType("REDSTONE", new ResourceLocation("mekanism:blocks/infuse/Redstone")).setUnlocalizedName("redstone"));
InfuseRegistry.registerInfuseType(new InfuseType("FUNGI", new ResourceLocation("mekanism:blocks/infuse/Fungi")).setUnlocalizedName("fungi"));
InfuseRegistry.registerInfuseType(new InfuseType("BIO", new ResourceLocation("mekanism:blocks/infuse/Bio")).setUnlocalizedName("bio"));
InfuseRegistry.registerInfuseType(new InfuseType("OBSIDIAN", new ResourceLocation("mekanism:blocks/infuse/Obsidian")).setUnlocalizedName("obsidian"));
Capabilities.registerCapabilities();
}
@@ -19,6 +19,7 @@ import mekanism.common.block.BlockObsidianTNT;
import mekanism.common.block.BlockOre;
import mekanism.common.block.BlockPlastic;
import mekanism.common.block.BlockPlasticFence;
import mekanism.common.block.BlockPlasticFence.PlasticFenceStateMapper;
import mekanism.common.block.BlockSalt;
import mekanism.common.block.states.BlockStateBasic.BasicBlockStateMapper;
import mekanism.common.block.states.BlockStateBasic.BasicBlockType;
@@ -70,8 +71,7 @@ public class MekanismBlocks
private static final IStateMapper machineMapper = new MachineBlockStateMapper();
private static final IStateMapper basicMapper = new BasicBlockStateMapper();
private static final IStateMapper plasticMapper = new PlasticBlockStateMapper();
private static final IStateMapper fenceMapper = new PlasticFenceStateMapper();
/**
* Adds and registers all blocks.
@@ -107,13 +107,14 @@ public class MekanismBlocks
ModelLoader.setCustomStateMapper(GlowPlasticBlock, plasticMapper);
ModelLoader.setCustomStateMapper(ReinforcedPlasticBlock, plasticMapper);
ModelLoader.setCustomStateMapper(RoadPlasticBlock, plasticMapper);
ModelLoader.setCustomStateMapper(PlasticFence, fenceMapper);
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(ObsidianTNT), 0, new ModelResourceLocation("mekanism:ObsidianTNT", "inventory"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(SaltBlock), 0, new ModelResourceLocation("mekanism:SaltBlock", "inventory"));
for(MachineType type : MachineType.values())
{
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(type.typeBlock.getBlock()), type.meta, new ModelResourceLocation("mekanism:" + type.getName(), "active=false,facing=north"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(type.typeBlock.getBlock()), type.meta, new ModelResourceLocation("mekanism:" + type.getName(), (type.hasActiveTexture() ? "active=false," : "") + "facing=north"));
}
for(BasicBlockType type : BasicBlockType.values())
@@ -147,6 +148,7 @@ public class MekanismBlocks
{
EnergyCubeTier tier = ((IEnergyCube)stack.getItem()).getEnergyCubeTier(stack);
ResourceLocation baseLocation = new ResourceLocation("mekanism", "EnergyCube");
return new ModelResourceLocation(baseLocation, "facing=north,tier="+tier);
}
});
@@ -1,5 +1,7 @@
package mekanism.common.block;
import static mekanism.common.block.states.BlockStatePlastic.colorProperty;
import java.util.List;
import mekanism.api.EnumColor;
@@ -8,7 +10,6 @@ import mekanism.common.block.states.BlockStatePlastic;
import mekanism.common.block.states.BlockStatePlastic.PlasticBlockType;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
@@ -23,8 +24,6 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import static mekanism.common.block.states.BlockStatePlastic.colorProperty;
public class BlockPlastic extends Block
{
public PlasticBlockType type;
@@ -60,7 +59,6 @@ public class BlockPlastic extends Block
return state.getValue(colorProperty).getMetadata();
}
/*
@Override
@SideOnly(Side.CLIENT)
@@ -129,6 +127,7 @@ public class BlockPlastic extends Block
{
EnumDyeColor color = state.getValue(colorProperty);
EnumColor dye = EnumColor.DYES[color.getDyeDamage()];
return (int)(dye.getColor(0)*255) << 16 | (int)(dye.getColor(1)*255) << 8 | (int)(dye.getColor(2)*255);
}
@@ -11,11 +11,14 @@ import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@@ -37,8 +40,7 @@ public class BlockPlasticFence extends BlockFence
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(NORTH, false).withProperty(EAST, false)
.withProperty(WEST, false).withProperty(SOUTH, false).withProperty(colorProperty, EnumDyeColor.byMetadata(meta));
return this.getDefaultState().withProperty(colorProperty, EnumDyeColor.byMetadata(meta));
}
@Override
@@ -66,8 +68,10 @@ public class BlockPlasticFence extends BlockFence
@Override
public int getRenderColor(IBlockState state)
{
EnumColor colour = EnumColor.AQUA;
return (int)(colour.getColor(0)*255) << 16 | (int)(colour.getColor(1)*255) << 8 | (int)(colour.getColor(2)*255);
EnumDyeColor color = state.getValue(colorProperty);
EnumColor dye = EnumColor.DYES[color.getDyeDamage()];
return (int)(dye.getColor(0)*255) << 16 | (int)(dye.getColor(1)*255) << 8 | (int)(dye.getColor(2)*255);
}
@Override
@@ -75,4 +79,18 @@ public class BlockPlasticFence extends BlockFence
{
return getMetaFromState(state);
}
public static class PlasticFenceStateMapper extends StateMapperBase
{
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state)
{
String properties = "east=" + state.getValue(EAST) + ",";
properties += "north=" + state.getValue(NORTH) + ",";
properties += "south=" + state.getValue(SOUTH) + ",";
properties += "west=" + state.getValue(WEST);
ResourceLocation baseLocation = new ResourceLocation("mekanism", "PlasticFence");
return new ModelResourceLocation(baseLocation, properties);
}
}
}
@@ -385,7 +385,6 @@ public class BlockStateMachine extends BlockStateFacing
{
return activable;
}
}
public static class MachineBlockPredicate implements Predicate<MachineType>
@@ -412,27 +411,30 @@ public class BlockStateMachine extends BlockStateFacing
BlockMachine block = (BlockMachine)state.getBlock();
MachineType type = state.getValue(block.getProperty());
StringBuilder builder = new StringBuilder();
if(type.hasActiveTexture())
{
builder.append(activeProperty.getName());
builder.append("=");
builder.append(state.getValue(activeProperty));
}
if(type.hasRotations())
{
EnumFacing facing = state.getValue(facingProperty);
if(type.canRotateTo(facing))
{
if(builder.length() > 0)
{
builder.append(",");
}
builder.append(facingProperty.getName());
builder.append("=");
builder.append(facing.getName());
}
else
{
else {
return new ModelResourceLocation("builtin/missing", "missing");
}
}
@@ -443,6 +445,7 @@ public class BlockStateMachine extends BlockStateFacing
}
ResourceLocation baseLocation = new ResourceLocation("mekanism", type.getName());
return new ModelResourceLocation(baseLocation, builder.toString());
}
}
@@ -51,5 +51,4 @@ public class BlockStatePlastic extends BlockState
return new ModelResourceLocation(baseLocation, property);
}
}
}