Loads of work on CTM, work on fixing multi blocks
No files matched your search
@@ -30,7 +30,6 @@ import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
*/
|
||||
public class Coord4D extends BlockPos
|
||||
{
|
||||
|
||||
public int dimensionId;
|
||||
|
||||
/**
|
||||
@@ -127,7 +126,9 @@ public class Coord4D extends BlockPos
|
||||
return null;
|
||||
}
|
||||
|
||||
return world.getTileEntity(this);
|
||||
TileEntity tile = world.getTileEntity(this);
|
||||
|
||||
return (tile != null && tile.hasWorldObj()) ? tile : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,9 +173,7 @@ public class Coord4D extends BlockPos
|
||||
*/
|
||||
public void write(ArrayList<Object> data)
|
||||
{
|
||||
data.add(getX());
|
||||
data.add(getY());
|
||||
data.add(getZ());
|
||||
data.add(toLong());
|
||||
data.add(dimensionId);
|
||||
}
|
||||
|
||||
@@ -281,7 +280,8 @@ public class Coord4D extends BlockPos
|
||||
*/
|
||||
public Coord4D difference(Vec3i vec)
|
||||
{
|
||||
return vec.getX() == 0 && vec.getY() == 0 && vec.getZ() == 0 ? this : new Coord4D(this.getX() - vec.getX(), this.getY() - vec.getY(), this.getZ() - vec.getZ()); }
|
||||
return vec.getX() == 0 && vec.getY() == 0 && vec.getZ() == 0 ? this : new Coord4D(this.getX() - vec.getX(), this.getY() - vec.getY(), this.getZ() - vec.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* A method used to find the EnumFacing represented by the distance of the defined Coord4D. Most likely won't have many
|
||||
@@ -396,12 +396,6 @@ public class Coord4D extends BlockPos
|
||||
return new AxisAlignedBB(this, add(1,1,1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Coord4D clone()
|
||||
{
|
||||
return new Coord4D(getX(), getY(), getZ(), dimensionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
@@ -419,7 +413,6 @@ public class Coord4D extends BlockPos
|
||||
) && !(obj instanceof Coord4D && ((Coord4D)obj).dimensionId != dimensionId);
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
@@ -430,5 +423,4 @@ public class Coord4D extends BlockPos
|
||||
code = 31 * code + dimensionId;
|
||||
return code;
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -66,7 +66,7 @@ import mekanism.client.gui.GuiTransporterConfig;
|
||||
import mekanism.client.gui.GuiUpgradeManagement;
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.client.render.RenderTickHandler;
|
||||
import mekanism.client.render.ctm.TextureStitcher;
|
||||
import mekanism.client.render.ctm.CTMRegistry;
|
||||
import mekanism.client.render.entity.RenderBalloon;
|
||||
import mekanism.client.render.entity.RenderFlame;
|
||||
import mekanism.client.render.entity.RenderObsidianTNTPrimed;
|
||||
@@ -648,7 +648,7 @@ public class ClientProxy extends CommonProxy
|
||||
{
|
||||
MekanismRenderer.init();
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new TextureStitcher());
|
||||
MinecraftForge.EVENT_BUS.register(new CTMRegistry());
|
||||
|
||||
//Register entity rendering handlers
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityObsidianTNT.class, new IRenderFactory<EntityObsidianTNT>() {
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
package mekanism.client.render.ctm;
|
||||
|
||||
import static mekanism.client.render.ctm.Dir.BOTTOM;
|
||||
import static mekanism.client.render.ctm.Dir.BOTTOM_LEFT;
|
||||
import static mekanism.client.render.ctm.Dir.BOTTOM_RIGHT;
|
||||
import static mekanism.client.render.ctm.Dir.LEFT;
|
||||
import static mekanism.client.render.ctm.Dir.RIGHT;
|
||||
import static mekanism.client.render.ctm.Dir.TOP;
|
||||
import static mekanism.client.render.ctm.Dir.TOP_LEFT;
|
||||
import static mekanism.client.render.ctm.Dir.TOP_RIGHT;
|
||||
import gnu.trove.map.TIntObjectMap;
|
||||
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||
|
||||
@@ -8,13 +16,12 @@ import java.util.EnumMap;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import static mekanism.client.render.ctm.Dir.*;
|
||||
|
||||
// @formatter:off
|
||||
/**
|
||||
* The CTM renderer will draw the block's FACE using by assembling 4 quadrants from the 5 available block
|
||||
@@ -254,26 +261,30 @@ public class CTM {
|
||||
* The state to check against for connection.
|
||||
* @return True if the given block can connect to the given location on the given side.
|
||||
*/
|
||||
public boolean isConnected(IBlockAccess world, BlockPos current, BlockPos connection, EnumFacing dir, IBlockState state) {
|
||||
|
||||
// if (CTMLib.chiselLoaded() && connectionBlocked(world, x, y, z, dir.ordinal())) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
public boolean isConnected(IBlockAccess world, BlockPos current, BlockPos connection, EnumFacing dir, IBlockState state)
|
||||
{
|
||||
BlockPos pos2 = connection.add(dir.getDirectionVec());
|
||||
|
||||
boolean disableObscured = disableObscuredFaceCheck.or(disableObscuredFaceCheckConfig);
|
||||
|
||||
IBlockState con = getBlockOrFacade(world, connection, dir);
|
||||
IBlockState obscuring = disableObscured ? null : getBlockOrFacade(world, pos2, dir);
|
||||
|
||||
CTMData data = ((ICTMBlock)state.getBlock()).getCTMData(state);
|
||||
|
||||
// no block or a bad API user
|
||||
if (con == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO VERY TEMPORARY
|
||||
boolean ret = con.getBlock() == state.getBlock();
|
||||
boolean ret = false;
|
||||
|
||||
if(con.getBlock() instanceof ICTMBlock)
|
||||
{
|
||||
String state2 = ((IStringSerializable)con.getValue(((ICTMBlock)con.getBlock()).getTypeProperty())).getName();
|
||||
|
||||
ret = data.acceptableBlockStates.contains(state2);
|
||||
}
|
||||
|
||||
// no block obscuring this face
|
||||
if (obscuring == null) {
|
||||
@@ -286,14 +297,6 @@ public class CTM {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// private boolean connectionBlocked(IBlockAccess world, int x, int y, int z, int side) {
|
||||
// Block block = world.getBlock(x, y, z);
|
||||
// if (block instanceof IConnectable) {
|
||||
// return !((IConnectable) block).canConnectCTM(world, x, y, z, side);
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
public IBlockState getBlockOrFacade(IBlockAccess world, BlockPos pos, EnumFacing side) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
return state;
|
||||
|
||||
@@ -6,23 +6,27 @@ import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class CTMBlockRenderContext {
|
||||
|
||||
public class CTMBlockRenderContext
|
||||
{
|
||||
private EnumMap<EnumFacing, CTM> ctmData = new EnumMap<>(EnumFacing.class);
|
||||
|
||||
public CTMBlockRenderContext(IBlockAccess world, BlockPos pos) {
|
||||
for (EnumFacing face : EnumFacing.VALUES) {
|
||||
public CTMBlockRenderContext(IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
for(EnumFacing face : EnumFacing.VALUES)
|
||||
{
|
||||
CTM ctm = createCTM();
|
||||
ctm.createSubmapIndices(world, pos, face);
|
||||
ctmData.put(face, ctm);
|
||||
}
|
||||
}
|
||||
|
||||
protected CTM createCTM() {
|
||||
protected CTM createCTM()
|
||||
{
|
||||
return CTM.getInstance();
|
||||
}
|
||||
|
||||
public CTM getCTM(EnumFacing face) {
|
||||
public CTM getCTM(EnumFacing face)
|
||||
{
|
||||
return ctmData.get(face);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package mekanism.client.render.ctm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CTMData
|
||||
{
|
||||
public List<String> acceptableBlockStates = new ArrayList<String>();
|
||||
|
||||
public boolean renderConvexConnections = false;
|
||||
|
||||
public String facingOverride;
|
||||
|
||||
public CTMData(IStringSerializable... states)
|
||||
{
|
||||
for(IStringSerializable state : states)
|
||||
{
|
||||
acceptableBlockStates.add(state.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public CTMData setRenderConvexConnections()
|
||||
{
|
||||
renderConvexConnections = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CTMData setFacingOverride(String s)
|
||||
{
|
||||
facingOverride= s;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean hasFacingOverride()
|
||||
{
|
||||
return facingOverride != null;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldRenderSide(IBlockAccess world, BlockPos pos, EnumFacing side)
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
|
||||
if(state.getBlock() instanceof ICTMBlock)
|
||||
{
|
||||
IStringSerializable serializable = (IStringSerializable)state.getValue(((ICTMBlock)state.getBlock()).getTypeProperty());
|
||||
return acceptableBlockStates.contains(serializable.getName());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -19,18 +19,22 @@ import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.TRSRTransformation;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class TextureStitcher {
|
||||
|
||||
public class CTMRegistry
|
||||
{
|
||||
private static List<TextureSpriteCallback> textures = new ArrayList<TextureSpriteCallback>();
|
||||
|
||||
private IBakedModel baseModel;
|
||||
public static ResourceLocation baseResource = new ResourceLocation("mekanism:block/ctm_block");
|
||||
|
||||
public static String[] ctmTypes = new String[] {"dynamic_tank"};
|
||||
public static String[] ctmTypes = new String[] {"dynamic_tank", "structural_glass", "dynamic_valve", "teleporter", "teleporter_frame", "induction_casing", "induction_port_input", "induction_port_output",
|
||||
"induction_cell_basic", "induction_cell_advanced", "induction_cell_elite", "induction_cell_ultimate", "induction_provider_basic", "induction_provider_advanced", "induction_provider_elite",
|
||||
"induction_provider_ultimate", "thermal_evaporation_controller", "thermal_evaporation_controller_on", "thermal_evaporation_valve", "superheating_element", "superheating_element_on", "reactor_port",
|
||||
"reactor_neutron_capture", "reactor_logic_adapter", "reactor_laser_focus", "reactor_glass", "reactor_frame", "reactor_controller_on", "reactor_controller_off", "boiler_casing", "boiler_valve",
|
||||
"electromagnetic_coil", "thermal_evaporation_valve", "thermal_evaporation_block", "turbine_casing", "turbine_vent", "turbine_valve"};
|
||||
|
||||
public static Map<String, ChiselTextureCTM> textureCache = new HashMap<String, ChiselTextureCTM>();
|
||||
|
||||
public TextureStitcher()
|
||||
public CTMRegistry()
|
||||
{
|
||||
if(textureCache.isEmpty())
|
||||
{
|
||||
@@ -42,8 +46,10 @@ public class TextureStitcher {
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTextureStitch(TextureStitchEvent.Pre event) {
|
||||
for (TextureSpriteCallback callback : textures) {
|
||||
public void onTextureStitch(TextureStitchEvent.Pre event)
|
||||
{
|
||||
for(TextureSpriteCallback callback : textures)
|
||||
{
|
||||
callback.stitch(event.map);
|
||||
}
|
||||
}
|
||||
@@ -54,7 +60,7 @@ public class TextureStitcher {
|
||||
IModel model = event.modelLoader.getModel(baseResource);
|
||||
baseModel = model.bake(new TRSRTransformation(ModelRotation.X0_Y0), Attributes.DEFAULT_BAKED_FORMAT, r -> Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(r.toString()));
|
||||
|
||||
for (String ctm : ctmTypes)
|
||||
for(String ctm : ctmTypes)
|
||||
{
|
||||
ModelChisel chiselModel = new ModelChisel(baseModel, ctm);
|
||||
chiselModel.load();
|
||||
@@ -79,14 +85,4 @@ public class TextureStitcher {
|
||||
|
||||
return new ChiselTextureCTM(EnumWorldBlockLayer.SOLID, callbacks);
|
||||
}
|
||||
|
||||
public static ChiselFace createFace(String name)
|
||||
{
|
||||
ChiselFace face = new ChiselFace();
|
||||
|
||||
face.addTexture(textureCache.get(name));
|
||||
face.setLayer(EnumWorldBlockLayer.SOLID);
|
||||
|
||||
return face;
|
||||
}
|
||||
}
|
||||
@@ -7,28 +7,30 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class ChiselTextureCTM {
|
||||
|
||||
@Getter
|
||||
public class ChiselTextureCTM
|
||||
{
|
||||
protected EnumWorldBlockLayer layer;
|
||||
|
||||
protected TextureSpriteCallback[] sprites;
|
||||
public TextureSpriteCallback[] sprites;
|
||||
|
||||
public ChiselTextureCTM(EnumWorldBlockLayer layer, TextureSpriteCallback[] sprites) {
|
||||
public ChiselTextureCTM(EnumWorldBlockLayer layer, TextureSpriteCallback[] sprites)
|
||||
{
|
||||
this.layer = layer;
|
||||
this.sprites = sprites;
|
||||
}
|
||||
|
||||
public List<BakedQuad> transformQuad(BakedQuad bq, CTMBlockRenderContext context, int quadGoal) {
|
||||
public List<BakedQuad> transformQuad(BakedQuad bq, CTMBlockRenderContext context, int quadGoal)
|
||||
{
|
||||
Quad quad = Quad.from(bq, DefaultVertexFormats.ITEM);
|
||||
if (context == null) {
|
||||
|
||||
if(context == null)
|
||||
{
|
||||
return Collections.singletonList(quad.transformUVs(sprites[0].getSprite()).rebake());
|
||||
}
|
||||
|
||||
@@ -36,21 +38,27 @@ public class ChiselTextureCTM {
|
||||
|
||||
int[] ctm = ((CTMBlockRenderContext)context).getCTM(bq.getFace()).getSubmapIndices();
|
||||
|
||||
for (int i = 0; i < quads.length; i++) {
|
||||
for(int i = 0; i < quads.length; i++)
|
||||
{
|
||||
Quad q = quads[i];
|
||||
if (q != null) {
|
||||
int ctmid = q.getUvs().normalize().getQuadrant();
|
||||
|
||||
if(q != null)
|
||||
{
|
||||
int ctmid = q.getUVs().normalize().getQuadrant();
|
||||
quads[i] = q.grow().transformUVs(sprites[ctm[ctmid] > 15 ? 0 : 1].getSprite(), CTM.uvs[ctm[ctmid]].normalize());
|
||||
}
|
||||
}
|
||||
|
||||
return Arrays.stream(quads).filter(Objects::nonNull).map(q -> q.rebake()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public TextureAtlasSprite getParticle(){
|
||||
public TextureAtlasSprite getParticle()
|
||||
{
|
||||
return sprites[0].getSprite();
|
||||
}
|
||||
|
||||
public Collection<ResourceLocation> getTextures() {
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
{
|
||||
return Arrays.stream(sprites).map(TextureSpriteCallback::getLocation).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,14 @@
|
||||
package mekanism.client.render.ctm;
|
||||
|
||||
public interface ICTMBlock {
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public interface ICTMBlock<T extends Enum & IStringSerializable>
|
||||
{
|
||||
public CTMData getCTMData(IBlockState state);
|
||||
|
||||
public PropertyEnum<? extends T> getTypeProperty();
|
||||
|
||||
public String getOverrideTexture(IBlockState state);
|
||||
}
|
||||
@@ -7,8 +7,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.statemap.DefaultStateMapper;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.resources.model.IBakedModel;
|
||||
@@ -24,20 +22,15 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
|
||||
public class ModelChisel implements IModel {
|
||||
|
||||
private static StateMapperBase mapper = new DefaultStateMapper();
|
||||
|
||||
public class ModelChisel implements IModel
|
||||
{
|
||||
private Map<EnumFacing, String> overrides = Maps.newHashMap();
|
||||
|
||||
private transient ChiselFace faceObj;
|
||||
private transient Map<EnumFacing, ChiselFace> overridesObj = new EnumMap<>(EnumFacing.class);
|
||||
private transient ChiselTextureCTM faceObj;
|
||||
private transient Map<EnumFacing, ChiselTextureCTM> overridesObj = new EnumMap<>(EnumFacing.class);
|
||||
|
||||
private transient IBakedModel modelObj;
|
||||
|
||||
private transient Map<IBlockState, IBakedModel> stateMap = Maps.newHashMap();
|
||||
|
||||
private transient List<ResourceLocation> textures = Lists.newArrayList();
|
||||
|
||||
public String modelName;
|
||||
@@ -49,44 +42,53 @@ public class ModelChisel implements IModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies() {
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return new ArrayList<ResourceLocation>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures() {
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
{
|
||||
return ImmutableList.copyOf(textures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
|
||||
public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelState getDefaultState() {
|
||||
public IModelState getDefaultState()
|
||||
{
|
||||
return TRSRTransformation.identity();
|
||||
}
|
||||
|
||||
void load() {
|
||||
if (faceObj != null) {
|
||||
void load()
|
||||
{
|
||||
if(faceObj != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
System.out.println("LOADING MODEL");
|
||||
faceObj = TextureStitcher.createFace(modelName);
|
||||
faceObj.getTextureList().forEach(t -> textures.addAll(t.getTextures()));
|
||||
overridesObj.values().forEach(f -> f.getTextureList().forEach(t -> textures.addAll(t.getTextures())));
|
||||
|
||||
faceObj = CTMRegistry.textureCache.get(modelName);
|
||||
textures.addAll(faceObj.getTextures());
|
||||
overridesObj.values().forEach(t -> textures.addAll(t.getTextures()));
|
||||
}
|
||||
|
||||
public ChiselFace getDefaultFace() {
|
||||
public ChiselTextureCTM getDefaultFace()
|
||||
{
|
||||
return faceObj;
|
||||
}
|
||||
|
||||
public ChiselFace getFace(EnumFacing facing) {
|
||||
public ChiselTextureCTM getFace(EnumFacing facing)
|
||||
{
|
||||
return overridesObj.getOrDefault(facing, faceObj);
|
||||
}
|
||||
|
||||
public IBakedModel getModel(IBlockState state) {
|
||||
public IBakedModel getModel(IBlockState state)
|
||||
{
|
||||
return modelObj;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
import mekanism.common.block.BlockBasic;
|
||||
import mekanism.common.block.states.BlockStateFacing;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
@@ -32,14 +33,13 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Ordering;
|
||||
|
||||
/**
|
||||
* Model for all chisel blocks
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ModelChiselBlock implements ISmartBlockModel, ISmartItemModel, IPerspectiveAwareModel {
|
||||
|
||||
public class ModelChiselBlock implements ISmartBlockModel, ISmartItemModel, IPerspectiveAwareModel
|
||||
{
|
||||
public static final TRSRTransformation DEFAULT_BLOCK_THIRD_PERSON_TRANSOFRM = new TRSRTransformation(new Vector3f(0, 1.5f / 16f, -2.75f / 16f), TRSRTransformation.quatFromYXZDegrees(new Vector3f(10, -45, 170)), new Vector3f(0.375f, 0.375f, 0.375f), null);
|
||||
public static final Matrix4f DEFAULT_BLOCK_THIRD_PERSON_MATRIX = DEFAULT_BLOCK_THIRD_PERSON_TRANSOFRM.getMatrix();
|
||||
|
||||
@@ -48,107 +48,144 @@ public class ModelChiselBlock implements ISmartBlockModel, ISmartItemModel, IPer
|
||||
|
||||
private ModelChisel model;
|
||||
|
||||
public ModelChiselBlock(List<BakedQuad> face, List<BakedQuad> general, ModelChisel model){
|
||||
public ModelChiselBlock(List<BakedQuad> face, List<BakedQuad> general, ModelChisel model)
|
||||
{
|
||||
this.face = face;
|
||||
this.general = general;
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public ModelChiselBlock(ModelChisel model){
|
||||
public ModelChiselBlock(ModelChisel model)
|
||||
{
|
||||
this(Collections.emptyList(), Collections.emptyList(), model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getFaceQuads(EnumFacing facing){
|
||||
public List<BakedQuad> getFaceQuads(EnumFacing facing)
|
||||
{
|
||||
return FluentIterable.from(face).filter(quad -> quad.getFace() == facing).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getGeneralQuads() {
|
||||
public List<BakedQuad> getGeneralQuads()
|
||||
{
|
||||
return general;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion(){
|
||||
public boolean isAmbientOcclusion()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d(){
|
||||
public boolean isGui3d()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer(){
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture() {
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
{
|
||||
return this.model.getDefaultFace().getParticle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms(){
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
{
|
||||
return ItemCameraTransforms.DEFAULT;
|
||||
}
|
||||
|
||||
// TODO implement model caching, returning a new model every time is a HUGE waste of memory and CPU
|
||||
|
||||
@Override
|
||||
public IBakedModel handleBlockState(IBlockState stateIn) {
|
||||
if (stateIn.getBlock() instanceof ICTMBlock && stateIn instanceof IExtendedBlockState) {
|
||||
public IBakedModel handleBlockState(IBlockState stateIn)
|
||||
{
|
||||
if(stateIn.getBlock() instanceof ICTMBlock && stateIn instanceof IExtendedBlockState)
|
||||
{
|
||||
IExtendedBlockState state = (IExtendedBlockState) stateIn;
|
||||
CTMBlockRenderContext ctxList = state.getValue(BlockBasic.ctmProperty);
|
||||
return createModel(stateIn, model, ctxList);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handleItemState(ItemStack stack) {
|
||||
public IBakedModel handleItemState(ItemStack stack)
|
||||
{
|
||||
Block block = ((ItemBlock) stack.getItem()).getBlock();
|
||||
return createModel(block.getDefaultState(), model, null);
|
||||
}
|
||||
|
||||
private ModelChiselBlock createModel(IBlockState state, ModelChisel model, CTMBlockRenderContext ctx) {
|
||||
private ModelChiselBlock createModel(IBlockState state, ModelChisel model, CTMBlockRenderContext ctx)
|
||||
{
|
||||
List<BakedQuad> faceQuads = Lists.newArrayList();
|
||||
List<BakedQuad> generalQuads = Lists.newArrayList();
|
||||
for (EnumFacing facing : EnumFacing.VALUES){
|
||||
ChiselFace face = model.getFace(facing);
|
||||
|
||||
for(EnumFacing facing : EnumFacing.VALUES)
|
||||
{
|
||||
ChiselTextureCTM face = model.getFace(facing);
|
||||
ICTMBlock block = (ICTMBlock)state.getBlock();
|
||||
CTMData data = block.getCTMData(state);
|
||||
|
||||
if(block.getOverrideTexture(state) != null)
|
||||
{
|
||||
face = CTMRegistry.textureCache.get(block.getOverrideTexture(state));
|
||||
}
|
||||
|
||||
int quadGoal = ctx == null ? 1 : Ordering.natural().max(FluentIterable.from(face.getTextureList()).transform(tex -> CTM.QUADS_PER_SIDE));
|
||||
int quadGoal = ctx == null ? 1 : CTM.QUADS_PER_SIDE;
|
||||
IBakedModel baked = model.getModel(state);
|
||||
List<BakedQuad> origFaceQuads = baked.getFaceQuads(facing);
|
||||
List<BakedQuad> origGeneralQuads = FluentIterable.from(baked.getGeneralQuads()).filter(q -> q.getFace() == facing).toList();
|
||||
addAllQuads(origFaceQuads, face, ctx, quadGoal, faceQuads);
|
||||
addAllQuads(origGeneralQuads, face, ctx, quadGoal, generalQuads);
|
||||
addAllQuads(origFaceQuads, face, ctx, state, quadGoal, faceQuads);
|
||||
addAllQuads(origGeneralQuads, face, ctx, state, quadGoal, generalQuads);
|
||||
}
|
||||
|
||||
return new ModelChiselBlock(faceQuads, generalQuads, model);
|
||||
}
|
||||
|
||||
private void addAllQuads(List<BakedQuad> from, ChiselFace face, @Nullable CTMBlockRenderContext ctx, int quadGoal, List<BakedQuad> to) {
|
||||
for (BakedQuad q : from) {
|
||||
for (ChiselTextureCTM tex : face.getTextureList()) {
|
||||
to.addAll(tex.transformQuad(q, ctx == null ? null : ctx, quadGoal));
|
||||
private void addAllQuads(List<BakedQuad> from, ChiselTextureCTM tex, @Nullable CTMBlockRenderContext ctx, IBlockState state, int quadGoal, List<BakedQuad> to)
|
||||
{
|
||||
for(BakedQuad q : from)
|
||||
{
|
||||
ChiselTextureCTM toUse = tex;
|
||||
CTMData data = ((ICTMBlock)state.getBlock()).getCTMData(state);
|
||||
|
||||
if(data.hasFacingOverride() && q.getFace() == state.getValue(BlockStateFacing.facingProperty))
|
||||
{
|
||||
toUse = CTMRegistry.textureCache.get(data.facingOverride);
|
||||
}
|
||||
|
||||
to.addAll(toUse.transformQuad(q, ctx == null ? null : ctx, quadGoal));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VertexFormat getFormat() {
|
||||
public VertexFormat getFormat()
|
||||
{
|
||||
return Attributes.DEFAULT_BAKED_FORMAT;
|
||||
}
|
||||
|
||||
private Pair<IPerspectiveAwareModel, Matrix4f> thirdPersonTransform;
|
||||
|
||||
@Override
|
||||
public Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) {
|
||||
if (cameraTransformType == TransformType.THIRD_PERSON) {
|
||||
if (thirdPersonTransform == null) {
|
||||
public Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType)
|
||||
{
|
||||
if(cameraTransformType == TransformType.THIRD_PERSON)
|
||||
{
|
||||
if(thirdPersonTransform == null)
|
||||
{
|
||||
thirdPersonTransform = ImmutablePair.of(this, DEFAULT_BLOCK_THIRD_PERSON_MATRIX);
|
||||
}
|
||||
|
||||
return thirdPersonTransform;
|
||||
}
|
||||
return Pair.of(this, null);
|
||||
|
||||
@@ -5,25 +5,29 @@ import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
/**
|
||||
* Block Property for the render context list
|
||||
*/
|
||||
public class PropertyCTMRenderContext implements IUnlistedProperty<CTMBlockRenderContext> {
|
||||
|
||||
public class PropertyCTMRenderContext implements IUnlistedProperty<CTMBlockRenderContext>
|
||||
{
|
||||
@Override
|
||||
public String getName(){
|
||||
public String getName()
|
||||
{
|
||||
return "connections";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(CTMBlockRenderContext value){
|
||||
public boolean isValid(CTMBlockRenderContext value)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<CTMBlockRenderContext> getType(){
|
||||
public Class<CTMBlockRenderContext> getType()
|
||||
{
|
||||
return CTMBlockRenderContext.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String valueToString(CTMBlockRenderContext value){
|
||||
public String valueToString(CTMBlockRenderContext value)
|
||||
{
|
||||
return value.toString();
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,6 @@ import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.Value;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
@@ -29,34 +24,31 @@ import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.MultimapBuilder;
|
||||
|
||||
@ToString(of = { "vertPos", "vertUv" })
|
||||
public class Quad {
|
||||
|
||||
public class Quad
|
||||
{
|
||||
public static final ISubmap TOP_LEFT = new Submap(8, 8, 0, 0);
|
||||
public static final ISubmap TOP_RIGHT = new Submap(8, 8, 8, 0);
|
||||
public static final ISubmap BOTTOM_LEFT = new Submap(8, 8, 0, 8);
|
||||
public static final ISubmap BOTTOM_RIGHT = new Submap(8, 8, 8, 8);
|
||||
|
||||
@Value
|
||||
public static class Vertex {
|
||||
public static class Vertex
|
||||
{
|
||||
Vector3f pos;
|
||||
Vector2f uvs;
|
||||
}
|
||||
|
||||
private static final TextureAtlasSprite BASE = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(TextureMap.LOCATION_MISSING_TEXTURE.toString());
|
||||
|
||||
@ToString
|
||||
public class UVs {
|
||||
|
||||
@Getter
|
||||
public class UVs
|
||||
{
|
||||
private float minU, minV, maxU, maxV;
|
||||
|
||||
@Getter
|
||||
private final TextureAtlasSprite sprite;
|
||||
|
||||
private final Vector2f[] data;
|
||||
|
||||
private UVs(Vector2f... data) {
|
||||
private UVs(Vector2f... data)
|
||||
{
|
||||
this(BASE, data);
|
||||
}
|
||||
|
||||
@@ -134,6 +126,11 @@ public class Quad {
|
||||
public UVs relativize() {
|
||||
return relativize(sprite);
|
||||
}
|
||||
|
||||
public TextureAtlasSprite getSprite()
|
||||
{
|
||||
return sprite;
|
||||
}
|
||||
|
||||
public UVs relativize(TextureAtlasSprite sprite) {
|
||||
Vector2f min = new Vector2f(sprite.getMinU(), sprite.getMinV());
|
||||
@@ -190,8 +187,7 @@ public class Quad {
|
||||
private final Vector2f[] vertUv;
|
||||
|
||||
// Technically nonfinal, but treated as such except in constructor
|
||||
@Getter
|
||||
private UVs uvs;
|
||||
private UVs uvsObj;
|
||||
|
||||
private final Builder builder;
|
||||
|
||||
@@ -199,16 +195,17 @@ public class Quad {
|
||||
this.vertPos = verts;
|
||||
this.vertUv = uvs;
|
||||
this.builder = builder;
|
||||
this.uvs = new UVs(uvs);
|
||||
this.uvsObj = new UVs(uvs);
|
||||
}
|
||||
|
||||
private Quad(Vector3f[] verts, UVs uvs, Builder builder) {
|
||||
this(verts, uvs.vectorize(), builder);
|
||||
this.uvs = new UVs(uvs.getSprite(), vertUv);
|
||||
this.uvsObj = new UVs(uvs.getSprite(), vertUv);
|
||||
}
|
||||
|
||||
public void compute() {
|
||||
|
||||
|
||||
public UVs getUVs()
|
||||
{
|
||||
return uvsObj;
|
||||
}
|
||||
|
||||
public Quad[] subdivide(int count) {
|
||||
@@ -235,7 +232,7 @@ public class Quad {
|
||||
@Nullable
|
||||
private Pair<Quad, Quad> divide(boolean vertical) {
|
||||
float min, max;
|
||||
UVs uvs = getUvs().normalize();
|
||||
UVs uvs = uvsObj.normalize();
|
||||
if (vertical) {
|
||||
min = uvs.minV;
|
||||
max = uvs.maxV;
|
||||
@@ -249,7 +246,7 @@ public class Quad {
|
||||
|
||||
int firstIndex = 0;
|
||||
for (int i = 0; i < vertUv.length; i++) {
|
||||
if (vertUv[i].y == getUvs().minV && vertUv[i].x == getUvs().minU) {
|
||||
if (vertUv[i].y == uvsObj.minV && vertUv[i].x == uvsObj.minU) {
|
||||
firstIndex = i;
|
||||
break;
|
||||
}
|
||||
@@ -305,7 +302,7 @@ public class Quad {
|
||||
public Quad rotate(int amount) {
|
||||
Vector2f[] uvs = new Vector2f[4];
|
||||
|
||||
TextureAtlasSprite s = getUvs().getSprite();
|
||||
TextureAtlasSprite s = uvsObj.getSprite();
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
Vector2f normalized = new Vector2f(normalize(s.getMinU(), s.getMaxU(), vertUv[i].x), normalize(s.getMinV(), s.getMaxV(), vertUv[i].y));
|
||||
@@ -332,14 +329,14 @@ public class Quad {
|
||||
}
|
||||
|
||||
Quad ret = new Quad(vertPos, uvs, builder);
|
||||
ret.uvs = new UVs(getUvs().getSprite(), ret.vertUv);
|
||||
ret.uvsObj = new UVs(uvsObj.getSprite(), ret.vertUv);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Quad derotate() {
|
||||
int start = 0;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (vertUv[i].x <= getUvs().minU && vertUv[i].y <= getUvs().minV) {
|
||||
if (vertUv[i].x <= uvsObj.minU && vertUv[i].y <= uvsObj.minV) {
|
||||
start = i;
|
||||
break;
|
||||
}
|
||||
@@ -383,11 +380,11 @@ public class Quad {
|
||||
}
|
||||
|
||||
public Quad transformUVs(TextureAtlasSprite sprite, ISubmap submap) {
|
||||
return new Quad(vertPos, getUvs().transform(sprite, submap), builder);
|
||||
return new Quad(vertPos, uvsObj.transform(sprite, submap), builder);
|
||||
}
|
||||
|
||||
public Quad grow() {
|
||||
return new Quad(vertPos, getUvs().normalizeQuadrant(), builder);
|
||||
return new Quad(vertPos, uvsObj.normalizeQuadrant(), builder);
|
||||
}
|
||||
|
||||
public static Quad from(BakedQuad baked, VertexFormat fmt) {
|
||||
@@ -396,17 +393,36 @@ public class Quad {
|
||||
return b.build().derotate(); // for now we will ignore rotated UVs
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public static class Builder implements IVertexConsumer {
|
||||
|
||||
@Getter
|
||||
public static class Builder implements IVertexConsumer
|
||||
{
|
||||
public Builder(VertexFormat fmt)
|
||||
{
|
||||
vertexFormat = fmt;
|
||||
}
|
||||
|
||||
private final VertexFormat vertexFormat;
|
||||
|
||||
@Setter
|
||||
private int quadTint;
|
||||
|
||||
@Setter
|
||||
private EnumFacing quadOrientation;
|
||||
|
||||
@Override
|
||||
public void setQuadTint(int tint)
|
||||
{
|
||||
quadTint = tint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQuadOrientation(EnumFacing orientation)
|
||||
{
|
||||
quadOrientation = orientation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VertexFormat getVertexFormat()
|
||||
{
|
||||
return vertexFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQuadColored() {}
|
||||
|
||||
@@ -1,18 +1,45 @@
|
||||
package mekanism.client.render.ctm;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class Submap implements ISubmap {
|
||||
|
||||
public class Submap implements ISubmap
|
||||
{
|
||||
private final float width, height;
|
||||
private final float xOffset, yOffset;
|
||||
|
||||
private final SubmapNormalized normalized = new SubmapNormalized(this);
|
||||
|
||||
public Submap(float w, float h, float x, float y)
|
||||
{
|
||||
width = w;
|
||||
height = h;
|
||||
xOffset = x;
|
||||
yOffset = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getXOffset()
|
||||
{
|
||||
return xOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getYOffset()
|
||||
{
|
||||
return yOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWidth()
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHeight()
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getInterpolatedU(TextureAtlasSprite sprite, float u) {
|
||||
@@ -41,10 +68,14 @@ public class Submap implements ISubmap {
|
||||
|
||||
private static final float FACTOR = 16f;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
private static class SubmapNormalized implements ISubmap {
|
||||
|
||||
private static class SubmapNormalized implements ISubmap
|
||||
{
|
||||
private final ISubmap parent;
|
||||
|
||||
public SubmapNormalized(ISubmap submap)
|
||||
{
|
||||
parent = submap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getXOffset() {
|
||||
|
||||
@@ -9,16 +9,18 @@ import net.minecraft.util.ResourceLocation;
|
||||
* Callback when textures are stitched
|
||||
*/
|
||||
@Getter
|
||||
public class TextureSpriteCallback {
|
||||
|
||||
public class TextureSpriteCallback
|
||||
{
|
||||
private ResourceLocation location;
|
||||
private TextureAtlasSprite sprite;
|
||||
|
||||
public TextureSpriteCallback(ResourceLocation loc) {
|
||||
this.location = loc;
|
||||
public TextureSpriteCallback(ResourceLocation loc)
|
||||
{
|
||||
location = loc;
|
||||
}
|
||||
|
||||
public void stitch(TextureMap map) {
|
||||
this.sprite = map.registerSprite(location);
|
||||
public void stitch(TextureMap map)
|
||||
{
|
||||
sprite = map.registerSprite(location);
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,6 @@ public class CommonProxy implements IGuiProvider
|
||||
GameRegistry.registerTileEntity(TileEntityEliteFactory.class, "UltimateSmeltingFactory");
|
||||
GameRegistry.registerTileEntity(TileEntityPurificationChamber.class, "PurificationChamber");
|
||||
GameRegistry.registerTileEntity(TileEntityEnergizedSmelter.class, "EnergizedSmelter");
|
||||
//GameRegistry.registerTileEntity(TileEntityMetallurgicInfuser.class, "MetallurgicInfuser");
|
||||
GameRegistry.registerTileEntity(TileEntityGasTank.class, "GasTank");
|
||||
GameRegistry.registerTileEntity(TileEntityEnergyCube.class, "EnergyCube");
|
||||
GameRegistry.registerTileEntity(TileEntityElectricPump.class, "ElectricPump");
|
||||
@@ -195,7 +194,6 @@ public class CommonProxy implements IGuiProvider
|
||||
GameRegistry.registerTileEntity(TileEntityPRC.class, "PressurizedReactionChamber");
|
||||
GameRegistry.registerTileEntity(TileEntityFluidTank.class, "PortableTank"); //TODO rename
|
||||
GameRegistry.registerTileEntity(TileEntityFluidicPlenisher.class, "FluidicPlenisher");
|
||||
//GameRegistry.registerTileEntity(TileEntityLaser.class, "Laser");
|
||||
GameRegistry.registerTileEntity(TileEntityLaserAmplifier.class, "LaserAmplifier");
|
||||
GameRegistry.registerTileEntity(TileEntityLaserTractorBeam.class, "LaserTractorBeam");
|
||||
GameRegistry.registerTileEntity(TileEntitySolarNeutronActivator.class, "SolarNeutronActivator");
|
||||
|
||||
@@ -228,7 +228,7 @@ public class MekanismBlocks
|
||||
}
|
||||
});
|
||||
|
||||
ItemMeshDefinition mesher = new ItemMeshDefinition() {
|
||||
ItemMeshDefinition machineMesher = new ItemMeshDefinition() {
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack)
|
||||
{
|
||||
@@ -251,8 +251,34 @@ public class MekanismBlocks
|
||||
}
|
||||
};
|
||||
|
||||
ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(MekanismBlocks.MachineBlock), mesher);
|
||||
ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(MekanismBlocks.MachineBlock2), mesher);
|
||||
ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(MekanismBlocks.MachineBlock3), mesher);
|
||||
ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(MekanismBlocks.MachineBlock), machineMesher);
|
||||
ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(MekanismBlocks.MachineBlock2), machineMesher);
|
||||
ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(MekanismBlocks.MachineBlock3), machineMesher);
|
||||
|
||||
ItemMeshDefinition basicMesher = new ItemMeshDefinition() {
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack)
|
||||
{
|
||||
MachineType type = MachineType.get(stack);
|
||||
|
||||
if(type != null)
|
||||
{
|
||||
String resource = "mekanism:" + type.getName();
|
||||
|
||||
if(type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY || type == MachineType.ELITE_FACTORY)
|
||||
{
|
||||
RecipeType recipe = RecipeType.values()[((ItemBlockMachine)stack.getItem()).getRecipeType(stack)];
|
||||
resource = "mekanism:" + type.getName() + "_" + recipe.getName();
|
||||
}
|
||||
|
||||
return ClientProxy.machineResources.get(resource);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
//ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(MekanismBlocks.BasicBlock), basicMesher);
|
||||
//ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(MekanismBlocks.BasicBlock2), basicMesher);
|
||||
}
|
||||
}
|
||||
@@ -71,10 +71,7 @@ import mekanism.common.network.PacketWalkieTalkieState;
|
||||
import mekanism.common.network.PacketWalkieTalkieState.WalkieTalkieStateMessage;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTSizeTracker;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
@@ -87,8 +84,6 @@ import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import scala.tools.nsc.Global.Run;
|
||||
|
||||
/**
|
||||
* Mekanism packet handler. As always, use packets sparingly!
|
||||
* @author AidanBrady
|
||||
@@ -161,6 +156,10 @@ public class PacketHandler
|
||||
{
|
||||
output.writeShort((Short)data);
|
||||
}
|
||||
else if(data instanceof Long)
|
||||
{
|
||||
output.writeLong((Long)data);
|
||||
}
|
||||
else if(data instanceof Boolean)
|
||||
{
|
||||
output.writeBoolean((Boolean)data);
|
||||
@@ -211,8 +210,7 @@ public class PacketHandler
|
||||
{
|
||||
encode(((ArrayList)data).toArray(), output);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
throw new RuntimeException("Un-encodable data passed to encode(): " + data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,11 @@ package mekanism.common.block;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.energy.IEnergizedItem;
|
||||
import mekanism.api.energy.IStrictEnergyStorage;
|
||||
import mekanism.client.render.ctm.CTMBlockRenderContext;
|
||||
import mekanism.client.render.ctm.CTMData;
|
||||
import mekanism.client.render.ctm.ICTMBlock;
|
||||
import mekanism.client.render.ctm.PropertyCTMRenderContext;
|
||||
import mekanism.common.Mekanism;
|
||||
@@ -17,6 +19,7 @@ import mekanism.common.block.states.BlockStateBasic;
|
||||
import mekanism.common.block.states.BlockStateBasic.BasicBlock;
|
||||
import mekanism.common.block.states.BlockStateBasic.BasicBlockType;
|
||||
import mekanism.common.block.states.BlockStateFacing;
|
||||
import mekanism.common.block.states.BlockStateMachine.MachineType;
|
||||
import mekanism.common.content.boiler.SynchronizedBoilerData;
|
||||
import mekanism.common.content.tank.TankUpdateProtocol;
|
||||
import mekanism.common.inventory.InventoryBin;
|
||||
@@ -27,6 +30,7 @@ import mekanism.common.tile.TileEntityBasicBlock;
|
||||
import mekanism.common.tile.TileEntityBin;
|
||||
import mekanism.common.tile.TileEntityDynamicTank;
|
||||
import mekanism.common.tile.TileEntityInductionCell;
|
||||
import mekanism.common.tile.TileEntityInductionPort;
|
||||
import mekanism.common.tile.TileEntityInductionProvider;
|
||||
import mekanism.common.tile.TileEntityMultiblock;
|
||||
import mekanism.common.tile.TileEntitySecurityDesk;
|
||||
@@ -99,12 +103,16 @@ public abstract class BlockBasic extends Block implements ICTMBlock//TODO? imple
|
||||
{
|
||||
public static final PropertyCTMRenderContext ctmProperty = new PropertyCTMRenderContext();
|
||||
|
||||
public CTMData[][] ctmData = new CTMData[16][4];
|
||||
|
||||
public BlockBasic()
|
||||
{
|
||||
super(Material.iron);
|
||||
setHardness(5F);
|
||||
setResistance(10F);
|
||||
setCreativeTab(Mekanism.tabMekanism);
|
||||
|
||||
initCTMs();
|
||||
}
|
||||
|
||||
public static BlockBasic getBlockBasic(BasicBlock block)
|
||||
@@ -120,6 +128,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock//TODO? imple
|
||||
|
||||
public abstract BasicBlock getBasicBlock();
|
||||
|
||||
@Override
|
||||
public BlockState createBlockState()
|
||||
{
|
||||
return new BlockStateBasic(this, getProperty());
|
||||
@@ -160,6 +169,34 @@ public abstract class BlockBasic extends Block implements ICTMBlock//TODO? imple
|
||||
state = state.withProperty(BlockStateBasic.activeProperty, ((IActiveState)tile).getActive());
|
||||
}
|
||||
|
||||
if(tile instanceof TileEntityInductionCell)
|
||||
{
|
||||
state = state.withProperty(BlockStateBasic.tierProperty, ((TileEntityInductionCell)tile).tier.getBaseTier());
|
||||
}
|
||||
|
||||
if(tile instanceof TileEntityInductionProvider)
|
||||
{
|
||||
state = state.withProperty(BlockStateBasic.tierProperty, ((TileEntityInductionProvider)tile).tier.getBaseTier());
|
||||
}
|
||||
|
||||
if(tile instanceof TileEntityInductionPort)
|
||||
{
|
||||
state = state.withProperty(BlockStateBasic.activeProperty, ((TileEntityInductionPort)tile).mode);
|
||||
}
|
||||
|
||||
if(tile instanceof TileEntitySuperheatingElement)
|
||||
{
|
||||
TileEntitySuperheatingElement element = (TileEntitySuperheatingElement)tile;
|
||||
boolean active = false;
|
||||
|
||||
if(element.multiblockUUID != null && SynchronizedBoilerData.clientHotMap.get(element.multiblockUUID) != null)
|
||||
{
|
||||
active = SynchronizedBoilerData.clientHotMap.get(element.multiblockUUID);
|
||||
}
|
||||
|
||||
state = state.withProperty(BlockStateBasic.activeProperty, active);
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -172,7 +209,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock//TODO? imple
|
||||
return stateIn;
|
||||
}
|
||||
|
||||
IExtendedBlockState state = (IExtendedBlockState) stateIn;
|
||||
IExtendedBlockState state = (IExtendedBlockState)stateIn;
|
||||
CTMBlockRenderContext ctx = new CTMBlockRenderContext(w, pos);
|
||||
|
||||
return state.withProperty(ctmProperty, ctx);
|
||||
@@ -208,7 +245,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock//TODO? imple
|
||||
|
||||
if(neighborBlock == this && tileEntity instanceof IMultiblock)
|
||||
{
|
||||
((IMultiblock)tileEntity).update();
|
||||
((IMultiblock)tileEntity).doUpdate();
|
||||
}
|
||||
|
||||
if(tileEntity instanceof TileEntityBasicBlock)
|
||||
@@ -218,96 +255,48 @@ public abstract class BlockBasic extends Block implements ICTMBlock//TODO? imple
|
||||
|
||||
if(tileEntity instanceof IStructuralMultiblock)
|
||||
{
|
||||
((IStructuralMultiblock)tileEntity).update();
|
||||
((IStructuralMultiblock)tileEntity).doUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister register)
|
||||
public void initCTMs()
|
||||
{
|
||||
switch(blockType)
|
||||
switch(getBasicBlock())
|
||||
{
|
||||
case BASIC_BLOCK_1:
|
||||
ctms[7][0] = new CTMData("ctm/TeleporterFrame", this, Arrays.asList(7)).addOtherBlockConnectivities(MekanismBlocks.MachineBlock, Arrays.asList(11)).registerIcons(register);
|
||||
ctms[9][0] = new CTMData("ctm/DynamicTank", this, Arrays.asList(9, 11)).registerIcons(register);
|
||||
ctms[10][0] = new CTMData("ctm/StructuralGlass", this, Arrays.asList(10)).registerIcons(register);
|
||||
ctms[11][0] = new CTMData("ctm/DynamicValve", this, Arrays.asList(11, 9)).registerIcons(register);
|
||||
ctmData[7][0] = new CTMData(BasicBlockType.TELEPORTER_FRAME, MachineType.TELEPORTER);
|
||||
ctmData[9][0] = new CTMData(BasicBlockType.DYNAMIC_TANK, BasicBlockType.DYNAMIC_VALVE);
|
||||
ctmData[10][0] = new CTMData(BasicBlockType.STRUCTURAL_GLASS);
|
||||
ctmData[11][0] = new CTMData(BasicBlockType.DYNAMIC_TANK, BasicBlockType.DYNAMIC_VALVE);
|
||||
|
||||
ctms[14][0] = new CTMData("ctm/ThermalEvaporationBlock", this, Arrays.asList(14, 15)).addOtherBlockConnectivities(MekanismBlocks.BasicBlock2, Arrays.asList(0)).addFacingOverride("ctm/ThermalEvaporationController").registerIcons(register);
|
||||
ctms[14][1] = new CTMData("ctm/ThermalEvaporationBlock", this, Arrays.asList(14, 15)).addOtherBlockConnectivities(MekanismBlocks.BasicBlock2, Arrays.asList(0)).addFacingOverride("ctm/ThermalEvaporationControllerOn").registerIcons(register);
|
||||
ctms[15][0] = new CTMData("ctm/ThermalEvaporationValve", this, Arrays.asList(15, 14)).addOtherBlockConnectivities(MekanismBlocks.BasicBlock2, Arrays.asList(0)).registerIcons(register);
|
||||
ctmData[14][0] = new CTMData(BasicBlockType.THERMAL_EVAPORATION_BLOCK, BasicBlockType.THERMAL_EVAPORATION_VALVE, BasicBlockType.THERMAL_EVAPORATION_CONTROLLER);
|
||||
ctmData[14][1] = new CTMData(BasicBlockType.THERMAL_EVAPORATION_BLOCK, BasicBlockType.THERMAL_EVAPORATION_VALVE, BasicBlockType.THERMAL_EVAPORATION_CONTROLLER);
|
||||
ctmData[15][0] = new CTMData(BasicBlockType.THERMAL_EVAPORATION_BLOCK, BasicBlockType.THERMAL_EVAPORATION_VALVE, BasicBlockType.THERMAL_EVAPORATION_CONTROLLER);
|
||||
|
||||
icons[0][0] = register.registerIcon("mekanism:OsmiumBlock");
|
||||
icons[1][0] = register.registerIcon("mekanism:BronzeBlock");
|
||||
icons[2][0] = register.registerIcon("mekanism:RefinedObsidian");
|
||||
icons[3][0] = register.registerIcon("mekanism:CoalBlock");
|
||||
icons[4][0] = register.registerIcon("mekanism:RefinedGlowstone");
|
||||
icons[5][0] = register.registerIcon("mekanism:SteelBlock");
|
||||
icons[6][0] = register.registerIcon(ICON_BASE);
|
||||
|
||||
MekanismRenderer.loadDynamicTextures(register, "bin/BinBasic", binIcons[0], new DefIcon(register.registerIcon("mekanism:bin/BinBasicTop"), 0), new DefIcon(register.registerIcon("mekanism:bin/BinBasicTopOn"), 6));
|
||||
MekanismRenderer.loadDynamicTextures(register, "bin/BinAdvanced", binIcons[1], new DefIcon(register.registerIcon("mekanism:bin/BinAdvancedTop"), 0), new DefIcon(register.registerIcon("mekanism:bin/BinAdvancedTopOn"), 6));
|
||||
MekanismRenderer.loadDynamicTextures(register, "bin/BinElite", binIcons[2], new DefIcon(register.registerIcon("mekanism:bin/BinEliteTop"), 0), new DefIcon(register.registerIcon("mekanism:bin/BinEliteTopOn"), 6));
|
||||
MekanismRenderer.loadDynamicTextures(register, "bin/BinUltimate", binIcons[3], new DefIcon(register.registerIcon("mekanism:bin/BinUltimateTop"), 0), new DefIcon(register.registerIcon("mekanism:bin/BinUltimateTopOn"), 6));
|
||||
|
||||
icons[7][0] = ctms[7][0].mainTextureData.icon;
|
||||
icons[8][0] = register.registerIcon("mekanism:SteelCasing");
|
||||
icons[9][0] = ctms[9][0].mainTextureData.icon;
|
||||
icons[10][0] = ctms[10][0].mainTextureData.icon;
|
||||
icons[11][0] = ctms[11][0].mainTextureData.icon;
|
||||
icons[12][0] = register.registerIcon("mekanism:CopperBlock");
|
||||
icons[13][0] = register.registerIcon("mekanism:TinBlock");
|
||||
icons[14][0] = ctms[14][0].facingOverride.icon;
|
||||
icons[14][1] = ctms[14][1].facingOverride.icon;
|
||||
icons[14][2] = ctms[14][0].mainTextureData.icon;
|
||||
icons[15][0] = ctms[15][0].mainTextureData.icon;
|
||||
break;
|
||||
case BASIC_BLOCK_2:
|
||||
ctms[0][0] = new CTMData("ctm/ThermalEvaporationBlock", this, Arrays.asList(0)).addOtherBlockConnectivities(MekanismBlocks.BasicBlock, Arrays.asList(14, 15)).registerIcons(register);
|
||||
ctms[1][0] = new CTMData("ctm/InductionCasing", this, Arrays.asList(1, 2)).registerIcons(register);
|
||||
ctms[2][0] = new CTMData("ctm/InductionPortInput", this, Arrays.asList(1, 2)).registerIcons(register);
|
||||
ctms[2][1] = new CTMData("ctm/InductionPortOutput", this, Arrays.asList(1, 2)).registerIcons(register);
|
||||
ctms[3][0] = new CTMData("ctm/InductionCellBasic", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections();
|
||||
ctms[3][1] = new CTMData("ctm/InductionCellAdvanced", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections();
|
||||
ctms[3][2] = new CTMData("ctm/InductionCellElite", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections();
|
||||
ctms[3][3] = new CTMData("ctm/InductionCellUltimate", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections();
|
||||
ctms[4][0] = new CTMData("ctm/InductionProviderBasic", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections();
|
||||
ctms[4][1] = new CTMData("ctm/InductionProviderAdvanced", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections();
|
||||
ctms[4][2] = new CTMData("ctm/InductionProviderElite", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections();
|
||||
ctms[4][3] = new CTMData("ctm/InductionProviderUltimate", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections();
|
||||
ctms[5][0] = new CTMData("ctm/SuperheatingElement", this, Arrays.asList(5)).registerIcons(register).setRenderConvexConnections();
|
||||
ctms[5][1] = new CTMData("ctm/SuperheatingElementOn", this, Arrays.asList(5)).registerIcons(register).setRenderConvexConnections();
|
||||
ctms[7][0] = new CTMData("ctm/BoilerCasing", this, Arrays.asList(7, 8)).registerIcons(register);
|
||||
ctms[8][0] = new CTMData("ctm/BoilerValve", this, Arrays.asList(7, 8)).registerIcons(register);
|
||||
|
||||
icons[6][0] = register.registerIcon("mekanism:PressureDisperser");
|
||||
|
||||
icons[0][0] = ctms[0][0].mainTextureData.icon;
|
||||
icons[1][0] = ctms[1][0].mainTextureData.icon;
|
||||
icons[2][0] = ctms[2][0].mainTextureData.icon;
|
||||
icons[2][1] = ctms[2][1].mainTextureData.icon;
|
||||
icons[3][0] = ctms[3][0].mainTextureData.icon;
|
||||
icons[3][1] = ctms[3][1].mainTextureData.icon;
|
||||
icons[3][2] = ctms[3][2].mainTextureData.icon;
|
||||
icons[3][3] = ctms[3][3].mainTextureData.icon;
|
||||
icons[4][0] = ctms[4][0].mainTextureData.icon;
|
||||
icons[4][1] = ctms[4][1].mainTextureData.icon;
|
||||
icons[4][2] = ctms[4][2].mainTextureData.icon;
|
||||
icons[4][3] = ctms[4][3].mainTextureData.icon;
|
||||
icons[5][0] = ctms[5][0].mainTextureData.icon;
|
||||
icons[5][1] = ctms[5][1].mainTextureData.icon;
|
||||
icons[7][0] = ctms[7][0].mainTextureData.icon;
|
||||
icons[8][0] = ctms[8][0].mainTextureData.icon;
|
||||
|
||||
icons[9][0] = register.registerIcon(ICON_BASE);
|
||||
|
||||
ctmData[0][0] = new CTMData(BasicBlockType.THERMAL_EVAPORATION_BLOCK, BasicBlockType.THERMAL_EVAPORATION_VALVE, BasicBlockType.THERMAL_EVAPORATION_CONTROLLER);
|
||||
ctmData[1][0] = new CTMData(BasicBlockType.INDUCTION_CASING, BasicBlockType.INDUCTION_PORT);
|
||||
ctmData[2][0] = new CTMData(BasicBlockType.INDUCTION_CASING, BasicBlockType.INDUCTION_PORT);
|
||||
ctmData[2][1] = new CTMData(BasicBlockType.INDUCTION_CASING, BasicBlockType.INDUCTION_PORT);
|
||||
ctmData[3][0] = new CTMData(BasicBlockType.INDUCTION_CELL, BasicBlockType.INDUCTION_PROVIDER).setRenderConvexConnections();
|
||||
ctmData[3][1] = new CTMData(BasicBlockType.INDUCTION_CELL, BasicBlockType.INDUCTION_PROVIDER).setRenderConvexConnections();
|
||||
ctmData[3][2] = new CTMData(BasicBlockType.INDUCTION_CELL, BasicBlockType.INDUCTION_PROVIDER).setRenderConvexConnections();
|
||||
ctmData[3][3] = new CTMData(BasicBlockType.INDUCTION_CELL, BasicBlockType.INDUCTION_PROVIDER).setRenderConvexConnections();
|
||||
ctmData[4][0] = new CTMData(BasicBlockType.INDUCTION_CELL, BasicBlockType.INDUCTION_PROVIDER).setRenderConvexConnections();
|
||||
ctmData[4][1] = new CTMData(BasicBlockType.INDUCTION_CELL, BasicBlockType.INDUCTION_PROVIDER).setRenderConvexConnections();
|
||||
ctmData[4][2] = new CTMData(BasicBlockType.INDUCTION_CELL, BasicBlockType.INDUCTION_PROVIDER).setRenderConvexConnections();
|
||||
ctmData[4][3] = new CTMData(BasicBlockType.INDUCTION_CELL, BasicBlockType.INDUCTION_PROVIDER).setRenderConvexConnections();
|
||||
ctmData[5][0] = new CTMData(BasicBlockType.SUPERHEATING_ELEMENT).setRenderConvexConnections();
|
||||
ctmData[5][1] = new CTMData(BasicBlockType.SUPERHEATING_ELEMENT).setRenderConvexConnections();
|
||||
ctmData[7][0] = new CTMData(BasicBlockType.BOILER_CASING, BasicBlockType.BOILER_VALVE);
|
||||
ctmData[8][0] = new CTMData(BasicBlockType.BOILER_CASING, BasicBlockType.BOILER_VALVE);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(IBlockAccess world, BlockPos pos, int side)
|
||||
@@ -884,7 +873,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock//TODO? imple
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return BasicBlockType.get(state).create();
|
||||
}
|
||||
|
||||
@@ -945,12 +934,12 @@ public abstract class BlockBasic extends Block implements ICTMBlock//TODO? imple
|
||||
|
||||
if(tileEntity instanceof IMultiblock)
|
||||
{
|
||||
((IMultiblock)tileEntity).update();
|
||||
((IMultiblock)tileEntity).doUpdate();
|
||||
}
|
||||
|
||||
if(tileEntity instanceof IStructuralMultiblock)
|
||||
{
|
||||
((IStructuralMultiblock)tileEntity).update();
|
||||
((IStructuralMultiblock)tileEntity).doUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1058,22 +1047,20 @@ public abstract class BlockBasic extends Block implements ICTMBlock//TODO? imple
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldSideBeRendered(IBlockAccess world, BlockPos pos, int side)
|
||||
public boolean shouldSideBeRendered(IBlockAccess world, BlockPos pos, EnumFacing side)
|
||||
{
|
||||
Coord4D obj = new Coord4D(pos).offset(EnumFacing.getFront(side).getOpposite());
|
||||
Coord4D obj = new Coord4D(pos).offset(EnumFacing.getFront(side.ordinal()).getOpposite());
|
||||
|
||||
if(BasicBlockType.get(this, world.getBlockMetadata(x, y, z)) == BasicBlockType.STRUCTURAL_GLASS)
|
||||
if(BasicBlockType.get(world.getBlockState(obj)) == BasicBlockType.STRUCTURAL_GLASS)
|
||||
{
|
||||
return ctms[10][0].shouldRenderSide(world, pos, side);
|
||||
return ctmData[10][0].shouldRenderSide(world, pos, side);
|
||||
}
|
||||
else {
|
||||
return super.shouldSideBeRendered(world, pos, side);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public EnumFacing[] getValidRotations(World world, BlockPos pos)
|
||||
@@ -1115,6 +1102,41 @@ public abstract class BlockBasic extends Block implements ICTMBlock//TODO? imple
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CTMData getCTMData(IBlockState state)
|
||||
{
|
||||
return ctmData[getMetaFromState(state)][0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverrideTexture(IBlockState state)
|
||||
{
|
||||
BasicBlockType type = state.getValue(getBasicBlock().getProperty());
|
||||
|
||||
if(type == BasicBlockType.INDUCTION_CELL || type == BasicBlockType.INDUCTION_PROVIDER)
|
||||
{
|
||||
return type.getName() + "_" + state.getValue(BlockStateBasic.tierProperty).getName();
|
||||
}
|
||||
|
||||
if(type == BasicBlockType.THERMAL_EVAPORATION_CONTROLLER)
|
||||
{
|
||||
return type.getName() + (state.getValue(BlockStateBasic.activeProperty) ? "_on" : "");
|
||||
}
|
||||
|
||||
if(type == BasicBlockType.INDUCTION_PORT)
|
||||
{
|
||||
return type.getName() + (state.getValue(BlockStateBasic.activeProperty) ? "output" : "input");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyEnum<BasicBlockType> getTypeProperty()
|
||||
{
|
||||
return getBasicBlock().getProperty();
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package mekanism.common.block.states;
|
||||
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.Tier.BaseTier;
|
||||
import mekanism.common.block.BlockBasic;
|
||||
import mekanism.common.tile.TileEntityBin;
|
||||
import mekanism.common.tile.TileEntityBoilerCasing;
|
||||
@@ -42,10 +43,11 @@ import com.google.common.base.Predicates;
|
||||
public class BlockStateBasic extends ExtendedBlockState
|
||||
{
|
||||
public static final PropertyBool activeProperty = PropertyBool.create("active");
|
||||
public static final PropertyEnum<BaseTier> tierProperty = PropertyEnum.create("tier", BaseTier.class);
|
||||
|
||||
public BlockStateBasic(BlockBasic block, PropertyEnum<BasicBlockType> typeProperty)
|
||||
{
|
||||
super(block, new IProperty[] {BlockStateFacing.facingProperty, typeProperty, activeProperty}, new IUnlistedProperty[] {BlockBasic.ctmProperty});
|
||||
super(block, new IProperty[] {BlockStateFacing.facingProperty, typeProperty, activeProperty, tierProperty}, new IUnlistedProperty[] {BlockBasic.ctmProperty});
|
||||
}
|
||||
|
||||
public static enum BasicBlock
|
||||
@@ -154,7 +156,7 @@ public class BlockStateBasic extends ExtendedBlockState
|
||||
return null;
|
||||
}
|
||||
|
||||
public static BasicBlockType get(BasicBlock blockType, int metadata)
|
||||
public static BasicBlockType get(BasicBlock blockType, int metadata)
|
||||
{
|
||||
BasicBlockType firstTry = values()[blockType.ordinal() << 4 | metadata];
|
||||
if(firstTry.blockType == blockType && firstTry.meta == metadata)
|
||||
|
||||
@@ -16,8 +16,8 @@ import mekanism.common.tile.TileEntityBoilerValve;
|
||||
import mekanism.common.tile.TileEntityPressureDisperser;
|
||||
import mekanism.common.tile.TileEntitySuperheatingElement;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
||||
public class BoilerUpdateProtocol extends UpdateProtocol<SynchronizedBoilerData>
|
||||
{
|
||||
@@ -149,7 +149,7 @@ public class BoilerUpdateProtocol extends UpdateProtocol<SynchronizedBoilerData>
|
||||
}
|
||||
|
||||
//Gradle build requires these fields to be final
|
||||
final Coord4D renderLocation = structure.renderLocation.clone();
|
||||
final Coord4D renderLocation = structure.renderLocation;
|
||||
final int volLength = structure.volLength;
|
||||
final int volWidth = structure.volWidth;
|
||||
|
||||
|
||||
@@ -8,5 +8,5 @@ public interface IMultiblock<T extends SynchronizedData<T>>
|
||||
|
||||
public boolean onActivate(EntityPlayer player);
|
||||
|
||||
public void update();
|
||||
public void doUpdate();
|
||||
}
|
||||
@@ -12,5 +12,5 @@ public interface IStructuralMultiblock
|
||||
|
||||
public void setController(Coord4D coord);
|
||||
|
||||
public void update();
|
||||
public void doUpdate();
|
||||
}
|
||||
@@ -6,13 +6,12 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.tile.TileEntityMultiblock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class UpdateProtocol<T extends SynchronizedData<T>>
|
||||
{
|
||||
@@ -38,7 +37,7 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
|
||||
*/
|
||||
public void loopThrough(TileEntity tile)
|
||||
{
|
||||
World worldObj = tile.getWorld();
|
||||
World worldObj = pointer.getWorld();
|
||||
|
||||
int origX = tile.getPos().getX(), origY = tile.getPos().getY(), origZ = tile.getPos().getZ();
|
||||
|
||||
@@ -220,8 +219,8 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
|
||||
for(EnumFacing side : EnumFacing.VALUES)
|
||||
{
|
||||
Coord4D coord = Coord4D.get(tile).offset(side);
|
||||
TileEntity tileEntity = coord.getTileEntity(tile.getWorld());
|
||||
|
||||
TileEntity tileEntity = coord.getTileEntity(pointer.getWorld());
|
||||
|
||||
if(isViableNode(coord))
|
||||
{
|
||||
if(!iteratedNodes.contains(tileEntity))
|
||||
@@ -319,6 +318,11 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
|
||||
public boolean isViableNode(BlockPos pos)
|
||||
{
|
||||
TileEntity tile = pointer.getWorld().getTileEntity(pos);
|
||||
|
||||
if(tile == null || !tile.hasWorldObj())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(tile instanceof IStructuralMultiblock)
|
||||
{
|
||||
@@ -548,7 +552,7 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
|
||||
|
||||
if(toUse == null)
|
||||
{
|
||||
toUse = obj.clone();
|
||||
toUse = obj;
|
||||
}
|
||||
}
|
||||
else if(tileEntity instanceof IStructuralMultiblock)
|
||||
|
||||
@@ -30,11 +30,12 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraftforge.fml.common.Optional.Interface;
|
||||
import net.minecraftforge.fml.common.Optional.Method;
|
||||
|
||||
@Interface(iface = "ic2.api.tile.IWrenchable", modid = "IC2")
|
||||
public abstract class TileEntityBasicBlock extends TileEntity implements IWrenchable, ITileNetwork, IChunkLoadHandler, IFrequencyHandler
|
||||
public abstract class TileEntityBasicBlock extends TileEntity implements IWrenchable, ITileNetwork, IChunkLoadHandler, IFrequencyHandler, ITickable
|
||||
{
|
||||
/** The direction this block is facing. */
|
||||
public EnumFacing facing = EnumFacing.NORTH;
|
||||
|
||||
@@ -30,14 +30,13 @@ import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.PipeUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
@@ -180,7 +179,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
if(take)
|
||||
{
|
||||
activeType = fluid.getFluid();
|
||||
recurringNodes.add(wrapper.clone());
|
||||
recurringNodes.add(wrapper);
|
||||
fluidTank.fill(fluid, true);
|
||||
|
||||
if(shouldTake(fluid, wrapper))
|
||||
|
||||
@@ -90,10 +90,10 @@ public abstract class TileEntityMultiblock<T extends SynchronizedData<T>> extend
|
||||
getManager().updateCache(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(structure == null && ticker == 5)
|
||||
{
|
||||
update();
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
if(prevStructure == (structure == null))
|
||||
@@ -135,7 +135,7 @@ public abstract class TileEntityMultiblock<T extends SynchronizedData<T>> extend
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
public void doUpdate()
|
||||
{
|
||||
if(!worldObj.isRemote && (structure == null || !getSynchronizedData().didTick))
|
||||
{
|
||||
@@ -204,7 +204,7 @@ public abstract class TileEntityMultiblock<T extends SynchronizedData<T>> extend
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(ByteBuf dataStream)
|
||||
public void (ByteBuf dataStream)
|
||||
{
|
||||
super.handlePacketData(dataStream);
|
||||
|
||||
|
||||
@@ -32,13 +32,13 @@ public class TileEntityStructuralGlass extends TileEntity implements IStructural
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
public void doUpdate()
|
||||
{
|
||||
if(master != null)
|
||||
{
|
||||
if(master.getTileEntity(worldObj) instanceof IMultiblock)
|
||||
{
|
||||
((IMultiblock)master.getTileEntity(worldObj)).update();
|
||||
((IMultiblock)master.getTileEntity(worldObj)).doUpdate();
|
||||
}
|
||||
else {
|
||||
master = null;
|
||||
@@ -49,7 +49,7 @@ public class TileEntityStructuralGlass extends TileEntity implements IStructural
|
||||
|
||||
if(multiblock != null)
|
||||
{
|
||||
multiblock.update();
|
||||
multiblock.doUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"defaults": {
|
||||
"model": "cube_all",
|
||||
"textures": {
|
||||
"all": "mekanism:blocks/DynamicTank"
|
||||
"all": "mekanism:blocks/ctm/dynamic_tank"
|
||||
}
|
||||
},
|
||||
"variants": {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"defaults": {
|
||||
"model": "cube_all",
|
||||
"textures": {
|
||||
"all": "mekanism:blocks/DynamicValve"
|
||||
"all": "mekanism:blocks/ctm/dynamic_valve"
|
||||
}
|
||||
},
|
||||
"variants": {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"defaults": {
|
||||
"model": "cube_all",
|
||||
"textures": {
|
||||
"all": "mekanism:blocks/InductionCasing"
|
||||
"all": "mekanism:blocks/ctm/"
|
||||
}
|
||||
},
|
||||
"variants": {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"defaults": {
|
||||
"model": "cube_all",
|
||||
"textures": {
|
||||
"all": "mekanism:blocks/DynamicGlass"
|
||||
"all": "mekanism:blocks/ctm/dynamic_glass"
|
||||
}
|
||||
},
|
||||
"variants": {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"defaults": {
|
||||
"model": "cube_all",
|
||||
"textures": {
|
||||
"all": "mekanism:blocks/ctm/Teleporter"
|
||||
"all": "mekanism:blocks/ctm/teleporter"
|
||||
}
|
||||
},
|
||||
"variants": {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"defaults": {
|
||||
"model": "cube_all",
|
||||
"textures": {
|
||||
"all": "mekanism:blocks/TeleporterFrame"
|
||||
"all": "mekanism:blocks/ctm/teleporter_frame"
|
||||
}
|
||||
},
|
||||
"variants": {
|
||||
|
||||
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |