Cables render, need textures

This commit is contained in:
modmuss50 2016-03-05 11:19:33 +00:00
parent e3c150c06e
commit 0204ddc539
7 changed files with 93 additions and 349 deletions

View file

@ -1,68 +0,0 @@
package techreborn.asm;
import java.util.Map;
import net.minecraftforge.fml.common.DummyModContainer;
import net.minecraftforge.fml.common.ModMetadata;
import net.minecraftforge.fml.relauncher.IFMLCallHook;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
import techreborn.lib.ModInfo;
@IFMLLoadingPlugin.MCVersion("1.7.10")
public class LoadingPlugin implements IFMLLoadingPlugin {
public static boolean runtimeDeobfEnabled = false;
public static int stripedClases = 0;
// @Override
// public String[] getASMTransformerClass() {
// return new String[]{"techreborn.asm.ClassTransformation"};
// }
@Override
public String[] getASMTransformerClass() {
return new String[0];
}
@Override
public String getModContainerClass() {
return DummyMod.class.getName();
}
@Override
public String getSetupClass() {
return DummyMod.class.getName();
}
@Override
public void injectData(Map<String, Object> data) {
runtimeDeobfEnabled = (Boolean) data.get("runtimeDeobfuscationEnabled");
}
@Override
public String getAccessTransformerClass() {
return null;
}
public static class DummyMod extends DummyModContainer implements IFMLCallHook {
public DummyMod() {
super(new ModMetadata());
ModMetadata md = getMetadata();
md.autogenerated = true;
md.modId = ModInfo.MOD_ID + "asm";
md.name = md.description = "Techreborn-ASM";
md.parent = ModInfo.MOD_ID;
md.version = "000";
}
@Override
public void injectData(Map<String, Object> data) {
}
@Override
public Void call() throws Exception {
return null;
}
}
}

View file

@ -7,6 +7,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import techreborn.parts.CableMultipart;
import techreborn.parts.EnumCableType;
/**
* Created by Mark on 04/03/2016.
@ -16,7 +17,10 @@ public class ClientPartModelBakery {
@SideOnly(Side.CLIENT)
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onModelBake(ModelBakeEvent event){
event.modelRegistry.putObject(new ModelResourceLocation("techreborn:cable#type=COPPER"), new RenderCablePart());
for(EnumCableType type : EnumCableType.values()){
event.modelRegistry.putObject(new ModelResourceLocation("techreborn:cable#type=" + type.name()), new RenderCablePart(type));
}
}
}

View file

@ -1,5 +1,6 @@
package techreborn.client.render.parts;
import buildcraft.robotics.render.RobotItemModel;
import mcmultipart.client.multipart.ISmartMultipartModel;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
@ -8,8 +9,11 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.model.IBakedModel;
import net.minecraft.client.resources.model.ModelRotation;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.property.IExtendedBlockState;
import org.lwjgl.util.vector.Vector3f;
import reborncore.common.misc.vecmath.Vecs3dCube;
import techreborn.parts.CableMultipart;
import techreborn.parts.EnumCableType;
import java.util.ArrayList;
import java.util.Collections;
@ -21,13 +25,23 @@ public class RenderCablePart implements ISmartMultipartModel {
private TextureAtlasSprite texture;
public RenderCablePart() {
EnumCableType type;
IExtendedBlockState state;
public RenderCablePart(IExtendedBlockState state, EnumCableType type) {
this(type);
this.state = state;
}
public RenderCablePart(EnumCableType type) {
texture = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("fluxedredstone:blocks/cable_redstone");
this.type = type;
}
@Override
public IBakedModel handlePartState(IBlockState state) {
return new RenderCablePart();
return new RenderCablePart((IExtendedBlockState) state, type);
}
public void addCubeToList(Vecs3dCube cube, ArrayList<BakedQuad> list, BlockPartFace face, ModelRotation modelRotation, TextureAtlasSprite cubeTexture) {
@ -52,6 +66,26 @@ public class RenderCablePart implements ISmartMultipartModel {
int thickness = 4;
int lastThickness = 16 - thickness;
addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, lastThickness), list, face, ModelRotation.X0_Y0, texture);
if (state != null) {
if (state.getValue(CableMultipart.UP)) {
addCubeToList(new Vecs3dCube(thickness, lastThickness, thickness, lastThickness, 16.0, lastThickness), list, face, ModelRotation.X0_Y0, texture);
}
if (state.getValue(CableMultipart.DOWN)) {
addCubeToList(new Vecs3dCube(thickness, 0.0, thickness, lastThickness, thickness, lastThickness), list, face, ModelRotation.X0_Y0, texture);
}
if (state.getValue(CableMultipart.NORTH)) {
addCubeToList(new Vecs3dCube(thickness, thickness, 0.0, lastThickness, lastThickness, lastThickness), list, face, ModelRotation.X0_Y0, texture);
}
if (state.getValue(CableMultipart.SOUTH)) {
addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, 16.0), list, face, ModelRotation.X0_Y0, texture);
}
if (state.getValue(CableMultipart.EAST)) {
addCubeToList(new Vecs3dCube(thickness, thickness, thickness, 16.0, lastThickness, lastThickness), list, face, ModelRotation.X0_Y0, texture);
}
if (state.getValue(CableMultipart.WEST)) {
addCubeToList(new Vecs3dCube(0.0, thickness, thickness, lastThickness, lastThickness, lastThickness), list, face, ModelRotation.X0_Y0, texture);
}
}
return list;
}

View file

@ -41,222 +41,30 @@ public class CableMultipart extends Multipart implements IOccludingPart, ISlotte
public Map<EnumFacing, BlockPos> connectedSides;
public int ticks = 0;
public ItemStack stack;
public int type = 0;
public static final IUnlistedProperty UP = Properties.toUnlisted(PropertyBool.create("up"));
public static final IUnlistedProperty DOWN = Properties.toUnlisted(PropertyBool.create("down"));
public static final IUnlistedProperty NORTH = Properties.toUnlisted(PropertyBool.create("north"));
public static final IUnlistedProperty EAST = Properties.toUnlisted(PropertyBool.create("east"));
public static final IUnlistedProperty SOUTH = Properties.toUnlisted(PropertyBool.create("south"));
public static final IUnlistedProperty WEST = Properties.toUnlisted(PropertyBool.create("west"));
public static final IProperty TYPE = PropertyEnum.create("type", CableTypes.class);
public static final IUnlistedProperty<Boolean> UP = Properties.toUnlisted(PropertyBool.create("up"));
public static final IUnlistedProperty<Boolean> DOWN = Properties.toUnlisted(PropertyBool.create("down"));
public static final IUnlistedProperty<Boolean> NORTH = Properties.toUnlisted(PropertyBool.create("north"));
public static final IUnlistedProperty<Boolean> EAST = Properties.toUnlisted(PropertyBool.create("east"));
public static final IUnlistedProperty<Boolean> SOUTH = Properties.toUnlisted(PropertyBool.create("south"));
public static final IUnlistedProperty<Boolean> WEST = Properties.toUnlisted(PropertyBool.create("west"));
public static final IProperty TYPE = PropertyEnum.create("type", EnumCableType.class);
public CableMultipart() {
EnumCableType type;
public CableMultipart(EnumCableType type) {
this.type = type;
connectedSides = new HashMap<>();
refreshBounding();
}
public static int getMaxCapacity(int type) {
switch (type) {
case 0:
return 128;
case 1:
return 128;
case 2:
return 512;
case 3:
return 512;
case 4:
return 512;
case 5:
return 2048;
case 6:
return 2048;
case 7:
return 2048;
case 8:
return 2048;
case 9:
return 8192;
case 10:
return 32;
case 11:
return 8192;
case 12:
return 8192;
case 13:
return 32;
case 14:
return 32;
default:
return 0;
}
}
public static float getCableThickness(int cableType) {
float p = 1.0F;
switch (cableType) {
case 0:
p = 6.0F;
break;
case 1:
p = 4.0F;
break;
case 2:
p = 3.0F;
break;
case 3:
p = 6.0F;
break;
case 4:
p = 6.0F;
break;
case 5:
p = 6.0F;
break;
case 6:
p = 10.0F;
break;
case 7:
p = 10.0F;
break;
case 8:
p = 12.0F;
break;
case 9:
p = 4.0F;
break;
case 10:
p = 4.0F;
break;
case 11:
p = 8.0F;
break;
case 12:
p = 8.0F;
break;
case 13:
p = 16.0F;
break;
case 14:
p = 6.0F;
}
return p / 16.0F;
}
public static String getNameFromType(int cableType) {
String p = null;
switch (cableType) {
case 0:
p = "insulatedCopperCable";
break;
case 1:
p = "copperCable";
break;
case 2:
p = "goldCable";
break;
case 3:
p = "insulatedGoldCable";
break;
case 4:
p = "doubleInsulatedGoldCable";
break;
case 5:
p = "ironCable";
break;
case 6:
p = "insulatedIronCable";
break;
case 7:
p = "doubleInsulatedIronCable";
break;
case 8:
p = "trippleInsulatedIronCable";
break;
case 9:
p = "glassFiberCable";
break;
case 10:
p = "tinCable";
break;
case 11:
p = "detectorCableBlock";//Detector
break;
case 12:
p = "splitterCableBlock";// Splitter
break;
case 13:
p = "insulatedtinCable";
break;
case 14:
p = "unused"; // unused?
}
return p;
}
public static String getTextureNameFromType(int cableType) {
String p = null;
switch (cableType) {
case 0:
p = "insulatedCopperCableItem";
break;
case 1:
p = "copperCableItem";
break;
case 2:
p = "goldCableItem";
break;
case 3:
p = "insulatedGoldCableItem";
break;
case 4:
p = "doubleInsulatedGoldCableItem";
break;
case 5:
p = "ironCableItem";
break;
case 6:
p = "insulatedIronCableItem";
break;
case 7:
p = "doubleInsulatedIronCableItem";
break;
case 8:
p = "trippleInsulatedIronCableItem";
break;
case 9:
p = "glassFiberCableItem";
break;
case 10:
p = "tinCableItem";
break;
case 11:
p = "detectorCableItem";//Detector
break;
case 12:
p = "splitterCableItem";// Splitter
break;
case 13:
p = "insulatedTinCableItem";
break;
case 14:
p = "unused"; // unused?
}
return p;
}
public void setType(int newType) {
this.type = newType;
refreshBounding();
public CableMultipart(){
this(EnumCableType.COPPER);
}
public void refreshBounding() {
float centerFirst = center - offset;
double w = getCableThickness(type) / 2;
double w = (type.cableThickness / 16) - 0.5;
boundingBoxes[6] = new Vecs3dCube(centerFirst - w - 0.03, centerFirst
- w - 0.08, centerFirst - w - 0.03, centerFirst + w + 0.08,
centerFirst + w + 0.04, centerFirst + w + 0.08);
@ -417,42 +225,6 @@ public class CableMultipart extends Multipart implements IOccludingPart, ISlotte
}
}
public double getConductionLoss() {
switch (this.type) {
case 0:
return 0.2D;
case 1:
return 0.3D;
case 2:
return 0.5D;
case 3:
return 0.45D;
case 4:
return 0.4D;
case 5:
return 1.0D;
case 6:
return 0.95D;
case 7:
return 0.9D;
case 8:
return 0.8D;
case 9:
return 0.025D;
case 10:
return 0.025D;
case 11:
return 0.5D;
case 12:
return 0.5D;
case 13:
default:
return 0.025D;
case 14:
return 0.2D;
}
}
@Override
public EnumSet<PartSlot> getSlotMask() {
return EnumSet.of(PartSlot.CENTER);
@ -473,7 +245,7 @@ public class CableMultipart extends Multipart implements IOccludingPart, ISlotte
.withProperty(SOUTH, shouldConnectTo(EnumFacing.SOUTH))
.withProperty(WEST, shouldConnectTo(EnumFacing.WEST))
.withProperty(EAST, shouldConnectTo(EnumFacing.EAST))
.withProperty(TYPE, CableTypes.COPPER);
.withProperty(TYPE, type);
}
@Override

View file

@ -1,22 +0,0 @@
package techreborn.parts;
import net.minecraft.util.IStringSerializable;
/**
* Created by Mark on 05/03/2016.
*/
public enum CableTypes implements IStringSerializable {
COPPER("copper"),
TIN("tin");
private String friendlyName;
CableTypes(String friendlyName) {
this.friendlyName = friendlyName;
}
@Override
public String getName() {
return friendlyName;
}
}

View file

@ -0,0 +1,29 @@
package techreborn.parts;
import net.minecraft.util.IStringSerializable;
public enum EnumCableType implements IStringSerializable {
COPPER("copper"),
TIN("tin"),
GOLD("gold"),
HV("hv"),
GLASSFIBER("glassfiber"),
ICOPPER("insulatedcopper"),
IGOLD("insulatedgold"),
IHV("insulatedhv");
private String friendlyName;
public String textureName = "minecraft:blocks/iron_block";
public int transferRate= 128;
public double cableThickness = 3.0;
public boolean canKill = false;
EnumCableType(String friendlyName) {
this.friendlyName = friendlyName;
}
@Override
public String getName() {
return friendlyName;
}
}

View file

@ -27,8 +27,8 @@ import java.util.List;
public class ItemCables extends ItemMultiPart implements ITexturedItem {
public static ItemStack getCableByName(String name, int count) {
for (int i = 0; i < types.length; i++) {
if (types[i].equalsIgnoreCase(name)) {
for (int i = 0; i < EnumCableType.values().length; i++) {
if (EnumCableType.values()[i].name().equalsIgnoreCase(name)) {
return new ItemStack(TechRebornParts.cables, count, i);
}
}
@ -39,11 +39,6 @@ public class ItemCables extends ItemMultiPart implements ITexturedItem {
return getCableByName(name, 1);
}
public static final String[] types = new String[]
{"copper", "tin", "gold", "hv", "glassfiber", "insulatedcopper", "insulatedgold", "insulatedhv"};
//NOTE FOR MODMUSS copper tin and gold cables that are not insulated should hurt the player if they tuch them
public ItemCables() {
setCreativeTab(TechRebornCreativeTab.instance);
setHasSubtypes(true);
@ -54,7 +49,7 @@ public class ItemCables extends ItemMultiPart implements ITexturedItem {
@Override
public IMultipart createPart(World world, BlockPos pos, EnumFacing side, Vec3 hit, ItemStack stack, EntityPlayer player) {
return new CableMultipart();
return new CableMultipart(EnumCableType.values()[stack.getItemDamage()]);
}
@ -62,28 +57,28 @@ public class ItemCables extends ItemMultiPart implements ITexturedItem {
// gets Unlocalized Name depending on meta data
public String getUnlocalizedName(ItemStack itemStack) {
int meta = itemStack.getItemDamage();
if (meta < 0 || meta >= types.length) {
if (meta < 0 || meta >= EnumCableType.values().length) {
meta = 0;
}
return super.getUnlocalizedName() + "." + types[meta];
return super.getUnlocalizedName() + "." + EnumCableType.values()[meta];
}
// Adds Dusts SubItems To Creative Tab
public void getSubItems(Item item, CreativeTabs creativeTabs, List list) {
for (int meta = 0; meta < types.length; ++meta) {
for (int meta = 0; meta < EnumCableType.values().length; ++meta) {
list.add(new ItemStack(item, 1, meta));
}
}
@Override
public String getTextureName(int damage) {
return ModInfo.MOD_ID + ":items/cables/" + types[damage];
return ModInfo.MOD_ID + ":items/cables/" + EnumCableType.values()[damage];
}
@Override
public int getMaxMeta() {
return types.length;
return EnumCableType.values().length;
}
@Override