Fix cable models

This commit is contained in:
Prospector 2017-06-12 10:25:29 -07:00
parent e0c39a4777
commit 11527b3a22
12 changed files with 219 additions and 235 deletions

View file

@ -36,10 +36,7 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.*;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
@ -91,7 +88,7 @@ public class BlockCable extends BlockContainer {
@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
return new ItemStack(this, 1, 0);
return state.getValue(TYPE).getStack();
}
@Override
@ -104,6 +101,19 @@ public class BlockCable extends BlockContainer {
return false;
}
@Override
public BlockRenderLayer getBlockLayer() {
return BlockRenderLayer.CUTOUT;
}
@Override
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
if (blockState.getValue(TYPE) == EnumCableType.GLASSFIBER)
return false;
else
return true;
}
@Override
public boolean isFullBlock(IBlockState state) {
return false;

View file

@ -24,8 +24,12 @@
package techreborn.client;
import com.google.common.collect.Maps;
import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.DefaultStateMapper;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
@ -33,12 +37,15 @@ import techreborn.blocks.BlockOre;
import techreborn.blocks.BlockOre2;
import techreborn.blocks.BlockStorage;
import techreborn.blocks.BlockStorage2;
import techreborn.blocks.cable.BlockCable;
import techreborn.blocks.cable.EnumCableType;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.init.ModItems;
import techreborn.items.*;
import java.util.Map;
public class RegisterItemJsons {
public static void registerModels() {
registerItems();
@ -179,8 +186,33 @@ public class RegisterItemJsons {
}
for (EnumCableType cableType : EnumCableType.values()) {
registerBlockstate(ModBlocks.CABLE, cableType.ordinal(), "inv_" + cableType.getName().toLowerCase());
registerBlockstateMultiItem(Item.getItemFromBlock(ModBlocks.CABLE), cableType.ordinal(), cableType.getName().toLowerCase(), "cable_inv");
}
ModelLoader.setCustomStateMapper(ModBlocks.CABLE, new DefaultStateMapper() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
Map<IProperty<?>, Comparable<?>> map = Maps.<IProperty<?>, Comparable<?>>newLinkedHashMap(state.getProperties());
if (state.getValue(BlockCable.TYPE).ordinal() <= 4) {
return new ModelResourceLocation(new ResourceLocation(ModBlocks.CABLE.getRegistryName().getResourceDomain(), ModBlocks.CABLE.getRegistryName().getResourcePath()) + "_thin", this.getPropertyString(map));
}
return new ModelResourceLocation(new ResourceLocation(ModBlocks.CABLE.getRegistryName().getResourceDomain(), ModBlocks.CABLE.getRegistryName().getResourcePath()) + "_thick", this.getPropertyString(map));
}
});
}
public static void setBlockStateMapper(Block block, String path, IProperty... ignoredProperties) {
final String slash = !path.isEmpty() ? "/" : "";
ModelLoader.setCustomStateMapper(block, new DefaultStateMapper() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
Map<IProperty<?>, Comparable<?>> map = Maps.<IProperty<?>, Comparable<?>>newLinkedHashMap(state.getProperties());
for (IProperty<?> iproperty : ignoredProperties) {
map.remove(iproperty);
}
return new ModelResourceLocation(new ResourceLocation(block.getRegistryName().getResourceDomain(), path + slash + block.getRegistryName().getResourcePath()), this.getPropertyString(map));
}
});
}
private static void registerBlocks() {
@ -225,4 +257,9 @@ public class RegisterItemJsons {
ResourceLocation loc = new ResourceLocation("techreborn", path);
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(loc, "type=" + variantName));
}
private static void registerBlockstateMultiItem(Item item, int meta, String variantName, String path) {
ResourceLocation loc = new ResourceLocation("techreborn", path);
ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(loc, "type=" + variantName));
}
}

View file

@ -1,174 +0,0 @@
{
"forge_marker": 1,
"defaults": {
"transform": "forge:default-block",
"model": "techreborn:cable_thin",
"textures": {
"cable": "techreborn:block/blocks/cables/copper_cable",
"particle": "techreborn:block/blocks/cables/copper_cable"
}
},
"variants": {
"inventory": [
{
"transform": "forge:default-block",
"model": "techreborn:cable",
"textures": {
"cable": "techreborn:blocks/cables/copper_cable"
}
}
],
"down": {
"true": {
"submodel": {
"pipeDown": {
"model": "techreborn:cable_connection_alt_thin",
"x": 270
}
}
},
"false": {
}
},
"east": {
"true": {
"submodel": "techreborn:cable_connection_thin",
"y": 90
},
"false": {
}
},
"north": {
"true": {
"submodel": "techreborn:cable_connection_thin"
},
"false": {
}
},
"south": {
"true": {
"submodel": "techreborn:cable_connection_alt_thin"
},
"false": {
}
},
"up": {
"true": {
"submodel": {
"pipeUp": {
"model": "techreborn:cable_connection_thin",
"x": 270
}
}
},
"false": {
}
},
"west": {
"true": {
"submodel": "techreborn:cable_connection_alt_thin",
"y": 90
},
"false": {
}
},
"type": {
"copper": {
"textures": {
"cable": "techreborn:blocks/cables/copper_cable"
}
},
"tin": {
"textures": {
"cable": "techreborn:blocks/cables/tin_cable"
}
},
"gold": {
"textures": {
"cable": "techreborn:blocks/cables/gold_cable"
}
},
"hv": {
"textures": {
"cable": "techreborn:blocks/cables/hv_cable"
}
},
"glassfiber": {
"textures": {
"cable": "techreborn:blocks/cables/glass_fiber_cable"
}
},
"insulatedcopper": {
"textures": {
"cable": "techreborn:blocks/cables/copper_insulated_cable"
}
},
"insulatedgold": {
"textures": {
"cable": "techreborn:blocks/cables/gold_insulated_cable"
}
},
"insulatedhv": {
"textures": {
"cable": "techreborn:blocks/cables/hv_insulated_cable"
}
},
"inv_copper": {
"transform": "forge:default-block",
"model": "techreborn:cable",
"textures": {
"cable": "techreborn:blocks/cables/copper_cable"
}
},
"inv_tin": {
"transform": "forge:default-block",
"model": "techreborn:cable",
"textures": {
"cable": "techreborn:blocks/cables/tin_cable"
}
},
"inv_gold": {
"transform": "forge:default-block",
"model": "techreborn:cable",
"textures": {
"cable": "techreborn:blocks/cables/gold_cable"
}
},
"inv_hv": {
"transform": "forge:default-block",
"model": "techreborn:cable",
"textures": {
"cable": "techreborn:blocks/cables/hv_cable"
}
},
"inv_glassfiber": {
"transform": "forge:default-block",
"model": "techreborn:cable",
"textures": {
"cable": "techreborn:blocks/cables/glass_fiber_cable"
}
},
"inv_insulatedcopper": {
"transform": "forge:default-block",
"model": "techreborn:cable",
"textures": {
"cable": "techreborn:blocks/cables/copper_insulated_cable"
}
},
"inv_insulatedgold": {
"transform": "forge:default-block",
"model": "techreborn:cable",
"textures": {
"cable": "techreborn:blocks/cables/gold_insulated_cable"
}
},
"inv_insulatedhv": {
"transform": "forge:default-block",
"model": "techreborn:cable",
"textures": {
"cable": "techreborn:blocks/cables/hv_insulated_cable"
}
}
}
}
}

View file

@ -1,17 +1,51 @@
{
"forge_marker": 1,
"defaults": {
"transform": "forge:default-block",
"transform": "forge:default-item",
"model": "techreborn:item"
},
"variants": {
"copper": [
{
"transform": "forge:default-item",
"type": {
"copper": {
"textures": {
"texture": "techreborn:items/cables/copper"
}
},
"tin": {
"textures": {
"texture": "techreborn:items/cables/tin"
}
},
"gold": {
"textures": {
"texture": "techreborn:items/cables/gold"
}
},
"hv": {
"textures": {
"texture": "techreborn:items/cables/hv"
}
},
"glassfiber": {
"textures": {
"texture": "techreborn:items/cables/glassfiber"
}
},
"insulatedcopper": {
"textures": {
"texture": "techreborn:items/cables/insulatedcopper"
}
},
"insulatedgold": {
"textures": {
"texture": "techreborn:items/cables/insulatedgold"
}
},
"insulatedhv": {
"textures": {
"texture": "techreborn:items/cables/insulatedhv"
}
}
]
}
}
}

View file

@ -0,0 +1,83 @@
{
"forge_marker": 1,
"defaults": {
"transform": "forge:default-block",
"model": "techreborn:cable",
"textures": {
"particle": "#cable"
}
},
"variants": {
"down": {
"true": {
"submodel": {
"pipeDown": {
"model": "techreborn:cable_connection_alt",
"x": 270
}
}
},
"false": {
}
},
"east": {
"true": {
"submodel": "techreborn:cable_connection",
"y": 90
},
"false": {
}
},
"north": {
"true": {
"submodel": "techreborn:cable_connection"
},
"false": {
}
},
"south": {
"true": {
"submodel": "techreborn:cable_connection_alt"
},
"false": {
}
},
"up": {
"true": {
"submodel": {
"pipeUp": {
"model": "techreborn:cable_connection",
"x": 270
}
}
},
"false": {
}
},
"west": {
"true": {
"submodel": "techreborn:cable_connection_alt",
"y": 90
},
"false": {
}
},
"type": {
"insulatedcopper": {
"textures": {
"cable": "techreborn:blocks/cables/copper_insulated_cable"
}
},
"insulatedgold": {
"textures": {
"cable": "techreborn:blocks/cables/gold_insulated_cable"
}
},
"insulatedhv": {
"textures": {
"cable": "techreborn:blocks/cables/hv_insulated_cable"
}
}
}
}
}

View file

@ -4,11 +4,19 @@
"transform": "forge:default-block",
"model": "techreborn:cable_thin",
"textures": {
"cable": "techreborn:block/cable",
"particle": "#cable"
}
},
"variants": {
"inventory": [
{
"transform": "forge:default-block",
"model": "techreborn:cable",
"textures": {
"cable": "techreborn:blocks/cables/copper_cable"
}
}
],
"down": {
"true": {
"submodel": {
@ -88,21 +96,6 @@
"textures": {
"cable": "techreborn:blocks/cables/glass_fiber_cable"
}
},
"insulatedcopper": {
"textures": {
"cable": "techreborn:blocks/cables/copper_insulated_cable"
}
},
"insulatedgold": {
"textures": {
"cable": "techreborn:blocks/cables/gold_insulated_cable"
}
},
"insulatedhv": {
"textures": {
"cable": "techreborn:blocks/cables/hv_insulated_cable"
}
}
}
}

View file

@ -293,14 +293,14 @@ item.techreborn.dust.diorite.name=Diorite Dust
item.techreborn.dust.granite.name=Granite Dust
item.techreborn.wrench.name=Wrench
item.techreborn.cable.COPPER.name=Copper Cable
item.techreborn.cable.TIN.name=Tin Cable
item.techreborn.cable.GOLD.name=Gold Cable
item.techreborn.cable.HV.name=HV Cable
item.techreborn.cable.GLASSFIBER.name=Glass Fiber Cable
item.techreborn.cable.ICOPPER.name=Insulated Copper Cable
item.techreborn.cable.IGOLD.name=Insulated Gold Cable
item.techreborn.cable.IHV.name=Insulated HV Cable
tile.techreborn.cable.copper.name=Copper Cable
tile.techreborn.cable.tin.name=Tin Cable
tile.techreborn.cable.gold.name=Gold Cable
tile.techreborn.cable.hv.name=HV Cable
tile.techreborn.cable.glassfiber.name=Glass Fiber Cable
tile.techreborn.cable.insulatedcopper.name=Insulated Copper Cable
tile.techreborn.cable.insulatedgold.name=Insulated Gold Cable
tile.techreborn.cable.insulatedhv.name=Insulated HV Cable
item.techreborn.scrapbox.name=Scrap Box
item.techreborn.part.carbon_mesh.name=Carbon Mesh
item.techreborn.part.carbon_fiber.name=Carbon Fiber

View file

@ -1,20 +1,21 @@
{
"credit": "Made with Blockbench, a free, modern block model editor by JannisX11",
"textures": {"0": "textures/#cable"},
"elements": [
{
"name": "Cable",
"from": [6, 6, 6],
"to": [10, 10, 10],
"shade": true,
"faces": {
"north": {"uv": [1, 1, 5, 5], "texture": "#0"},
"east": {"uv": [1, 1, 5, 5], "texture": "#0"},
"south": {"uv": [1, 1, 5, 5], "texture": "#0"},
"west": {"uv": [1, 1, 5, 5], "texture": "#0"},
"up": {"uv": [1, 1, 5, 5], "texture": "#0"},
"down": {"uv": [1, 1, 5, 5], "texture": "#0"}
}
}
]
"__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
"textures": {
"0": "#cable"
},
"elements": [
{
"name": "Cable",
"from": [ 5.0, 5.0, 5.0 ],
"to": [ 11.0, 11.0, 11.0 ],
"faces": {
"north": { "texture": "#0", "uv": [ 0.0, 0.0, 6.0, 6.0 ] },
"east": { "texture": "#0", "uv": [ 0.0, 0.0, 6.0, 6.0 ] },
"south": { "texture": "#0", "uv": [ 0.0, 0.0, 6.0, 6.0 ] },
"west": { "texture": "#0", "uv": [ 0.0, 0.0, 6.0, 6.0 ] },
"up": { "texture": "#0", "uv": [ 0.0, 0.0, 6.0, 6.0 ] },
"down": { "texture": "#0", "uv": [ 0.0, 0.0, 6.0, 6.0 ] }
}
}
]
}

View file

@ -9,9 +9,9 @@
"from": [ 5.0, 5.0, 0.0 ],
"to": [ 11.0, 11.0, 5.0 ],
"faces": {
"north": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 6.0 ], "cullface": "north" },
"north": { "texture": "#0", "uv": [ 0.0, 0.0, 6.0, 6.0 ], "cullface": "north" },
"east": { "texture": "#0", "uv": [ 0.0, 6.0, 5.0, 12.0 ] },
"south": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 6.0 ], "cullface": "south" },
"south": { "texture": "#0", "uv": [ 0.0, 0.0, 6.0, 6.0 ], "cullface": "south" },
"west": { "texture": "#0", "uv": [ 0.0, 6.0, 5.0, 12.0 ] },
"up": { "texture": "#0", "uv": [ 0.0, 6.0, 5.0, 12.0 ], "rotation": 90 },
"down": { "texture": "#0", "uv": [ 0.0, 6.0, 5.0, 12.0 ], "rotation": 90 }

View file

@ -18,7 +18,7 @@
],
"faces": {
"north": {
"texture": "#-1",
"texture": "#0",
"uv": [
0.0,
0.0,
@ -37,7 +37,7 @@
]
},
"south": {
"texture": "#-1",
"texture": "#0",
"uv": [
0.0,
0.0,

View file

@ -10,13 +10,13 @@
"faces": {
"north": {
"uv": [1, 1, 5, 5],
"texture": "#-1",
"texture": "#0",
"cullface": "north"
},
"east": {"uv": [1, 7, 7, 11], "texture": "#0"},
"south": {
"uv": [1, 1, 5, 5],
"texture": "#-1",
"texture": "#0",
"cullface": "south"
},
"west": {"uv": [1, 7, 7, 11], "texture": "#0"},

View file

@ -10,13 +10,13 @@
"faces": {
"north": {
"uv": [1, 1, 5, 5],
"texture": "#-1",
"texture": "#0",
"cullface": "north"
},
"east": {"uv": [0, 7, 6, 11], "texture": "#0"},
"south": {
"uv": [1, 1, 5, 5],
"texture": "#-1",
"texture": "#0",
"cullface": "south"
},
"west": {"uv": [0, 7, 6, 11], "texture": "#0"},