Its all broke, mcmultipart support

This commit is contained in:
modmuss50 2016-03-19 18:01:34 +00:00
parent f255137753
commit 471a945de6
18 changed files with 83 additions and 73 deletions

View file

@ -80,7 +80,7 @@ if (ENV.BUILD_NUMBER) {
}
minecraft {
version = "1.9-12.16.0.1766-1.9"
version = "1.9-12.16.0.1770-1.9"
mappings = "snapshot_20160316"
replace "@MODVERSION@", project.version
// makeObfSourceJar = false

View file

@ -1,5 +1,6 @@
package techreborn.client.render.parts;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
@ -13,7 +14,7 @@ public class ClientPartLoader implements ICompatModule {
@Override
public void preInit(FMLPreInitializationEvent event) {
// MinecraftForge.EVENT_BUS.register(new ClientPartModelBakery());
MinecraftForge.EVENT_BUS.register(new ClientPartModelBakery());
}
@Override

View file

@ -1,6 +1,6 @@
package techreborn.client.render.parts;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
@ -19,7 +19,7 @@ public class ClientPartModelBakery {
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onModelBake(ModelBakeEvent event){
for(EnumCableType type : EnumCableType.values()){
event.modelRegistry.putObject(new ModelResourceLocation("techreborn:cable#type=" + type.getName().toLowerCase()), new RenderCablePart(type));
event.getModelRegistry().putObject(new ModelResourceLocation("techreborn:cable#type=" + type.getName().toLowerCase()), new RenderCablePart(type));
}
}

View file

@ -1,16 +1,16 @@
package techreborn.client.render.parts;
import mcmultipart.client.multipart.ISmartMultipartModel;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.BlockFaceUV;
import net.minecraft.client.renderer.block.model.BlockPartFace;
import net.minecraft.client.renderer.block.model.FaceBakery;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.block.model.ModelRotation;
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;
@ -19,10 +19,9 @@ import techreborn.parts.CableMultipart;
import techreborn.parts.EnumCableType;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class RenderCablePart implements ISmartMultipartModel {
public class RenderCablePart implements IBakedModel {
private FaceBakery faceBakery = new FaceBakery();
@ -30,23 +29,11 @@ public class RenderCablePart implements ISmartMultipartModel {
EnumCableType type;
IExtendedBlockState state;
public RenderCablePart(IExtendedBlockState state, EnumCableType type) {
this(type);
this.state = state;
}
public RenderCablePart(EnumCableType type) {
texture = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(type.textureName);
this.type = type;
}
@Override
public IBakedModel handlePartState(IBlockState state) {
return new RenderCablePart((IExtendedBlockState) state, type);
}
public void addCubeToList(Vecs3dCube cube, ArrayList<BakedQuad> list, BlockPartFace face, ModelRotation modelRotation, TextureAtlasSprite cubeTexture) {
list.add(faceBakery.makeBakedQuad(new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMinZ()), new Vector3f((float) cube.getMaxX(), (float) cube.getMinY(), (float) cube.getMaxZ()), face, cubeTexture, EnumFacing.DOWN, modelRotation, null, true, true));//down
list.add(faceBakery.makeBakedQuad(new Vector3f((float) cube.getMinX(), (float) cube.getMaxY(), (float) cube.getMinZ()), new Vector3f((float) cube.getMaxX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture, EnumFacing.UP, modelRotation, null, true, true));//up
@ -57,17 +44,13 @@ public class RenderCablePart implements ISmartMultipartModel {
}
@Override
public List<BakedQuad> getFaceQuads(EnumFacing p_177551_1_) {
return Collections.emptyList();
}
@Override
public List<BakedQuad> getGeneralQuads() {
public List<BakedQuad> getQuads(IBlockState blockState, EnumFacing side, long rand) {
ArrayList<BakedQuad> list = new ArrayList<BakedQuad>();
BlockFaceUV uv = new BlockFaceUV(new float[]{0.0F, 0.0F, 16.0F, 16.0F}, 0);
BlockPartFace face = new BlockPartFace(null, 0, "", uv);
double thickness = type.cableThickness;
double lastThickness = 16 - thickness;
IExtendedBlockState state = (IExtendedBlockState) blockState;
addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, lastThickness), list, face, ModelRotation.X0_Y0, texture);
if (state != null) {
if (state.getValue(CableMultipart.UP)) {
@ -116,4 +99,9 @@ public class RenderCablePart implements ISmartMultipartModel {
public ItemCameraTransforms getItemCameraTransforms() {
return ItemCameraTransforms.DEFAULT;
}
@Override
public ItemOverrideList getOverrides() {
return null;
}
}

View file

@ -6,6 +6,7 @@ import net.minecraftforge.fml.relauncher.Side;
import techreborn.client.render.parts.ClientPartLoader;
import techreborn.config.ConfigTechReborn;
import techreborn.parts.StandalonePartCompact;
import techreborn.parts.TechRebornParts;
import java.util.ArrayList;
@ -37,7 +38,7 @@ public class CompatManager {
// registerCompact(RecipesBiomesOPlenty.class, "BiomesOPlenty");
// registerCompact(RecipesBuildcraft.class, "BuildCraft|Builders");
// registerCompact(RecipesThaumcraft.class, "Thaumcraft");
// registerCompact(TechRebornParts.class, "mcmultipart");
registerCompact(TechRebornParts.class, "mcmultipart");
registerCompact(ClientPartLoader.class, "mcmultipart", "@client");
registerCompact(StandalonePartCompact.class, "!mcmultipart");
//registerCompact(WailaMcMultiPartCompact.class, "mcmultipart", "Waila");

View file

@ -4,7 +4,7 @@ import mcmultipart.MCMultiPartMod;
import mcmultipart.microblock.IMicroblock;
import mcmultipart.multipart.ICollidableMultipart;
import mcmultipart.multipart.IMultipartContainer;
import mcmultipart.multipart.IOccludingPart;
import mcmultipart.multipart.INormallyOccludingPart;
import mcmultipart.multipart.ISlottedPart;
import mcmultipart.multipart.Multipart;
import mcmultipart.multipart.MultipartHelper;
@ -16,20 +16,20 @@ import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
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.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.ITickable;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState;
@ -38,8 +38,8 @@ import net.minecraftforge.common.property.Properties;
import reborncore.api.power.IEnergyInterfaceTile;
import reborncore.common.misc.Functions;
import reborncore.common.misc.vecmath.Vecs3dCube;
import reborncore.common.util.WorldUtils;
import techreborn.config.ConfigTechReborn;
import techreborn.parts.walia.IPartWaliaProvider;
import techreborn.power.TRPowerNet;
import techreborn.utils.damageSources.ElectrialShockSource;
@ -52,7 +52,7 @@ import java.util.Map;
/**
* Created by modmuss50 on 02/03/2016.
*/
public abstract class CableMultipart extends Multipart implements IOccludingPart, ISlottedPart, ITickable, ICableType, ICollidableMultipart, IPartWaliaProvider {
public abstract class CableMultipart extends Multipart implements INormallyOccludingPart, ISlottedPart, ITickable, ICableType, ICollidableMultipart {
public Vecs3dCube[] boundingBoxes = new Vecs3dCube[14];
public float center = 0.6F;
@ -110,7 +110,7 @@ public abstract class CableMultipart extends Multipart implements IOccludingPart
@Override
public void addCollisionBoxes(AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity) {
super.addCollisionBoxes(mask, list, collidingEntity);
for (EnumFacing dir : EnumFacing.VALUES) {
if (connectedSides.containsKey(dir) && mask.intersectsWith(boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB()))
list.add(boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB());
@ -118,6 +118,7 @@ public abstract class CableMultipart extends Multipart implements IOccludingPart
if (mask.intersectsWith(boundingBoxes[6].toAABB())) {
list.add(boundingBoxes[6].toAABB());
}
super.addCollisionBoxes(mask, list, collidingEntity);
}
@Override
@ -168,7 +169,7 @@ public abstract class CableMultipart extends Multipart implements IOccludingPart
checkConnectedSides();
for (EnumFacing direction : EnumFacing.VALUES) {
BlockPos blockPos = getPos().offset(direction);
getWorld().markBlockForUpdate(blockPos);
WorldUtils.updateBlock(getWorld(), blockPos);
CableMultipart part = getPartFromWorld(getWorld(), blockPos, direction);
if (part != null) {
part.checkConnectedSides();
@ -229,9 +230,10 @@ public abstract class CableMultipart extends Multipart implements IOccludingPart
}
}
if (!OcclusionHelper.occlusionTest(getContainer().getParts(), this, boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB())) {
return false;
}
//TODO 1.9 boken
// if (!OcclusionHelper.occlusionTest(this, boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB())) {
// return false;
// }
CableMultipart cableMultipart = getPartFromWorld(getWorld(), getPos().offset(dir), dir.getOpposite());
@ -291,7 +293,7 @@ public abstract class CableMultipart extends Multipart implements IOccludingPart
}
@Override
public BlockState createBlockState() {
public BlockStateContainer createBlockState() {
return new ExtendedBlockState(MCMultiPartMod.multipart,
new IProperty[]{
TYPE
@ -306,10 +308,10 @@ public abstract class CableMultipart extends Multipart implements IOccludingPart
}
@Override
public String getModelPath() {
return "techreborn:cable";
}
// @Override
// public String getModelPath() {
// return "techreborn:cable";
// }
@Override
public float getHardness(PartMOP hit) {
@ -335,7 +337,8 @@ public abstract class CableMultipart extends Multipart implements IOccludingPart
entity.attackEntityFrom(new ElectrialShockSource(), 1F);
}
if(ConfigTechReborn.UninsulatedElectocutionSound){
getWorld().playSoundAtEntity(entity, "techreborn:cable_shock", 0.6F, 1F);
//TODO 1.9 nope
// getWorld().playSoundAtEntity(entity, "techreborn:cable_shock", 0.6F, 1F);
}
if(ConfigTechReborn.UninsulatedElectocutionParticle){
getWorld().spawnParticle(EnumParticleTypes.CRIT, entity.posX, entity.posY, entity.posZ, 0, 0, 0);
@ -412,16 +415,22 @@ public abstract class CableMultipart extends Multipart implements IOccludingPart
network = null;
}
// @Override
// public void addInfo(List<String> info) {
// info.add(EnumChatFormatting.GREEN + "EU Transfer: " + EnumChatFormatting.LIGHT_PURPLE + getCableType().transferRate);
// if (getCableType().canKill) {
// info.add(EnumChatFormatting.RED + "Damages entity's!");
// }
// }
@Override
public void addInfo(List<String> info) {
info.add(EnumChatFormatting.GREEN + "EU Transfer: " + EnumChatFormatting.LIGHT_PURPLE + getCableType().transferRate);
if (getCableType().canKill) {
info.add(EnumChatFormatting.RED + "Damages entity's!");
}
public ResourceLocation getModelPath() {
return new ResourceLocation("techreborn:cable");
}
@Override
public boolean canRenderInLayer(EnumWorldBlockLayer layer) {
return layer == EnumWorldBlockLayer.CUTOUT;
public boolean canRenderInLayer(BlockRenderLayer layer) {
return layer == BlockRenderLayer.CUTOUT;
}
}

View file

@ -2,32 +2,40 @@ package techreborn.parts;
import net.minecraft.util.IStringSerializable;
import reborncore.api.power.EnumPowerTier;
import techreborn.parts.types.CopperCable;
import techreborn.parts.types.GlassFiberCable;
import techreborn.parts.types.GoldCable;
import techreborn.parts.types.HVCable;
import techreborn.parts.types.InsulatedCopperCable;
import techreborn.parts.types.InsulatedGoldCable;
import techreborn.parts.types.InsulatedHVCable;
import techreborn.parts.types.TinCable;
public enum EnumCableType implements IStringSerializable {
COPPER("copper", "techreborn:blocks/cables/copper_cable", 128, 12.0, true, EnumPowerTier.LOW),
TIN("tin", "techreborn:blocks/cables/tin_cable", 32, 12.0, true, EnumPowerTier.MEDIUM),
GOLD("gold", "techreborn:blocks/cables/gold_cable", 512, 12.0, true, EnumPowerTier.MEDIUM),
HV("hv", "techreborn:blocks/cables/hv_cable", 2048, 12.0, true, EnumPowerTier.HIGH),
GLASSFIBER("glassfiber", "techreborn:blocks/cables/glass_fiber_cable", 8192, 12.0, false, EnumPowerTier.HIGH),
ICOPPER("insulatedcopper", "techreborn:blocks/cables/copper_insulated_cable", 128, 10.0, false, EnumPowerTier.LOW),
IGOLD("insulatedgold", "techreborn:blocks/cables/gold_insulated_cable", 512, 10.0, false, EnumPowerTier.HIGH),
IHV("insulatedhv", "techreborn:blocks/cables/hv_insulated_cable", 2048, 10.0, false, EnumPowerTier.HIGH);
COPPER("copper", "techreborn:blocks/cables/copper_cable", 128, 12.0, true, EnumPowerTier.LOW, CopperCable.class),
TIN("tin", "techreborn:blocks/cables/tin_cable", 32, 12.0, true, EnumPowerTier.MEDIUM, TinCable.class),
GOLD("gold", "techreborn:blocks/cables/gold_cable", 512, 12.0, true, EnumPowerTier.MEDIUM, GoldCable.class),
HV("hv", "techreborn:blocks/cables/hv_cable", 2048, 12.0, true, EnumPowerTier.HIGH, HVCable.class),
GLASSFIBER("glassfiber", "techreborn:blocks/cables/glass_fiber_cable", 8192, 12.0, false, EnumPowerTier.HIGH, GlassFiberCable.class),
ICOPPER("insulatedcopper", "techreborn:blocks/cables/copper_insulated_cable", 128, 10.0, false, EnumPowerTier.LOW, InsulatedCopperCable.class),
IGOLD("insulatedgold", "techreborn:blocks/cables/gold_insulated_cable", 512, 10.0, false, EnumPowerTier.HIGH, InsulatedGoldCable.class),
IHV("insulatedhv", "techreborn:blocks/cables/hv_insulated_cable", 2048, 10.0, false, EnumPowerTier.HIGH, InsulatedHVCable.class);
private String friendlyName;
public String textureName = "minecraft:blocks/iron_block";
public int transferRate = 128;
public double cableThickness = 3.0;
public boolean canKill = false;
//public Class<? extends CableMultipart> cableClass;
public Class<? extends CableMultipart> cableClass;
public EnumPowerTier tier;
EnumCableType(String friendlyName, String textureName, int transferRate, double cableThickness, boolean canKill, EnumPowerTier tier) {
EnumCableType(String friendlyName, String textureName, int transferRate, double cableThickness, boolean canKill, EnumPowerTier tier, Class<? extends CableMultipart> cableClass) {
this.friendlyName = friendlyName;
this.textureName = textureName;
this.transferRate = transferRate;
this.cableThickness = cableThickness / 2;
this.canKill = canKill;
// this.cableClass = cableClass;
this.cableClass = cableClass;
this.tier = tier;
}

View file

@ -3,16 +3,18 @@ package techreborn.parts;
import mcmultipart.item.ItemMultiPart;
import mcmultipart.multipart.IMultipart;
import me.modmuss50.jsonDestroyer.api.ITexturedItem;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Vec3;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.RebornCore;
import techreborn.client.TechRebornCreativeTab;
import techreborn.lib.ModInfo;
@ -34,7 +36,7 @@ public class ItemCables extends ItemMultiPart implements ITexturedItem {
}
@Override
public IMultipart createPart(World world, BlockPos pos, EnumFacing side, Vec3 hit, ItemStack stack, EntityPlayer player) {
public IMultipart createPart(World world, BlockPos pos, EnumFacing side, Vec3d hit, ItemStack stack, EntityPlayer player) {
try {
return TechRebornParts.multipartHashMap.get(EnumCableType.values()[stack.getItemDamage()]).newInstance();
} catch (InstantiationException | IllegalAccessException e) {
@ -73,6 +75,7 @@ public class ItemCables extends ItemMultiPart implements ITexturedItem {
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) {
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
@ -80,10 +83,10 @@ public class ItemCables extends ItemMultiPart implements ITexturedItem {
@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
EnumCableType type = EnumCableType.values()[stack.getItemDamage()];
tooltip.add(EnumChatFormatting.GREEN + "EU Transfer: " + EnumChatFormatting.LIGHT_PURPLE + type.transferRate);
tooltip.add(TextFormatting.GREEN + "EU Transfer: " + TextFormatting.LIGHT_PURPLE + type.transferRate);
if (type.canKill) {
tooltip.add(EnumChatFormatting.RED + "Damages entity's!");
tooltip.add(TextFormatting.RED + "Damages entity's!");
}
tooltip.add(EnumChatFormatting.GREEN + "Tier: " + EnumChatFormatting.LIGHT_PURPLE + type.tier);
tooltip.add(TextFormatting.GREEN + "Tier: " + TextFormatting.LIGHT_PURPLE + type.tier);
}
}