mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Merge remote-tracking branch 'upstream/1.11' into 1.12
This commit is contained in:
commit
c9dc4c0ac0
468 files changed
+1602
-9935
No files matched your search
@@ -71,7 +71,6 @@ 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.CTMRegistry;
|
||||
import mekanism.client.render.entity.RenderBalloon;
|
||||
import mekanism.client.render.entity.RenderFlame;
|
||||
import mekanism.client.render.entity.RenderObsidianTNTPrimed;
|
||||
@@ -279,7 +278,6 @@ public class ClientProxy extends CommonProxy
|
||||
client.machineEffects = Mekanism.configuration.get("client", "MachineEffects", true).getBoolean();
|
||||
client.replaceSoundsWhenResuming = Mekanism.configuration.get("client", "ReplaceSoundsWhenResuming", true,
|
||||
"If true, will reduce lagging between player sounds. Setting to false will reduce GC load").getBoolean();
|
||||
client.renderCTM = Mekanism.configuration.get("client", "CTMRenderer", true).getBoolean();
|
||||
client.enableAmbientLighting = Mekanism.configuration.get("client", "EnableAmbientLighting", true).getBoolean();
|
||||
client.ambientLightingLevel = Mekanism.configuration.get("client", "AmbientLightingLevel", 15).getInt();
|
||||
client.opaqueTransmitters = Mekanism.configuration.get("client", "OpaqueTransmitterRender", false).getBoolean();
|
||||
@@ -1111,8 +1109,7 @@ public class ClientProxy extends CommonProxy
|
||||
MekanismRenderer.init();
|
||||
|
||||
ModelLoaderRegistry.registerLoader(MekanismOBJLoader.INSTANCE);
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new CTMRegistry());
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
MinecraftForge.EVENT_BUS.register(MekanismOBJLoader.INSTANCE);
|
||||
|
||||
@@ -1152,11 +1149,6 @@ public class ClientProxy extends CommonProxy
|
||||
return new RenderFlame(manager);
|
||||
}
|
||||
});
|
||||
|
||||
CTMRegistry.registerCTMs("mekanism", "dynamic_tank", "structural_glass", "dynamic_valve", "teleporter", "teleporter_frame", "induction_casing", "induction_port", "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",
|
||||
"boiler_casing", "boiler_valve", "thermal_evaporation_valve", "thermal_evaporation_block");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -161,7 +161,8 @@ public class RenderResizableCuboid {
|
||||
wr.begin(GL11.GL_QUADS, shadeTypes.vertexFormat);
|
||||
|
||||
for (EnumFacing face : EnumFacing.values()) {
|
||||
renderCuboidFace(wr, face, sprites, flips, textureStart, textureSize, size, textureOffset, shadeTypes, formula, faceFormula, world);
|
||||
if(cube.shouldSideRender(face))
|
||||
renderCuboidFace(wr, face, sprites, flips, textureStart, textureSize, size, textureOffset, shadeTypes, formula, faceFormula, world);
|
||||
}
|
||||
|
||||
tess.draw();
|
||||
|
||||
@@ -1,349 +0,0 @@
|
||||
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;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
// @formatter:off
|
||||
/**
|
||||
* The CTM renderer will draw the block's FACE using by assembling 4 quadrants from the 5 available block
|
||||
* textures. The normal Texture.png is the blocks "unconnected" texture, and is used when CTM is disabled or the block
|
||||
* has nothing to connect to. This texture has all of the outside corner quadrants The texture-ctm.png contains the
|
||||
* rest of the quadrants.
|
||||
* <pre><blockquote>
|
||||
* ┌─────────────────┐ ┌────────────────────────────────┐
|
||||
* │ texture.png │ │ texture-ctm.png │
|
||||
* │ ╔══════╤══════╗ │ │ ──────┼────── ║ ─────┼───── ║ │
|
||||
* │ ║ │ ║ │ │ │ │ │║ │ ║ │
|
||||
* │ ║ 16 │ 17 ║ │ │ │ 0 │ 1 │║ 2 │ 3 ║ │
|
||||
* │ ╟──────┼──────╢ │ │ ┼──────┼──────┼╟──────┼──────╢ │
|
||||
* │ ║ │ ║ │ │ │ │ │║ │ ║ │
|
||||
* │ ║ 18 │ 19 ║ │ │ │ 4 │ 5 │║ 6 │ 7 ║ │
|
||||
* │ ╚══════╧══════╝ │ │ ──────┼────── ║ ─────┼───── ║ │
|
||||
* └─────────────────┘ │ ═══════╤═══════╝ ─────┼───── ╚ │
|
||||
* │ │ │ ││ │ │ │
|
||||
* │ │ 8 │ 9 ││ 10 │ 11 │ │
|
||||
* │ ┼──────┼──────┼┼──────┼──────┼ │
|
||||
* │ │ │ ││ │ │ │
|
||||
* │ │ 12 │ 13 ││ 14 │ 15 │ │
|
||||
* │ ═══════╧═══════╗ ─────┼───── ╔ │
|
||||
* └────────────────────────────────┘
|
||||
* </blockquote></pre>
|
||||
* combining { 18, 13, 9, 16 }, we can generate a texture connected to the right!
|
||||
* <pre><blockquote>
|
||||
* ╔══════╤═══════
|
||||
* ║ │ │
|
||||
* ║ 16 │ 9 │
|
||||
* ╟──────┼──────┼
|
||||
* ║ │ │
|
||||
* ║ 18 │ 13 │
|
||||
* ╚══════╧═══════
|
||||
* </blockquote></pre>
|
||||
*
|
||||
* combining { 18, 13, 11, 2 }, we can generate a texture, in the shape of an L (connected to the right, and up
|
||||
* <pre><blockquote>
|
||||
* ║ ─────┼───── ╚
|
||||
* ║ │ │
|
||||
* ║ 2 │ 11 │
|
||||
* ╟──────┼──────┼
|
||||
* ║ │ │
|
||||
* ║ 18 │ 13 │
|
||||
* ╚══════╧═══════
|
||||
* </blockquote></pre>
|
||||
*
|
||||
* HAVE FUN!
|
||||
* -CptRageToaster-
|
||||
*/
|
||||
public class CTM {
|
||||
public static int REQUIRED_TEXTURES = 2;
|
||||
public static int QUADS_PER_SIDE = 4;
|
||||
|
||||
/**
|
||||
* The Uvs for the specific "magic number" value
|
||||
*/
|
||||
public static final ISubmap[] uvs = new ISubmap[]{
|
||||
//Ctm texture
|
||||
new Submap(4, 4, 0, 0), // 0
|
||||
new Submap(4, 4, 4, 0), // 1
|
||||
new Submap(4, 4, 8, 0), // 2
|
||||
new Submap(4, 4, 12, 0), // 3
|
||||
new Submap(4, 4, 0, 4), // 4
|
||||
new Submap(4, 4, 4, 4), // 5
|
||||
new Submap(4, 4, 8, 4), // 6
|
||||
new Submap(4, 4, 12, 4), // 7
|
||||
new Submap(4, 4, 0, 8), // 8
|
||||
new Submap(4, 4, 4, 8), // 9
|
||||
new Submap(4, 4, 8, 8), // 10
|
||||
new Submap(4, 4, 12, 8), // 11
|
||||
new Submap(4, 4, 0, 12), // 12
|
||||
new Submap(4, 4, 4, 12), // 13
|
||||
new Submap(4, 4, 8, 12), // 14
|
||||
new Submap(4, 4, 12, 12), // 15
|
||||
// Default texture
|
||||
new Submap(8, 8, 0, 0), // 16
|
||||
new Submap(8, 8, 8, 0), // 17
|
||||
new Submap(8, 8, 0, 8), // 18
|
||||
new Submap(8, 8, 8, 8) // 19
|
||||
};
|
||||
|
||||
public static final ISubmap FULL_TEXTURE = new Submap(16, 16, 0, 0);
|
||||
|
||||
// @formatter:on
|
||||
|
||||
/** Some hardcoded offset values for the different corner indeces */
|
||||
protected static int[] submapOffsets = { 4, 5, 1, 0 };
|
||||
/** For use via the Chisel 2 config only, altering this could cause unintended behavior */
|
||||
public static boolean disableObscuredFaceCheckConfig = false;
|
||||
|
||||
public Optional<Boolean> disableObscuredFaceCheck = Optional.absent();
|
||||
|
||||
protected TIntObjectMap<Dir[]> submapMap = new TIntObjectHashMap<Dir[]>();
|
||||
protected EnumMap<Dir, Boolean> connectionMap = Maps.newEnumMap(Dir.class);
|
||||
protected int[] submapCache;
|
||||
|
||||
protected CTM()
|
||||
{
|
||||
for (Dir dir : Dir.VALUES)
|
||||
{
|
||||
connectionMap.put(dir, false);
|
||||
}
|
||||
|
||||
// Mapping the different corner indeces to their respective dirs
|
||||
submapMap.put(0, new Dir[] { BOTTOM, LEFT, BOTTOM_LEFT });
|
||||
submapMap.put(1, new Dir[] { BOTTOM, RIGHT, BOTTOM_RIGHT });
|
||||
submapMap.put(2, new Dir[] { TOP, RIGHT, TOP_RIGHT });
|
||||
submapMap.put(3, new Dir[] { TOP, LEFT, TOP_LEFT });
|
||||
}
|
||||
|
||||
public static CTM getInstance() {
|
||||
return new CTM();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The indeces of the typical 4x4 submap to use for the given face at the given location.
|
||||
*
|
||||
* Indeces are in counter-clockwise order starting at bottom left.
|
||||
*/
|
||||
public int[] createSubmapIndices(IBlockAccess world, BlockPos pos, EnumFacing side) {
|
||||
submapCache = new int[] { 18, 19, 17, 16 };
|
||||
|
||||
if (world == null) {
|
||||
return submapCache;
|
||||
}
|
||||
|
||||
buildConnectionMap(world, pos, side);
|
||||
|
||||
// Map connections to submap indeces
|
||||
for (int i = 0; i < 4; i++) {
|
||||
fillSubmaps(i);
|
||||
}
|
||||
|
||||
return submapCache;
|
||||
}
|
||||
|
||||
public int[] createSubmapIndices(long data, EnumFacing side){
|
||||
submapCache = new int[] { 18, 19, 17, 16 };
|
||||
|
||||
buildConnectionMap(data, side);
|
||||
|
||||
// Map connections to submap indeces
|
||||
for (int i = 0; i < 4; i++) {
|
||||
fillSubmaps(i);
|
||||
}
|
||||
|
||||
return submapCache;
|
||||
}
|
||||
|
||||
public int[] getSubmapIndices() {
|
||||
return submapCache;
|
||||
}
|
||||
|
||||
public static boolean isDefaultTexture(int id) {
|
||||
return (id == 16 || id == 17 || id == 18 || id == 19);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the connection map and stores it in this CTM instance. The {@link #connected(Dir)}, {@link #connectedAnd(Dir...)}, and {@link #connectedOr(Dir...)} methods can be used to access it.
|
||||
*/
|
||||
public void buildConnectionMap(IBlockAccess world, BlockPos pos, EnumFacing side) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
for (Dir dir : Dir.VALUES) {
|
||||
connectionMap.put(dir, dir.isConnected(this, world, pos, side, state));
|
||||
}
|
||||
}
|
||||
|
||||
public void buildConnectionMap(long data, EnumFacing side){
|
||||
for (Dir dir : Dir.VALUES){
|
||||
connectionMap.put(dir, false);
|
||||
}
|
||||
List<CTMConnections> connections = CTMConnections.decode(data);
|
||||
for (CTMConnections loc : connections){
|
||||
if (loc.getDirForSide(side) != null){
|
||||
connectionMap.put(loc.getDirForSide(side), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fillSubmaps(int idx) {
|
||||
Dir[] dirs = submapMap.get(idx);
|
||||
if (connectedOr(dirs[0], dirs[1])) {
|
||||
if (connectedAnd(dirs)) {
|
||||
// If all dirs are connected, we use the fully connected face,
|
||||
// the base offset value.
|
||||
submapCache[idx] = submapOffsets[idx];
|
||||
} else {
|
||||
// This is a bit magic-y, but basically the array is ordered so
|
||||
// the first dir requires an offset of 2, and the second dir
|
||||
// requires an offset of 8, plus the initial offset for the
|
||||
// corner.
|
||||
submapCache[idx] = submapOffsets[idx] + (connected(dirs[0]) ? 2 : 0) + (connected(dirs[1]) ? 8 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dir
|
||||
* The direction to check connection in.
|
||||
* @return True if the cached connectionMap holds a connection in this {@link Dir direction}.
|
||||
*/
|
||||
public boolean connected(Dir dir) {
|
||||
return connectionMap.get(dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dirs
|
||||
* The directions to check connection in.
|
||||
* @return True if the cached connectionMap holds a connection in <i><b>all</b></i> the given {@link Dir directions}.
|
||||
*/
|
||||
public boolean connectedAnd(Dir... dirs) {
|
||||
for (Dir dir : dirs) {
|
||||
if (!connected(dir)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dirs
|
||||
* The directions to check connection in.
|
||||
* @return True if the cached connectionMap holds a connection in <i><b>one of</b></i> the given {@link Dir directions}.
|
||||
*/
|
||||
public boolean connectedOr(Dir... dirs) {
|
||||
for (Dir dir : dirs) {
|
||||
if (connected(dir)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple check for if the given block can connect to the given direction on the given side.
|
||||
*
|
||||
* @param world
|
||||
* @param current
|
||||
* The position of your block.
|
||||
* @param y
|
||||
* The position of the block to check against.
|
||||
* @param dir
|
||||
* The {@link EnumFacing side} of the block to check for connection status. This is <i>not</i> the direction to check in.
|
||||
* @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 = world.getBlockState(current);
|
||||
return isConnected(world, current, connection, dir, state);
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple check for if the given block can connect to the given direction on the given side.
|
||||
*
|
||||
* @param world
|
||||
* @param current
|
||||
* The position of your block.
|
||||
* @param y
|
||||
* The position of the block to check against.
|
||||
* @param dir
|
||||
* The {@link EnumFacing side} of the block to check for connection status. This is <i>not</i> the direction to check in.
|
||||
* @param state
|
||||
* 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)
|
||||
{
|
||||
BlockPos pos2 = connection.add(dir.getDirectionVec());
|
||||
|
||||
boolean disableObscured = disableObscuredFaceCheck.or(disableObscuredFaceCheckConfig);
|
||||
|
||||
IBlockState obscuring = disableObscured ? null : getConnectedState(world, pos2, dir);
|
||||
|
||||
boolean ret = canConnect(world, current, connection);
|
||||
|
||||
// no block obscuring this face
|
||||
if(obscuring == null)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
// check that we aren't already connected outwards from this side
|
||||
ret &= !obscuring.isFullCube() || !obscuring.equals(state);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static boolean canConnect(IBlockAccess world, BlockPos pos, BlockPos connection)
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
IBlockState con = world.getBlockState(connection);
|
||||
|
||||
if(!(state.getBlock() instanceof ICTMBlock))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CTMData data = ((ICTMBlock)state.getBlock()).getCTMData(state);
|
||||
|
||||
// no block or a bad API user
|
||||
if(con == null || data == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean ret = false;
|
||||
|
||||
if(con.getBlock() instanceof ICTMBlock && ((ICTMBlock)con.getBlock()).getCTMData(con) != null)
|
||||
{
|
||||
String state2 = ((IStringSerializable)con.getValue(((ICTMBlock)con.getBlock()).getTypeProperty())).getName();
|
||||
|
||||
ret = data.acceptableBlockStates.contains(state2);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static IBlockState getConnectedState(IBlockAccess world, BlockPos pos, EnumFacing side)
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
return state;
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package mekanism.client.render.ctm;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import static mekanism.client.render.ctm.CTMConnections.*;
|
||||
|
||||
public class CTMBlockRenderContext
|
||||
{
|
||||
private static final CTMConnections[] CACHED_LOCATIONS = ArrayUtils.removeElements(CTMConnections.VALUES, UP_UP, DOWN_DOWN, EAST_EAST, WEST_WEST, NORTH_NORTH, SOUTH_SOUTH);
|
||||
|
||||
private EnumMap<EnumFacing, CTM> ctmData = new EnumMap<>(EnumFacing.class);
|
||||
|
||||
private long data;
|
||||
|
||||
public CTMBlockRenderContext(IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
for(EnumFacing face : EnumFacing.VALUES)
|
||||
{
|
||||
CTM ctm = createCTM();
|
||||
ctm.createSubmapIndices(world, pos, face);
|
||||
ctmData.put(face, ctm);
|
||||
}
|
||||
|
||||
data = CTMConnections.getData(world, pos, CACHED_LOCATIONS);
|
||||
}
|
||||
|
||||
public CTMBlockRenderContext(long d)
|
||||
{
|
||||
data = d;
|
||||
|
||||
for(EnumFacing face : EnumFacing.VALUES)
|
||||
{
|
||||
CTM ctm = createCTM();
|
||||
ctm.createSubmapIndices(data, face);
|
||||
ctmData.put(face, ctm);
|
||||
}
|
||||
}
|
||||
|
||||
protected CTM createCTM()
|
||||
{
|
||||
return CTM.getInstance();
|
||||
}
|
||||
|
||||
public CTM getCTM(EnumFacing face)
|
||||
{
|
||||
return ctmData.get(face);
|
||||
}
|
||||
|
||||
public long serialize()
|
||||
{
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -1,224 +0,0 @@
|
||||
package mekanism.client.render.ctm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.MekanismAPI;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
/**
|
||||
* Represents all the different spot for connection locations for a ctm block
|
||||
*/
|
||||
public enum CTMConnections
|
||||
{
|
||||
UP(Dir.TOP),
|
||||
DOWN(Dir.BOTTOM),
|
||||
NORTH(EnumFacing.EAST, Dir.RIGHT),
|
||||
SOUTH(EnumFacing.EAST, Dir.LEFT),
|
||||
EAST(Dir.RIGHT),
|
||||
WEST(Dir.LEFT),
|
||||
|
||||
NORTH_EAST(EnumFacing.UP, Dir.TOP_RIGHT),
|
||||
NORTH_WEST(EnumFacing.UP, Dir.TOP_LEFT),
|
||||
SOUTH_EAST(EnumFacing.UP, Dir.BOTTOM_RIGHT),
|
||||
SOUTH_WEST(EnumFacing.UP, Dir.BOTTOM_LEFT),
|
||||
|
||||
NORTH_UP(EnumFacing.EAST, Dir.TOP_RIGHT),
|
||||
NORTH_DOWN(EnumFacing.EAST, Dir.BOTTOM_RIGHT),
|
||||
SOUTH_UP(EnumFacing.EAST, Dir.TOP_LEFT),
|
||||
SOUTH_DOWN(EnumFacing.EAST, Dir.BOTTOM_LEFT),
|
||||
|
||||
EAST_UP(Dir.TOP_RIGHT),
|
||||
EAST_DOWN(Dir.BOTTOM_RIGHT),
|
||||
WEST_UP(Dir.TOP_LEFT),
|
||||
WEST_DOWN(Dir.BOTTOM_LEFT),
|
||||
|
||||
NORTH_EAST_UP(EnumFacing.EAST, Dir.TOP_RIGHT, true),
|
||||
NORTH_EAST_DOWN(EnumFacing.EAST, Dir.BOTTOM_RIGHT, true),
|
||||
|
||||
SOUTH_EAST_UP(EnumFacing.EAST, Dir.TOP_LEFT, true),
|
||||
SOUTH_EAST_DOWN(EnumFacing.EAST, Dir.BOTTOM_LEFT, true),
|
||||
|
||||
SOUTH_WEST_UP(EnumFacing.WEST, Dir.TOP_LEFT, true),
|
||||
SOUTH_WEST_DOWN(EnumFacing.WEST, Dir.BOTTOM_LEFT, true),
|
||||
|
||||
NORTH_WEST_UP(EnumFacing.WEST, Dir.TOP_RIGHT, true),
|
||||
NORTH_WEST_DOWN(EnumFacing.WEST, Dir.BOTTOM_RIGHT, true),
|
||||
|
||||
UP_UP(EnumFacing.UP, null, true),
|
||||
DOWN_DOWN(EnumFacing.DOWN, null, true),
|
||||
NORTH_NORTH(EnumFacing.NORTH, null, true),
|
||||
SOUTH_SOUTH(EnumFacing.SOUTH, null, true),
|
||||
EAST_EAST(EnumFacing.EAST, null, true),
|
||||
WEST_WEST(EnumFacing.WEST, null, true);
|
||||
|
||||
public static final CTMConnections[] VALUES = values();
|
||||
|
||||
/**
|
||||
* The enum facing directions needed to get to this connection location
|
||||
*/
|
||||
private EnumFacing normal;
|
||||
private Dir dir;
|
||||
private boolean offset;
|
||||
|
||||
private CTMConnections(Dir dir)
|
||||
{
|
||||
this(EnumFacing.SOUTH, dir);
|
||||
}
|
||||
|
||||
private CTMConnections(Dir dir, boolean offset)
|
||||
{
|
||||
this(EnumFacing.SOUTH, dir, offset);
|
||||
}
|
||||
|
||||
private CTMConnections(EnumFacing normal, Dir dir)
|
||||
{
|
||||
this(normal, dir, false);
|
||||
}
|
||||
|
||||
private CTMConnections(EnumFacing normal, Dir dir, boolean offset)
|
||||
{
|
||||
this.normal = normal;
|
||||
this.dir = dir;
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public Dir getDirForSide(EnumFacing facing)
|
||||
{
|
||||
return dir == null ? null : dir;//TODO .relativize()
|
||||
}
|
||||
|
||||
public EnumFacing clipOrDestroy(EnumFacing direction)
|
||||
{
|
||||
EnumFacing[] dirs = dir == null ? new EnumFacing[] {normal, normal} : dir.getNormalizedDirs(direction);
|
||||
|
||||
if(dirs[0] == direction)
|
||||
{
|
||||
return dirs.length > 1 ? dirs[1] : null;
|
||||
}
|
||||
else if(dirs.length > 1 && dirs[1] == direction)
|
||||
{
|
||||
return dirs[0];
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public BlockPos transform(BlockPos pos)
|
||||
{
|
||||
if(dir != null)
|
||||
{
|
||||
for(EnumFacing facing : dir.getNormalizedDirs(normal))
|
||||
{
|
||||
pos = pos.offset(facing);
|
||||
}
|
||||
}
|
||||
else {
|
||||
pos = pos.offset(normal);
|
||||
}
|
||||
|
||||
if(offset)
|
||||
{
|
||||
pos = pos.offset(normal);
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
public static CTMConnections fromFacing(EnumFacing facing)
|
||||
{
|
||||
switch(facing)
|
||||
{
|
||||
case NORTH: return NORTH;
|
||||
case SOUTH: return SOUTH;
|
||||
case EAST: return EAST;
|
||||
case WEST: return WEST;
|
||||
case UP: return UP;
|
||||
case DOWN: return DOWN;
|
||||
default: return NORTH;
|
||||
}
|
||||
}
|
||||
|
||||
public static EnumFacing toFacing(CTMConnections loc)
|
||||
{
|
||||
switch(loc)
|
||||
{
|
||||
case NORTH: return EnumFacing.NORTH;
|
||||
case SOUTH: return EnumFacing.SOUTH;
|
||||
case EAST: return EnumFacing.EAST;
|
||||
case WEST: return EnumFacing.WEST;
|
||||
case UP: return EnumFacing.UP;
|
||||
case DOWN: return EnumFacing.DOWN;
|
||||
default: return EnumFacing.NORTH;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<CTMConnections> decode(long data)
|
||||
{
|
||||
List<CTMConnections> list = new ArrayList<>();
|
||||
|
||||
for(CTMConnections loc : values())
|
||||
{
|
||||
if((1 & (data >> loc.ordinal())) != 0)
|
||||
{
|
||||
list.add(loc);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public long getMask()
|
||||
{
|
||||
return 1 << ordinal();
|
||||
}
|
||||
|
||||
public static List<CTMConnections> getConnections(IBlockAccess world, BlockPos pos, CTMConnections[] values)
|
||||
{
|
||||
List<CTMConnections> locs = new ArrayList<>();
|
||||
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
|
||||
for(CTMConnections loc : values)
|
||||
{
|
||||
BlockPos second = loc.transform(pos);
|
||||
|
||||
if(CTM.canConnect(world, pos, second))
|
||||
{
|
||||
locs.add(loc);
|
||||
}
|
||||
}
|
||||
|
||||
return locs;
|
||||
}
|
||||
|
||||
public static long getData(IBlockAccess world, BlockPos pos, CTMConnections[] values)
|
||||
{
|
||||
List<CTMConnections> locs = getConnections(world, pos, values);
|
||||
|
||||
long data = 0;
|
||||
|
||||
for(CTMConnections loc : locs)
|
||||
{
|
||||
data = data | loc.getMask();
|
||||
}
|
||||
|
||||
if(MekanismAPI.debug)
|
||||
{
|
||||
String s = Long.toBinaryString(data);
|
||||
|
||||
while(s.length() < 32)
|
||||
{
|
||||
s = "0" + s;
|
||||
}
|
||||
|
||||
System.out.println(pos + ": " + s);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package mekanism.client.render.ctm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
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 CTMData(IStringSerializable... states)
|
||||
{
|
||||
for(IStringSerializable state : states)
|
||||
{
|
||||
acceptableBlockStates.add(state.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public CTMData setRenderConvexConnections()
|
||||
{
|
||||
renderConvexConnections = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@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 true;
|
||||
}
|
||||
}
|
||||
@@ -1,226 +0,0 @@
|
||||
package mekanism.client.render.ctm;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
import mekanism.common.block.states.BlockStateBasic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.MultimapBuilder;
|
||||
import com.google.common.collect.Table;
|
||||
import com.google.common.collect.Tables;
|
||||
|
||||
/**
|
||||
* Model for all CTM blocks, credit to Chisel
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class CTMModelFactory implements IBakedModel
|
||||
{
|
||||
private ListMultimap<BlockRenderLayer, BakedQuad> genQuads = MultimapBuilder.enumKeys(BlockRenderLayer.class).arrayListValues().build();
|
||||
private Table<BlockRenderLayer, EnumFacing, List<BakedQuad>> faceQuads = Tables.newCustomTable(Maps.newEnumMap(BlockRenderLayer.class), () -> Maps.newEnumMap(EnumFacing.class));
|
||||
|
||||
private ModelCTM model;
|
||||
|
||||
private CTMOverride override = new CTMOverride();
|
||||
|
||||
public CTMModelFactory(ModelCTM m)
|
||||
{
|
||||
model = m;
|
||||
}
|
||||
|
||||
private static Cache<Integer, CTMModelFactory> ctmCache = CacheBuilder.newBuilder().expireAfterAccess(1, TimeUnit.MINUTES).maximumSize(500).<Integer, CTMModelFactory>build();
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState stateIn, EnumFacing side, long rand)
|
||||
{
|
||||
CTMModelFactory baked;
|
||||
|
||||
if(stateIn != null && stateIn.getBlock() instanceof ICTMBlock && stateIn instanceof IExtendedBlockState)
|
||||
{
|
||||
IExtendedBlockState state = (IExtendedBlockState)stateIn;
|
||||
IBlockState clean = state.getClean();
|
||||
CTMBlockRenderContext ctxList = state.getValue(BlockStateBasic.ctmProperty);
|
||||
|
||||
try {
|
||||
if(ctxList == null)
|
||||
{
|
||||
baked = ctmCache.get(Objects.hash(clean, -1), () -> createModel(state, model, null));
|
||||
}
|
||||
else {
|
||||
long serialized = ctxList.serialize();
|
||||
baked = ctmCache.get(Objects.hash(clean, serialized), () -> createModel(state, model, ctxList));
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
}
|
||||
else {
|
||||
baked = this;
|
||||
}
|
||||
|
||||
BlockRenderLayer layer = MinecraftForgeClient.getRenderLayer();
|
||||
return side == null ? baked.genQuads.get(layer) : layer == null ? baked.faceQuads.column(side).values().stream().flatMap(List::stream).collect(Collectors.toList()) : baked.faceQuads.get(layer, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
{
|
||||
return model.getDefaultFace().getParticle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
{
|
||||
return ItemCameraTransforms.DEFAULT;
|
||||
}
|
||||
|
||||
private CTMModelFactory createModel(IBlockState state, ModelCTM model, CTMBlockRenderContext ctx)
|
||||
{
|
||||
CTMModelFactory ret = new CTMModelFactory(model);
|
||||
IBakedModel baked = model.getModel(state);
|
||||
int quadGoal = ctx == null ? 1 : CTM.QUADS_PER_SIDE;
|
||||
List<BakedQuad> quads = Lists.newArrayList();
|
||||
|
||||
for(BlockRenderLayer layer : BlockRenderLayer.values())
|
||||
{
|
||||
for(EnumFacing facing : EnumFacing.VALUES)
|
||||
{
|
||||
TextureCTM face = model.getFace(facing);
|
||||
|
||||
if(ctx == null || layer == state.getBlock().getBlockLayer())
|
||||
{
|
||||
ICTMBlock block = (ICTMBlock)state.getBlock();
|
||||
CTMData data = block.getCTMData(state);
|
||||
|
||||
if(block.getOverrideTexture(state, facing) != null)
|
||||
{
|
||||
face = CTMRegistry.textureCache.get(block.getOverrideTexture(state, facing));
|
||||
}
|
||||
|
||||
List<BakedQuad> temp = baked.getQuads(state, facing, 0);
|
||||
addAllQuads(temp, face, ctx, state, quadGoal, quads);
|
||||
ret.faceQuads.put(layer, facing, ImmutableList.copyOf(quads));
|
||||
|
||||
temp = FluentIterable.from(baked.getQuads(state, null, 0)).filter(q -> q.getFace() == facing).toList();
|
||||
addAllQuads(temp, face, ctx, state, quadGoal, quads);
|
||||
ret.genQuads.putAll(layer, temp);
|
||||
}
|
||||
else {
|
||||
ret.faceQuads.put(layer, facing, Lists.newArrayList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void addAllQuads(List<BakedQuad> from, TextureCTM tex, @Nullable CTMBlockRenderContext ctx, IBlockState state, int quadGoal, List<BakedQuad> to)
|
||||
{
|
||||
to.clear();
|
||||
|
||||
for(BakedQuad q : from)
|
||||
{
|
||||
to.addAll(tex.transformQuad(q, ctx == null ? null : ctx, quadGoal));
|
||||
}
|
||||
}
|
||||
|
||||
private static TRSRTransformation get(float tx, float ty, float tz, float ax, float ay, float az, float s)
|
||||
{
|
||||
return new TRSRTransformation(
|
||||
new Vector3f(tx / 16, ty / 16, tz / 16),
|
||||
TRSRTransformation.quatFromXYZDegrees(new Vector3f(ax, ay, az)),
|
||||
new Vector3f(s, s, s),
|
||||
null);
|
||||
}
|
||||
|
||||
public static Map<TransformType, TRSRTransformation> transforms = ImmutableMap.<TransformType, TRSRTransformation>builder()
|
||||
.put(TransformType.GUI, get(0, 0, 0, 30, 225, 0, 0.625f))
|
||||
.put(TransformType.THIRD_PERSON_RIGHT_HAND, get(0, 2.5f, 0, 75, 45, 0, 0.375f))
|
||||
.put(TransformType.THIRD_PERSON_LEFT_HAND, get(0, 2.5f, 0, 75, 45, 0, 0.375f))
|
||||
.put(TransformType.FIRST_PERSON_RIGHT_HAND, get(0, 0, 0, 0, 45, 0, 0.4f))
|
||||
.put(TransformType.FIRST_PERSON_LEFT_HAND, get(0, 0, 0, 0, 225, 0, 0.4f))
|
||||
.put(TransformType.GROUND, get(0, 2, 0, 0, 0, 0, 0.25f))
|
||||
.put(TransformType.HEAD, get(0, 0, 0, 0, 0, 0, 1))
|
||||
.put(TransformType.FIXED, get(0, 0, 0, 0, 0, 0, 1))
|
||||
.put(TransformType.NONE, get(0, 0, 0, 0, 0, 0, 0))
|
||||
.build();
|
||||
|
||||
@Override
|
||||
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType)
|
||||
{
|
||||
return Pair.of(this, transforms.get(cameraTransformType).getMatrix());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
return override;
|
||||
}
|
||||
|
||||
private class CTMOverride extends ItemOverrideList
|
||||
{
|
||||
public CTMOverride()
|
||||
{
|
||||
super(Lists.newArrayList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity)
|
||||
{
|
||||
Block block = ((ItemBlock)stack.getItem()).getBlock();
|
||||
return createModel(block.getDefaultState(), model, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
package mekanism.client.render.ctm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.model.ModelRotation;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.client.model.Attributes;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
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 List<Pair<String, String>> ctmTypes = new ArrayList<Pair<String, String>>();
|
||||
|
||||
public static Map<String, TextureCTM> textureCache = new HashMap<String, TextureCTM>();
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTextureStitch(TextureStitchEvent.Pre event)
|
||||
{
|
||||
for(TextureSpriteCallback callback : textures)
|
||||
{
|
||||
callback.stitch(event.getMap());
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onModelBake(ModelBakeEvent event) throws Exception
|
||||
{
|
||||
IModel model = ModelLoaderRegistry.getModel(baseResource);
|
||||
baseModel = model.bake(new TRSRTransformation(ModelRotation.X0_Y0), Attributes.DEFAULT_BAKED_FORMAT, r -> Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(r.toString()));
|
||||
|
||||
for(Pair<String, String> pair : ctmTypes)
|
||||
{
|
||||
ModelCTM chiselModel = new ModelCTM(baseModel, pair.getRight());
|
||||
chiselModel.load();
|
||||
event.getModelRegistry().putObject(new ModelResourceLocation(pair.getLeft() + ":" + pair.getRight()), new CTMModelFactory(chiselModel));
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerCTMs(String domain, String... ctms)
|
||||
{
|
||||
for(String s : ctms)
|
||||
{
|
||||
ctmTypes.add(Pair.of(domain, s));
|
||||
textureCache.put(s, createTexture(domain, s));
|
||||
}
|
||||
}
|
||||
|
||||
public static void register(TextureSpriteCallback callback)
|
||||
{
|
||||
textures.add(callback);
|
||||
}
|
||||
|
||||
public static TextureCTM createTexture(String domain, String name)
|
||||
{
|
||||
TextureSpriteCallback[] callbacks = new TextureSpriteCallback[CTM.REQUIRED_TEXTURES];
|
||||
|
||||
callbacks[0] = new TextureSpriteCallback(new ResourceLocation(domain + ":blocks/ctm/" + name));
|
||||
callbacks[1] = new TextureSpriteCallback(new ResourceLocation(domain + ":blocks/ctm/" + name + "-ctm"));
|
||||
|
||||
register(callbacks[0]);
|
||||
register(callbacks[1]);
|
||||
|
||||
return new TextureCTM(callbacks);
|
||||
}
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
package mekanism.client.render.ctm;
|
||||
|
||||
import static net.minecraft.util.EnumFacing.DOWN;
|
||||
import static net.minecraft.util.EnumFacing.EAST;
|
||||
import static net.minecraft.util.EnumFacing.NORTH;
|
||||
import static net.minecraft.util.EnumFacing.SOUTH;
|
||||
import static net.minecraft.util.EnumFacing.UP;
|
||||
import static net.minecraft.util.EnumFacing.WEST;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumFacing.Axis;
|
||||
import net.minecraft.util.EnumFacing.AxisDirection;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
/**
|
||||
* Think of this class as a "Two dimensional EnumFacing, with diagonals".
|
||||
* <p>
|
||||
* It represents the eight different directions a face of a block can connect with CTM, and contains the logic for determining if a block is indeed connected in that direction.
|
||||
* <p>
|
||||
* Note that, for example, {@link #TOP_RIGHT} does not mean connected to the {@link #TOP} and {@link #RIGHT}, but connected in the diagonal direction represented by {@link #TOP_RIGHT}. This is used
|
||||
* for inner corner rendering.
|
||||
*/
|
||||
public enum Dir {
|
||||
// @formatter:off
|
||||
TOP(UP),
|
||||
TOP_RIGHT(UP, EAST),
|
||||
RIGHT(EAST),
|
||||
BOTTOM_RIGHT(DOWN, EAST),
|
||||
BOTTOM(DOWN),
|
||||
BOTTOM_LEFT(DOWN, WEST),
|
||||
LEFT(WEST),
|
||||
TOP_LEFT(UP, WEST);
|
||||
// @formatter:on
|
||||
|
||||
/**
|
||||
* All values of this enum, used to prevent unnecessary allocation via {@link #values()}.
|
||||
*/
|
||||
public static final Dir[] VALUES = values();
|
||||
private static final EnumFacing NORMAL = SOUTH;
|
||||
|
||||
private EnumFacing[] dirs;
|
||||
|
||||
private Dir(EnumFacing... dirs) {
|
||||
this.dirs = dirs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds if this block is connected for the given side in this Dir.
|
||||
*
|
||||
* @param inst
|
||||
* The CTM instance to use for logic.
|
||||
* @param world
|
||||
* The world the block is in.
|
||||
* @param pos
|
||||
* The position of your block.
|
||||
* @param side
|
||||
* The side of the current face.
|
||||
* @return True if the block is connected in the given Dir, false otherwise.
|
||||
*/
|
||||
public boolean isConnected(CTM ctm, IBlockAccess world, BlockPos pos, EnumFacing side) {
|
||||
return ctm.isConnected(world, pos, getConnection(pos, side), side);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds if this block is connected for the given side in this Dir.
|
||||
*
|
||||
* @param inst
|
||||
* The CTM instance to use for logic.
|
||||
* @param world
|
||||
* The world the block is in.
|
||||
* @param pos
|
||||
* The position of your block.
|
||||
* @param side
|
||||
* The side of the current face.
|
||||
* @param side
|
||||
* The state to check for connection with.
|
||||
* @return True if the block is connected in the given Dir, false otherwise.
|
||||
*/
|
||||
public boolean isConnected(CTM ctm, IBlockAccess world, BlockPos pos, EnumFacing side, IBlockState state) {
|
||||
return ctm.isConnected(world, pos, getConnection(pos, side), side, state);
|
||||
}
|
||||
|
||||
private BlockPos getConnection(BlockPos pos, EnumFacing side) {
|
||||
EnumFacing[] dirs = getNormalizedDirs(side);
|
||||
BlockPos connection = pos;
|
||||
for (EnumFacing dir : dirs) {
|
||||
connection = connection.offset(dir);
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
||||
public EnumFacing[] getNormalizedDirs(EnumFacing normal) {
|
||||
if (normal == NORMAL) {
|
||||
return dirs;
|
||||
} else if (normal == NORMAL.getOpposite()) {
|
||||
// If this is the opposite direction of the default normal, we
|
||||
// need to mirror the dirs
|
||||
// A mirror version does not affect y+ and y- so we ignore those
|
||||
EnumFacing[] ret = new EnumFacing[dirs.length];
|
||||
for (int i = 0; i < ret.length; i++) {
|
||||
ret[i] = dirs[i].getFrontOffsetY() != 0 ? dirs[i] : dirs[i].getOpposite();
|
||||
}
|
||||
return ret;
|
||||
} else {
|
||||
EnumFacing axis = null;
|
||||
// Next, we need different a different rotation axis depending
|
||||
// on if this is up/down or not
|
||||
if (normal.getFrontOffsetY() == 0) {
|
||||
// If it is not up/down, pick either the left or right-hand
|
||||
// rotation
|
||||
axis = normal == NORMAL.rotateY() ? UP : DOWN;
|
||||
} else {
|
||||
// If it is up/down, pick either the up or down rotation.
|
||||
axis = normal == UP ? NORMAL.rotateYCCW() : NORMAL.rotateY();
|
||||
}
|
||||
EnumFacing[] ret = new EnumFacing[dirs.length];
|
||||
// Finally apply all the rotations
|
||||
for (int i = 0; i < ret.length; i++) {
|
||||
ret[i] = rotate(dirs[i], axis);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
// God why
|
||||
|
||||
private static final int[] FACING_LOOKUP = new int[EnumFacing.values().length];
|
||||
static {
|
||||
FACING_LOOKUP[NORTH.ordinal()] = 1;
|
||||
FACING_LOOKUP[EAST.ordinal()] = 2;
|
||||
FACING_LOOKUP[SOUTH.ordinal()] = 3;
|
||||
FACING_LOOKUP[WEST.ordinal()] = 4;
|
||||
FACING_LOOKUP[UP.ordinal()] = 5;
|
||||
FACING_LOOKUP[DOWN.ordinal()] = 6;
|
||||
}
|
||||
|
||||
private EnumFacing rotate(EnumFacing facing, EnumFacing axisFacing) {
|
||||
Axis axis = axisFacing.getAxis();
|
||||
AxisDirection axisDir = axisFacing.getAxisDirection();
|
||||
|
||||
if (axisDir == AxisDirection.POSITIVE) {
|
||||
return facing.rotateAround(axis);
|
||||
}
|
||||
|
||||
if (facing.getAxis() != axis) {
|
||||
switch (axis) {
|
||||
case X:
|
||||
// I did some manual testing and this is what worked...I don't get it either
|
||||
switch (FACING_LOOKUP[facing.ordinal()]) {
|
||||
case 1:
|
||||
return NORTH;
|
||||
case 2:
|
||||
case 4:
|
||||
default:
|
||||
return facing; // Invalid but ignored
|
||||
case 3:
|
||||
return SOUTH;
|
||||
case 5:
|
||||
return SOUTH;
|
||||
case 6:
|
||||
return NORTH;
|
||||
}
|
||||
case Y:
|
||||
return facing.rotateYCCW();
|
||||
case Z:
|
||||
switch (FACING_LOOKUP[facing.ordinal()]) {
|
||||
case 2:
|
||||
return EAST;
|
||||
case 3:
|
||||
default:
|
||||
return facing; // invalid but ignored
|
||||
case 4:
|
||||
return WEST;
|
||||
case 5:
|
||||
return DOWN;
|
||||
case 6:
|
||||
return UP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return facing;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package mekanism.client.render.ctm;
|
||||
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
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, EnumFacing side);
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package mekanism.client.render.ctm;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
|
||||
public interface ISubmap {
|
||||
|
||||
float getYOffset();
|
||||
|
||||
float getXOffset();
|
||||
|
||||
float getWidth();
|
||||
|
||||
float getHeight();
|
||||
|
||||
float getInterpolatedU(TextureAtlasSprite sprite, float u);
|
||||
|
||||
float getInterpolatedV(TextureAtlasSprite sprite, float v);
|
||||
|
||||
float[] toArray();
|
||||
|
||||
ISubmap normalize();
|
||||
|
||||
ISubmap relativize();
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package mekanism.client.render.ctm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
public class ModelCTM implements IModel
|
||||
{
|
||||
private Map<EnumFacing, String> overrides = Maps.newHashMap();
|
||||
|
||||
private transient TextureCTM faceObj;
|
||||
private transient Map<EnumFacing, TextureCTM> overridesObj = new EnumMap<>(EnumFacing.class);
|
||||
|
||||
private transient IBakedModel modelObj;
|
||||
|
||||
private transient List<ResourceLocation> textures = Lists.newArrayList();
|
||||
|
||||
public String modelName;
|
||||
|
||||
public ModelCTM(IBakedModel model, String name)
|
||||
{
|
||||
modelObj = model;
|
||||
modelName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return new ArrayList<ResourceLocation>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
{
|
||||
return ImmutableList.copyOf(textures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelState getDefaultState()
|
||||
{
|
||||
return TRSRTransformation.identity();
|
||||
}
|
||||
|
||||
void load()
|
||||
{
|
||||
if(faceObj != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
faceObj = CTMRegistry.textureCache.get(modelName);
|
||||
textures.addAll(faceObj.getTextures());
|
||||
overridesObj.values().forEach(t -> textures.addAll(t.getTextures()));
|
||||
}
|
||||
|
||||
public TextureCTM getDefaultFace()
|
||||
{
|
||||
return faceObj;
|
||||
}
|
||||
|
||||
public TextureCTM getFace(EnumFacing facing)
|
||||
{
|
||||
return overridesObj.getOrDefault(facing, faceObj);
|
||||
}
|
||||
|
||||
public IBakedModel getModel(IBlockState state)
|
||||
{
|
||||
return modelObj;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package mekanism.client.render.ctm;
|
||||
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
|
||||
/**
|
||||
* Block Property for the render context list
|
||||
*/
|
||||
public class PropertyCTMRenderContext implements IUnlistedProperty<CTMBlockRenderContext>
|
||||
{
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "connections";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(CTMBlockRenderContext value)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<CTMBlockRenderContext> getType()
|
||||
{
|
||||
return CTMBlockRenderContext.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String valueToString(CTMBlockRenderContext value)
|
||||
{
|
||||
return value.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,548 +0,0 @@
|
||||
package mekanism.client.render.ctm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement.EnumUsage;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.client.model.pipeline.IVertexConsumer;
|
||||
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.lwjgl.util.vector.Vector;
|
||||
import org.lwjgl.util.vector.Vector2f;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.MultimapBuilder;
|
||||
|
||||
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);
|
||||
|
||||
public static class Vertex
|
||||
{
|
||||
Vector3f pos;
|
||||
Vector2f uvs;
|
||||
}
|
||||
|
||||
private static final TextureAtlasSprite BASE = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(TextureMap.LOCATION_MISSING_TEXTURE.toString());
|
||||
|
||||
public class UVs
|
||||
{
|
||||
private float minU, minV, maxU, maxV;
|
||||
|
||||
private final TextureAtlasSprite sprite;
|
||||
|
||||
private final Vector2f[] data;
|
||||
|
||||
private UVs(Vector2f... data)
|
||||
{
|
||||
this(BASE, data);
|
||||
}
|
||||
|
||||
private UVs(TextureAtlasSprite sprite, Vector2f... data)
|
||||
{
|
||||
this.data = data;
|
||||
this.sprite = sprite;
|
||||
|
||||
float minU = Float.MAX_VALUE;
|
||||
float minV = Float.MAX_VALUE;
|
||||
float maxU = 0, maxV = 0;
|
||||
|
||||
for (Vector2f v : data)
|
||||
{
|
||||
minU = Math.min(minU, v.x);
|
||||
minV = Math.min(minV, v.y);
|
||||
maxU = Math.max(maxU, v.x);
|
||||
maxV = Math.max(maxV, v.y);
|
||||
}
|
||||
|
||||
this.minU = minU;
|
||||
this.minV = minV;
|
||||
this.maxU = maxU;
|
||||
this.maxV = maxV;
|
||||
}
|
||||
|
||||
public UVs(float minU, float minV, float maxU, float maxV, TextureAtlasSprite sprite)
|
||||
{
|
||||
this.minU = minU;
|
||||
this.minV = minV;
|
||||
this.maxU = maxU;
|
||||
this.maxV = maxV;
|
||||
this.sprite = sprite;
|
||||
this.data = vectorize();
|
||||
}
|
||||
|
||||
public UVs transform(TextureAtlasSprite other, ISubmap submap)
|
||||
{
|
||||
UVs normal = normalize();
|
||||
submap = submap.normalize();
|
||||
|
||||
float width = normal.maxU - normal.minU;
|
||||
float height = normal.maxV - normal.minV;
|
||||
|
||||
float minU = submap.getXOffset();
|
||||
float minV = submap.getYOffset();
|
||||
minU += normal.minU * submap.getWidth();
|
||||
minV += normal.minV * submap.getHeight();
|
||||
|
||||
float maxU = minU + (width * submap.getWidth());
|
||||
float maxV = minV + (height * submap.getHeight());
|
||||
|
||||
// TODO this is horrid
|
||||
return new UVs(other,
|
||||
new Vector2f(data[0].x == this.minU ? minU : maxU, data[0].y == this.minV ? minV : maxV),
|
||||
new Vector2f(data[1].x == this.minU ? minU : maxU, data[1].y == this.minV ? minV : maxV),
|
||||
new Vector2f(data[2].x == this.minU ? minU : maxU, data[2].y == this.minV ? minV : maxV),
|
||||
new Vector2f(data[3].x == this.minU ? minU : maxU, data[3].y == this.minV ? minV : maxV))
|
||||
.relativize();
|
||||
}
|
||||
|
||||
public UVs normalizeQuadrant()
|
||||
{
|
||||
UVs normal = normalize();
|
||||
|
||||
int quadrant = normal.getQuadrant();
|
||||
float minUInterp = quadrant == 1 || quadrant == 2 ? 0.5f : 0;
|
||||
float minVInterp = quadrant < 2 ? 0.5f : 0;
|
||||
float maxUInterp = quadrant == 0 || quadrant == 3 ? 0.5f : 1;
|
||||
float maxVInterp = quadrant > 1 ? 0.5f : 1;
|
||||
|
||||
normal = new UVs(sprite, normalize(new Vector2f(minUInterp, minVInterp), new Vector2f(maxUInterp, maxVInterp), normal.vectorize()));
|
||||
return normal.relativize();
|
||||
}
|
||||
|
||||
public UVs normalize()
|
||||
{
|
||||
Vector2f min = new Vector2f(sprite.getMinU(), sprite.getMinV());
|
||||
Vector2f max = new Vector2f(sprite.getMaxU(), sprite.getMaxV());
|
||||
return new UVs(sprite, normalize(min, max, data));
|
||||
}
|
||||
|
||||
public UVs relativize()
|
||||
{
|
||||
return relativize(sprite);
|
||||
}
|
||||
|
||||
public TextureAtlasSprite getSprite()
|
||||
{
|
||||
return sprite;
|
||||
}
|
||||
|
||||
public UVs relativize(TextureAtlasSprite sprite)
|
||||
{
|
||||
Vector2f min = new Vector2f(sprite.getMinU(), sprite.getMinV());
|
||||
Vector2f max = new Vector2f(sprite.getMaxU(), sprite.getMaxV());
|
||||
return new UVs(sprite, lerp(min, max, data));
|
||||
}
|
||||
|
||||
public Vector2f[] vectorize()
|
||||
{
|
||||
return data == null ? new Vector2f[]{ new Vector2f(minU, minV), new Vector2f(minU, maxV), new Vector2f(maxU, maxV), new Vector2f(maxU, minV) } : data;
|
||||
}
|
||||
|
||||
private Vector2f[] normalize(Vector2f min, Vector2f max, Vector2f... vecs)
|
||||
{
|
||||
Vector2f[] ret = new Vector2f[vecs.length];
|
||||
|
||||
for(int i = 0; i < ret.length; i++)
|
||||
{
|
||||
ret[i] = normalize(min, max, vecs[i]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private Vector2f normalize(Vector2f min, Vector2f max, Vector2f vec)
|
||||
{
|
||||
return new Vector2f(Quad.normalize(min.x, max.x, vec.x), Quad.normalize(min.y, max.y, vec.y));
|
||||
}
|
||||
|
||||
private Vector2f[] lerp(Vector2f min, Vector2f max, Vector2f... vecs)
|
||||
{
|
||||
Vector2f[] ret = new Vector2f[vecs.length];
|
||||
|
||||
for(int i = 0; i < ret.length; i++)
|
||||
{
|
||||
ret[i] = lerp(min, max, vecs[i]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private Vector2f lerp(Vector2f min, Vector2f max, Vector2f vec)
|
||||
{
|
||||
return new Vector2f(Quad.lerp(min.x, max.x, vec.x), Quad.lerp(min.y, max.y, vec.y));
|
||||
}
|
||||
|
||||
public int getQuadrant()
|
||||
{
|
||||
if(maxU <= 0.5f)
|
||||
{
|
||||
if(maxV <= 0.5f)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(maxV <= 0.5f)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final Vector3f[] vertPos;
|
||||
private final Vector2f[] vertUv;
|
||||
|
||||
// Technically nonfinal, but treated as such except in constructor
|
||||
private UVs uvsObj;
|
||||
|
||||
private final Builder builder;
|
||||
|
||||
private Quad(Vector3f[] verts, Vector2f[] uvs, Builder b)
|
||||
{
|
||||
vertPos = verts;
|
||||
vertUv = uvs;
|
||||
builder = b;
|
||||
uvsObj = new UVs(uvs);
|
||||
}
|
||||
|
||||
private Quad(Vector3f[] verts, UVs uvs, Builder builder)
|
||||
{
|
||||
this(verts, uvs.vectorize(), builder);
|
||||
uvsObj = new UVs(uvs.getSprite(), vertUv);
|
||||
}
|
||||
|
||||
public UVs getUVs()
|
||||
{
|
||||
return uvsObj;
|
||||
}
|
||||
|
||||
public Quad[] subdivide(int count)
|
||||
{
|
||||
List<Quad> rects = Lists.newArrayList();
|
||||
|
||||
Pair<Quad, Quad> firstDivide = divide(false);
|
||||
Pair<Quad, Quad> secondDivide = firstDivide.getLeft().divide(true);
|
||||
rects.add(secondDivide.getLeft());
|
||||
|
||||
if(firstDivide.getRight() != null)
|
||||
{
|
||||
Pair<Quad, Quad> thirdDivide = firstDivide.getRight().divide(true);
|
||||
rects.add(thirdDivide.getLeft());
|
||||
rects.add(thirdDivide.getRight());
|
||||
}
|
||||
else {
|
||||
rects.add(null);
|
||||
rects.add(null);
|
||||
}
|
||||
|
||||
rects.add(secondDivide.getRight());
|
||||
|
||||
return rects.toArray(new Quad[rects.size()]);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Pair<Quad, Quad> divide(boolean vertical)
|
||||
{
|
||||
float min, max;
|
||||
UVs uvs = uvsObj.normalize();
|
||||
|
||||
if(vertical)
|
||||
{
|
||||
min = uvs.minV;
|
||||
max = uvs.maxV;
|
||||
}
|
||||
else {
|
||||
min = uvs.minU;
|
||||
max = uvs.maxU;
|
||||
}
|
||||
|
||||
if(min < 0.5 && max > 0.5)
|
||||
{
|
||||
UVs first = new UVs(vertical ? uvs.minU : 0.5f, vertical ? 0.5f : uvs.minV, uvs.maxU, uvs.maxV, uvs.getSprite());
|
||||
UVs second = new UVs(uvs.minU, uvs.minV, vertical ? uvs.maxU : 0.5f, vertical ? 0.5f : uvs.maxV, uvs.getSprite());
|
||||
|
||||
int firstIndex = 0;
|
||||
|
||||
for(int i = 0; i < vertUv.length; i++)
|
||||
{
|
||||
if(vertUv[i].y == uvsObj.minV && vertUv[i].x == uvsObj.minU)
|
||||
{
|
||||
firstIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
float f = (0.5f - min) / (max - min);
|
||||
|
||||
Vector3f[] firstQuad = new Vector3f[4];
|
||||
Vector3f[] secondQuad = new Vector3f[4];
|
||||
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
int idx = (firstIndex + i) % 4;
|
||||
firstQuad[i] = new Vector3f(vertPos[idx]);
|
||||
secondQuad[i] = new Vector3f(vertPos[idx]);
|
||||
}
|
||||
|
||||
int i1 = 0;
|
||||
int i2 = vertical ? 1 : 3;
|
||||
int j1 = vertical ? 3 : 1;
|
||||
int j2 = 2;
|
||||
|
||||
firstQuad[i1].x = lerp(firstQuad[i1].x, firstQuad[i2].x, f);
|
||||
firstQuad[i1].y = lerp(firstQuad[i1].y, firstQuad[i2].y, f);
|
||||
firstQuad[i1].z = lerp(firstQuad[i1].z, firstQuad[i2].z, f);
|
||||
firstQuad[j1].x = lerp(firstQuad[j1].x, firstQuad[j2].x, f);
|
||||
firstQuad[j1].y = lerp(firstQuad[j1].y, firstQuad[j2].y, f);
|
||||
firstQuad[j1].z = lerp(firstQuad[j1].z, firstQuad[j2].z, f);
|
||||
|
||||
secondQuad[i2].x = lerp(secondQuad[i1].x, secondQuad[i2].x, f);
|
||||
secondQuad[i2].y = lerp(secondQuad[i1].y, secondQuad[i2].y, f);
|
||||
secondQuad[i2].z = lerp(secondQuad[i1].z, secondQuad[i2].z, f);
|
||||
secondQuad[j2].x = lerp(secondQuad[j1].x, secondQuad[j2].x, f);
|
||||
secondQuad[j2].y = lerp(secondQuad[j1].y, secondQuad[j2].y, f);
|
||||
secondQuad[j2].z = lerp(secondQuad[j1].z, secondQuad[j2].z, f);
|
||||
|
||||
Quad q1 = new Quad(firstQuad, first.relativize(), builder);
|
||||
Quad q2 = new Quad(secondQuad, second.relativize(), builder);
|
||||
|
||||
return Pair.of(q1, q2);
|
||||
}
|
||||
else {
|
||||
return Pair.of(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
static float lerp(float a, float b, float f)
|
||||
{
|
||||
float ret = (a * (1 - f)) + (b * f);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static float normalize(float min, float max, float x)
|
||||
{
|
||||
float ret = (x - min) / (max - min);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Quad rotate(int amount)
|
||||
{
|
||||
Vector2f[] uvs = new Vector2f[4];
|
||||
|
||||
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));
|
||||
Vector2f uv;
|
||||
|
||||
switch(amount)
|
||||
{
|
||||
case 1:
|
||||
uv = new Vector2f(normalized.y, 1 - normalized.x);
|
||||
break;
|
||||
case 2:
|
||||
uv = new Vector2f(1 - normalized.x, 1 - normalized.y);
|
||||
break;
|
||||
case 3:
|
||||
uv = new Vector2f(1 - normalized.y, normalized.x);
|
||||
break;
|
||||
default:
|
||||
uv = new Vector2f(normalized.x, normalized.y);
|
||||
break;
|
||||
}
|
||||
|
||||
uvs[i] = uv;
|
||||
}
|
||||
|
||||
for(int i = 0; i < uvs.length; i++)
|
||||
{
|
||||
uvs[i] = new Vector2f(lerp(s.getMinU(), s.getMaxU(), uvs[i].x), lerp(s.getMinV(), s.getMaxV(), uvs[i].y));
|
||||
}
|
||||
|
||||
Quad ret = new Quad(vertPos, uvs, builder);
|
||||
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 <= uvsObj.minU && vertUv[i].y <= uvsObj.minV)
|
||||
{
|
||||
start = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Vector2f[] uvs = new Vector2f[4];
|
||||
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
uvs[i] = vertUv[(i + start) % 4];
|
||||
}
|
||||
|
||||
return new Quad(vertPos, uvs, builder);
|
||||
}
|
||||
|
||||
public BakedQuad rebake()
|
||||
{
|
||||
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(this.builder.vertexFormat);
|
||||
builder.setQuadOrientation(this.builder.quadOrientation);
|
||||
builder.setQuadTint(this.builder.quadTint);
|
||||
builder.setApplyDiffuseLighting(this.builder.applyDiffuseLighting);
|
||||
builder.setTexture(this.uvsObj.getSprite());
|
||||
|
||||
for(int v = 0; v < 4; v++)
|
||||
{
|
||||
for(int i = 0; i < this.builder.vertexFormat.getElementCount(); i++)
|
||||
{
|
||||
VertexFormatElement ele = this.builder.vertexFormat.getElement(i);
|
||||
|
||||
switch(ele.getUsage())
|
||||
{
|
||||
case UV:
|
||||
Vector2f uv = vertUv[v];
|
||||
builder.put(i, uv.x, uv.y, 0, 1);
|
||||
|
||||
break;
|
||||
case POSITION:
|
||||
Vector3f p = vertPos[v];
|
||||
builder.put(i, p.x, p.y, p.z, 1);
|
||||
|
||||
break;
|
||||
default:
|
||||
builder.put(i, this.builder.vertexData.get(ele.getUsage()).get(v));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public Quad transformUVs(TextureAtlasSprite sprite)
|
||||
{
|
||||
return transformUVs(sprite, CTM.FULL_TEXTURE.normalize());
|
||||
}
|
||||
|
||||
public Quad transformUVs(TextureAtlasSprite sprite, ISubmap submap)
|
||||
{
|
||||
return new Quad(vertPos, uvsObj.transform(sprite, submap), builder);
|
||||
}
|
||||
|
||||
public Quad grow()
|
||||
{
|
||||
return new Quad(vertPos, uvsObj.normalizeQuadrant(), builder);
|
||||
}
|
||||
|
||||
public static Quad from(BakedQuad baked, VertexFormat fmt)
|
||||
{
|
||||
Builder b = new Builder(fmt);
|
||||
baked.pipe(b);
|
||||
return b.build().derotate(); // for now we will ignore rotated UVs
|
||||
}
|
||||
|
||||
public static class Builder implements IVertexConsumer
|
||||
{
|
||||
public Builder(VertexFormat fmt)
|
||||
{
|
||||
vertexFormat = fmt;
|
||||
}
|
||||
|
||||
private final VertexFormat vertexFormat;
|
||||
|
||||
private int quadTint;
|
||||
|
||||
private EnumFacing quadOrientation;
|
||||
|
||||
private boolean applyDiffuseLighting;
|
||||
|
||||
@Override
|
||||
public void setTexture(TextureAtlasSprite sprite)
|
||||
{
|
||||
//TODO ignore for now
|
||||
}
|
||||
|
||||
@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 setApplyDiffuseLighting(boolean lighting)
|
||||
{
|
||||
applyDiffuseLighting = lighting;
|
||||
}
|
||||
|
||||
private ListMultimap<EnumUsage, float[]> vertexData = MultimapBuilder.enumKeys(EnumUsage.class).arrayListValues().build();
|
||||
|
||||
@Override
|
||||
public void put(int element, float... data)
|
||||
{
|
||||
float[] copy = new float[data.length];
|
||||
System.arraycopy(data, 0, copy, 0, data.length);
|
||||
VertexFormatElement ele = vertexFormat.getElement(element);
|
||||
vertexData.put(ele.getUsage(), copy);
|
||||
}
|
||||
|
||||
public Quad build()
|
||||
{
|
||||
Vector3f[] verts = fromData(vertexData.get(EnumUsage.POSITION), 3);
|
||||
Vector2f[] uvs = fromData(vertexData.get(EnumUsage.UV), 2);
|
||||
|
||||
return new Quad(verts, uvs, this);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends Vector> T[] fromData(List<float[]> data, int size)
|
||||
{
|
||||
Vector[] ret = size == 2 ? new Vector2f[data.size()] : new Vector3f[data.size()];
|
||||
|
||||
for(int i = 0; i < data.size(); i++)
|
||||
{
|
||||
ret[i] = size == 2 ? new Vector2f(data.get(i)[0], data.get(i)[1]) : new Vector3f(data.get(i)[0], data.get(i)[1], data.get(i)[2]);
|
||||
}
|
||||
|
||||
return (T[])ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
package mekanism.client.render.ctm;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
|
||||
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) {
|
||||
return sprite.getInterpolatedU(getXOffset() + u / getWidth());
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getInterpolatedV(TextureAtlasSprite sprite, float v) {
|
||||
return sprite.getInterpolatedV(getYOffset() + v / getWidth());
|
||||
}
|
||||
|
||||
@Override
|
||||
public float[] toArray() {
|
||||
return new float[] { getXOffset(), getYOffset(), getXOffset() + getWidth(), getYOffset() + getHeight() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubmapNormalized normalize() {
|
||||
return normalized;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISubmap relativize() {
|
||||
return this;
|
||||
}
|
||||
|
||||
private static final float FACTOR = 16f;
|
||||
|
||||
private static class SubmapNormalized implements ISubmap
|
||||
{
|
||||
private final ISubmap parent;
|
||||
|
||||
public SubmapNormalized(ISubmap submap)
|
||||
{
|
||||
parent = submap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getXOffset() {
|
||||
return parent.getXOffset() / FACTOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getYOffset() {
|
||||
return parent.getYOffset() / FACTOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWidth() {
|
||||
return parent.getWidth() / FACTOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHeight() {
|
||||
return parent.getHeight() / FACTOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISubmap relativize() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISubmap normalize() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getInterpolatedU(TextureAtlasSprite sprite, float u) {
|
||||
return parent.getInterpolatedU(sprite, u);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getInterpolatedV(TextureAtlasSprite sprite, float v) {
|
||||
return parent.getInterpolatedV(sprite, v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float[] toArray() {
|
||||
return parent.toArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package mekanism.client.render.ctm;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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.BlockRenderLayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class TextureCTM
|
||||
{
|
||||
public TextureSpriteCallback[] sprites;
|
||||
|
||||
public TextureCTM(TextureSpriteCallback[] sprites)
|
||||
{
|
||||
this.sprites = sprites;
|
||||
}
|
||||
|
||||
public List<BakedQuad> transformQuad(BakedQuad bq, CTMBlockRenderContext context, int quadGoal)
|
||||
{
|
||||
Quad quad = Quad.from(bq, DefaultVertexFormats.ITEM);
|
||||
|
||||
if(context == null)
|
||||
{
|
||||
return Collections.singletonList(quad.transformUVs(sprites[0].getSprite()).rebake());
|
||||
}
|
||||
|
||||
Quad[] quads = quad.subdivide(4);
|
||||
|
||||
int[] ctm = ((CTMBlockRenderContext)context).getCTM(bq.getFace()).getSubmapIndices();
|
||||
|
||||
for(int i = 0; i < quads.length; i++)
|
||||
{
|
||||
Quad q = quads[i];
|
||||
|
||||
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()
|
||||
{
|
||||
return sprites[0].getSprite();
|
||||
}
|
||||
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
{
|
||||
return Arrays.stream(sprites).map(TextureSpriteCallback::getLocation).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package mekanism.client.render.ctm;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
/**
|
||||
* Callback when textures are stitched
|
||||
*/
|
||||
public class TextureSpriteCallback
|
||||
{
|
||||
private ResourceLocation location;
|
||||
private TextureAtlasSprite sprite;
|
||||
|
||||
public TextureSpriteCallback(ResourceLocation loc)
|
||||
{
|
||||
location = loc;
|
||||
}
|
||||
|
||||
public void stitch(TextureMap map)
|
||||
{
|
||||
sprite = map.registerSprite(location);
|
||||
}
|
||||
|
||||
public TextureAtlasSprite getSprite()
|
||||
{
|
||||
return sprite;
|
||||
}
|
||||
|
||||
public ResourceLocation getLocation()
|
||||
{
|
||||
return location;
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,12 @@ package mekanism.client.render.item;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import mekanism.api.energy.IEnergizedItem;
|
||||
import mekanism.client.model.ModelArmoredJetpack;
|
||||
import mekanism.client.model.ModelAtomicDisassembler;
|
||||
@@ -23,7 +26,6 @@ import mekanism.client.model.ModelSecurityDesk;
|
||||
import mekanism.client.model.ModelSeismicVibrator;
|
||||
import mekanism.client.model.ModelSolarNeutronActivator;
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.client.render.ctm.CTMModelFactory;
|
||||
import mekanism.client.render.tileentity.RenderBin;
|
||||
import mekanism.client.render.tileentity.RenderEnergyCube;
|
||||
import mekanism.client.render.tileentity.RenderFluidTank;
|
||||
@@ -63,6 +65,7 @@ import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -503,15 +506,37 @@ public class BakedCustomItemModel implements IBakedModel
|
||||
{
|
||||
return baseModel.getItemCameraTransforms();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType)
|
||||
{
|
||||
prevTransform = cameraTransformType;
|
||||
|
||||
return Pair.of(this, CTMModelFactory.transforms.get(cameraTransformType).getMatrix());
|
||||
|
||||
return Pair.of(this, transforms.get(cameraTransformType).getMatrix());
|
||||
}
|
||||
|
||||
// Copy from old CTM
|
||||
public static Map<TransformType, TRSRTransformation> transforms = ImmutableMap.<TransformType, TRSRTransformation>builder()
|
||||
.put(TransformType.GUI, get(0, 0, 0, 30, 225, 0, 0.625f))
|
||||
.put(TransformType.THIRD_PERSON_RIGHT_HAND, get(0, 2.5f, 0, 75, 45, 0, 0.375f))
|
||||
.put(TransformType.THIRD_PERSON_LEFT_HAND, get(0, 2.5f, 0, 75, 45, 0, 0.375f))
|
||||
.put(TransformType.FIRST_PERSON_RIGHT_HAND, get(0, 0, 0, 0, 45, 0, 0.4f))
|
||||
.put(TransformType.FIRST_PERSON_LEFT_HAND, get(0, 0, 0, 0, 225, 0, 0.4f))
|
||||
.put(TransformType.GROUND, get(0, 2, 0, 0, 0, 0, 0.25f))
|
||||
.put(TransformType.HEAD, get(0, 0, 0, 0, 0, 0, 1))
|
||||
.put(TransformType.FIXED, get(0, 0, 0, 0, 0, 0, 1))
|
||||
.put(TransformType.NONE, get(0, 0, 0, 0, 0, 0, 0))
|
||||
.build();
|
||||
|
||||
private static TRSRTransformation get(float tx, float ty, float tz, float ax, float ay, float az, float s)
|
||||
{
|
||||
return new TRSRTransformation(
|
||||
new Vector3f(tx / 16, ty / 16, tz / 16),
|
||||
TRSRTransformation.quatFromXYZDegrees(new Vector3f(ax, ay, az)),
|
||||
new Vector3f(s, s, s),
|
||||
null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
|
||||
@@ -5,9 +5,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.client.render.ctm.CTMModelFactory;
|
||||
import mekanism.common.block.property.PropertyColor;
|
||||
import mekanism.common.tile.TileEntityGlowPanel;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@@ -29,8 +29,8 @@ import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.obj.OBJModel;
|
||||
import net.minecraftforge.client.model.obj.OBJModel.Face;
|
||||
import net.minecraftforge.client.model.obj.OBJModel.OBJBakedModel;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -41,8 +41,8 @@ import com.google.common.collect.Lists;
|
||||
|
||||
public class GlowPanelModel extends OBJBakedModelBase
|
||||
{
|
||||
private static Map<Integer, List<BakedQuad>> glowPanelCache = new HashMap<Integer, List<BakedQuad>>();
|
||||
private static Map<Integer, GlowPanelModel> glowPanelItemCache = new HashMap<Integer, GlowPanelModel>();
|
||||
private static Map<Integer, List<BakedQuad>> glowPanelCache = new HashMap<>();
|
||||
private static Map<Integer, GlowPanelModel> glowPanelItemCache = new HashMap<>();
|
||||
|
||||
private IBlockState tempState;
|
||||
private ItemStack tempStack;
|
||||
@@ -163,8 +163,6 @@ public class GlowPanelModel extends OBJBakedModelBase
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Pair<IBakedModel, Matrix4f> thirdPersonTransform;
|
||||
|
||||
@Override
|
||||
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType transformType)
|
||||
@@ -172,7 +170,7 @@ public class GlowPanelModel extends OBJBakedModelBase
|
||||
if(transformType == TransformType.GUI)
|
||||
{
|
||||
GlStateManager.rotate(180, 1, 0, 0);
|
||||
ForgeHooksClient.multiplyCurrentGlMatrix(CTMModelFactory.transforms.get(transformType).getMatrix());
|
||||
ForgeHooksClient.multiplyCurrentGlMatrix(transforms.get(transformType).getMatrix());
|
||||
GlStateManager.translate(0.65F, 0.45F, 0.0F);
|
||||
GlStateManager.rotate(90, 1, 0, 0);
|
||||
GlStateManager.scale(1.6F, 1.6F, 1.6F);
|
||||
@@ -185,12 +183,34 @@ public class GlowPanelModel extends OBJBakedModelBase
|
||||
}
|
||||
else if(transformType == TransformType.THIRD_PERSON_RIGHT_HAND || transformType == TransformType.THIRD_PERSON_LEFT_HAND)
|
||||
{
|
||||
ForgeHooksClient.multiplyCurrentGlMatrix(CTMModelFactory.transforms.get(transformType).getMatrix());
|
||||
ForgeHooksClient.multiplyCurrentGlMatrix(transforms.get(transformType).getMatrix());
|
||||
GlStateManager.translate(0.0F, 0.3F, 0.2F);
|
||||
|
||||
return Pair.of(this, null);
|
||||
}
|
||||
|
||||
return Pair.of(this, CTMModelFactory.transforms.get(transformType).getMatrix());
|
||||
return Pair.of(this, transforms.get(transformType).getMatrix());
|
||||
}
|
||||
|
||||
// Copy from old CTM
|
||||
public static Map<TransformType, TRSRTransformation> transforms = ImmutableMap.<TransformType, TRSRTransformation>builder()
|
||||
.put(TransformType.GUI, get(0, 0, 0, 30, 225, 0, 0.625f))
|
||||
.put(TransformType.THIRD_PERSON_RIGHT_HAND, get(0, 2.5f, 0, 75, 45, 0, 0.375f))
|
||||
.put(TransformType.THIRD_PERSON_LEFT_HAND, get(0, 2.5f, 0, 75, 45, 0, 0.375f))
|
||||
.put(TransformType.FIRST_PERSON_RIGHT_HAND, get(0, 0, 0, 0, 45, 0, 0.4f))
|
||||
.put(TransformType.FIRST_PERSON_LEFT_HAND, get(0, 0, 0, 0, 225, 0, 0.4f))
|
||||
.put(TransformType.GROUND, get(0, 2, 0, 0, 0, 0, 0.25f))
|
||||
.put(TransformType.HEAD, get(0, 0, 0, 0, 0, 0, 1))
|
||||
.put(TransformType.FIXED, get(0, 0, 0, 0, 0, 0, 1))
|
||||
.put(TransformType.NONE, get(0, 0, 0, 0, 0, 0, 0))
|
||||
.build();
|
||||
|
||||
private static TRSRTransformation get(float tx, float ty, float tz, float ax, float ay, float az, float s)
|
||||
{
|
||||
return new TRSRTransformation(
|
||||
new Vector3f(tx / 16, ty / 16, tz / 16),
|
||||
TRSRTransformation.quatFromXYZDegrees(new Vector3f(ax, ay, az)),
|
||||
new Vector3f(s, s, s),
|
||||
null);
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,8 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
import mekanism.client.render.ctm.CTMModelFactory;
|
||||
import mekanism.common.block.property.PropertyColor;
|
||||
import mekanism.common.block.property.PropertyConnection;
|
||||
import mekanism.common.config.MekanismConfig.client;
|
||||
@@ -39,6 +39,7 @@ import net.minecraftforge.client.model.obj.OBJModel.Group;
|
||||
import net.minecraftforge.client.model.obj.OBJModel.OBJProperty;
|
||||
import net.minecraftforge.client.model.obj.OBJModel.OBJState;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -49,9 +50,9 @@ import com.google.common.collect.Lists;
|
||||
|
||||
public class TransmitterModel extends OBJBakedModelBase
|
||||
{
|
||||
private static Set<TransmitterModel> modelInstances = new HashSet<TransmitterModel>();
|
||||
private static Set<TransmitterModel> modelInstances = new HashSet<>();
|
||||
|
||||
private Map<Integer, List<BakedQuad>> modelCache = new HashMap<Integer, List<BakedQuad>>();
|
||||
private Map<Integer, List<BakedQuad>> modelCache = new HashMap<>();
|
||||
private TransmitterModel itemCache;
|
||||
|
||||
private IBlockState tempState;
|
||||
@@ -83,7 +84,7 @@ public class TransmitterModel extends OBJBakedModelBase
|
||||
{
|
||||
if(itemCache == null)
|
||||
{
|
||||
List<String> visible = new ArrayList<String>();
|
||||
List<String> visible = new ArrayList<>();
|
||||
|
||||
for(EnumFacing side : EnumFacing.values())
|
||||
{
|
||||
@@ -270,8 +271,30 @@ public class TransmitterModel extends OBJBakedModelBase
|
||||
@Override
|
||||
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType)
|
||||
{
|
||||
return Pair.of(this, CTMModelFactory.transforms.get(cameraTransformType).getMatrix());
|
||||
return Pair.of(this, transforms.get(cameraTransformType).getMatrix());
|
||||
}
|
||||
|
||||
// Copy from old CTM
|
||||
public static Map<TransformType, TRSRTransformation> transforms = ImmutableMap.<TransformType, TRSRTransformation>builder()
|
||||
.put(TransformType.GUI, get(0, 0, 0, 30, 225, 0, 0.625f))
|
||||
.put(TransformType.THIRD_PERSON_RIGHT_HAND, get(0, 2.5f, 0, 75, 45, 0, 0.375f))
|
||||
.put(TransformType.THIRD_PERSON_LEFT_HAND, get(0, 2.5f, 0, 75, 45, 0, 0.375f))
|
||||
.put(TransformType.FIRST_PERSON_RIGHT_HAND, get(0, 0, 0, 0, 45, 0, 0.4f))
|
||||
.put(TransformType.FIRST_PERSON_LEFT_HAND, get(0, 0, 0, 0, 225, 0, 0.4f))
|
||||
.put(TransformType.GROUND, get(0, 2, 0, 0, 0, 0, 0.25f))
|
||||
.put(TransformType.HEAD, get(0, 0, 0, 0, 0, 0, 1))
|
||||
.put(TransformType.FIXED, get(0, 0, 0, 0, 0, 0, 1))
|
||||
.put(TransformType.NONE, get(0, 0, 0, 0, 0, 0, 0))
|
||||
.build();
|
||||
|
||||
private static TRSRTransformation get(float tx, float ty, float tz, float ax, float ay, float az, float s)
|
||||
{
|
||||
return new TRSRTransformation(
|
||||
new Vector3f(tx / 16, ty / 16, tz / 16),
|
||||
TRSRTransformation.quatFromXYZDegrees(new Vector3f(ax, ay, az)),
|
||||
new Vector3f(s, s, s),
|
||||
null);
|
||||
}
|
||||
|
||||
public static void registerIcons(TextureMap map)
|
||||
{
|
||||
|
||||
+77
-98
@@ -19,37 +19,67 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import java.util.Arrays;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderThermalEvaporationController extends TileEntitySpecialRenderer<TileEntityThermalEvaporationController>
|
||||
{
|
||||
private static Map<SalinationRenderData, HashMap<Fluid, DisplayInteger[]>> cachedCenterFluids = new HashMap<SalinationRenderData, HashMap<Fluid, DisplayInteger[]>>();
|
||||
private static HashMap<Fluid, DisplayInteger[]> cachedCenterFluids = new HashMap<Fluid, DisplayInteger[]>();
|
||||
private static final int LEVELS = 16;
|
||||
private static final int ALL_LEVELS = LEVELS + 2;
|
||||
private static final int RING_INDEX = ALL_LEVELS-2;
|
||||
private static final int CONCAVE_INDEX = ALL_LEVELS-1;
|
||||
|
||||
@Override
|
||||
public void render(TileEntityThermalEvaporationController tileEntity, double x, double y, double z, float partialTick, int destroyStage, float alpha)
|
||||
{
|
||||
if(tileEntity.structured && tileEntity.inputTank.getFluid() != null)
|
||||
{
|
||||
SalinationRenderData data = new SalinationRenderData();
|
||||
|
||||
data.height = tileEntity.height-2;
|
||||
data.side = tileEntity.facing;
|
||||
|
||||
bindTexture(MekanismRenderer.getBlocksTexture());
|
||||
|
||||
if(data.height >= 1 && tileEntity.inputTank.getCapacity() > 0)
|
||||
if(tileEntity.height-2 >= 1 && tileEntity.inputTank.getCapacity() > 0)
|
||||
{
|
||||
push();
|
||||
|
||||
FluidRenderer.translateToOrigin(tileEntity.getRenderLocation());
|
||||
|
||||
MekanismRenderer.glowOn(tileEntity.inputTank.getFluid().getFluid().getLuminosity());
|
||||
DisplayInteger[] displayList = getListAndRender(tileEntity.inputTank.getFluid().getFluid());
|
||||
|
||||
DisplayInteger[] displayList = getListAndRender(data, tileEntity.inputTank.getFluid().getFluid());
|
||||
float levels = Math.min(((float)tileEntity.inputTank.getFluidAmount()/tileEntity.inputTank.getCapacity()), 1);
|
||||
levels *= (tileEntity.height-2);
|
||||
|
||||
float tankFillPercentage = Math.min(((float)tileEntity.inputTank.getFluidAmount()/tileEntity.inputTank.getCapacity()), 1);
|
||||
int partialLevels = (int)((levels-(int)levels)*16);
|
||||
|
||||
displayList[(int)(tankFillPercentage * ((float)getStages(data.height)-1))].render();
|
||||
switch(tileEntity.facing)
|
||||
{
|
||||
case SOUTH:
|
||||
GlStateManager.translate(-1, 0, -1);
|
||||
break;
|
||||
case EAST:
|
||||
GlStateManager.translate(-1, 0, 0);
|
||||
break;
|
||||
case WEST:
|
||||
GlStateManager.translate(0, 0, -1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
GlStateManager.translate(0, 0.01, 0);
|
||||
|
||||
if((int)levels>0)
|
||||
{
|
||||
displayList[CONCAVE_INDEX].render();
|
||||
GlStateManager.translate(0, 1, 0);
|
||||
|
||||
for(int i = 1; i < (int)levels; i++)
|
||||
{
|
||||
displayList[RING_INDEX].render();
|
||||
GlStateManager.translate(0, 1, 0);
|
||||
}
|
||||
}
|
||||
displayList[partialLevels].render();
|
||||
|
||||
MekanismRenderer.glowOff();
|
||||
|
||||
@@ -74,118 +104,67 @@ public class RenderThermalEvaporationController extends TileEntitySpecialRendere
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
private DisplayInteger[] getListAndRender(SalinationRenderData data, Fluid fluid)
|
||||
|
||||
private DisplayInteger[] getListAndRender(Fluid fluid)
|
||||
{
|
||||
if(cachedCenterFluids.containsKey(data) && cachedCenterFluids.get(data).containsKey(fluid))
|
||||
if(cachedCenterFluids.containsKey(fluid))
|
||||
{
|
||||
return cachedCenterFluids.get(data).get(fluid);
|
||||
return cachedCenterFluids.get(fluid);
|
||||
}
|
||||
|
||||
Model3D toReturn = new Model3D();
|
||||
toReturn.baseBlock = Blocks.WATER;
|
||||
toReturn.setTexture(MekanismRenderer.getFluidTexture(fluid, FluidType.STILL));
|
||||
DisplayInteger[] displays = new DisplayInteger[ALL_LEVELS];
|
||||
|
||||
final int stages = getStages(data.height);
|
||||
DisplayInteger[] displays = new DisplayInteger[stages];
|
||||
|
||||
if(cachedCenterFluids.containsKey(data))
|
||||
{
|
||||
cachedCenterFluids.get(data).put(fluid, displays);
|
||||
}
|
||||
else {
|
||||
HashMap<Fluid, DisplayInteger[]> map = new HashMap<Fluid, DisplayInteger[]>();
|
||||
map.put(fluid, displays);
|
||||
cachedCenterFluids.put(data, map);
|
||||
}
|
||||
Model3D model = new Model3D();
|
||||
model.baseBlock = fluid.getBlock();
|
||||
model.setTexture(MekanismRenderer.getFluidTexture(fluid, FluidType.STILL));
|
||||
|
||||
MekanismRenderer.colorFluid(fluid);
|
||||
|
||||
for(int i = 0; i < stages; i++)
|
||||
if(fluid.getStill() == null)
|
||||
{
|
||||
displays[i] = DisplayInteger.createAndStart();
|
||||
|
||||
if(fluid.getStill() != null)
|
||||
DisplayInteger empty = DisplayInteger.createAndStart();
|
||||
DisplayInteger.endList();
|
||||
Arrays.fill(displays, 0, LEVELS, empty);
|
||||
}
|
||||
else {
|
||||
model.setSideRender(EnumFacing.DOWN, false);
|
||||
|
||||
for(int i = 0; i < LEVELS; i++)
|
||||
{
|
||||
switch(data.side)
|
||||
{
|
||||
case NORTH:
|
||||
toReturn.minX = 0 + .01;
|
||||
toReturn.minY = 0 + .01;
|
||||
toReturn.minZ = 0 + .01;
|
||||
|
||||
toReturn.maxX = 2 - .01;
|
||||
toReturn.maxY = ((float)i/(float)stages)*data.height - .01;
|
||||
toReturn.maxZ = 2 - .01;
|
||||
break;
|
||||
case SOUTH:
|
||||
toReturn.minX = -1 + .01;
|
||||
toReturn.minY = 0 + .01;
|
||||
toReturn.minZ = -1 + .01;
|
||||
|
||||
toReturn.maxX = 1 - .01;
|
||||
toReturn.maxY = ((float)i/(float)stages)*data.height - .01;
|
||||
toReturn.maxZ = 1 - .01;
|
||||
break;
|
||||
case WEST:
|
||||
toReturn.minX = 0 + .01;
|
||||
toReturn.minY = 0 + .01;
|
||||
toReturn.minZ = -1 + .01;
|
||||
|
||||
toReturn.maxX = 2 - .01;
|
||||
toReturn.maxY = ((float)i/(float)stages)*data.height - .01;
|
||||
toReturn.maxZ = 1 - .01;
|
||||
break;
|
||||
case EAST:
|
||||
toReturn.minX = -1 + .01;
|
||||
toReturn.minY = 0 + .01;
|
||||
toReturn.minZ = 0 + .01;
|
||||
|
||||
toReturn.maxX = 1 - .01;
|
||||
toReturn.maxY = ((float)i/(float)stages)*data.height - .01;
|
||||
toReturn.maxZ = 2 - .01;
|
||||
break;
|
||||
}
|
||||
|
||||
MekanismRenderer.renderObject(toReturn);
|
||||
displays[i] = generateLevel(i, model);
|
||||
}
|
||||
|
||||
displays[i].endList();
|
||||
|
||||
model.setSideRender(EnumFacing.UP, false);
|
||||
displays[RING_INDEX] = generateLevel(LEVELS-1, model);
|
||||
model.setSideRender(EnumFacing.DOWN, true);
|
||||
displays[CONCAVE_INDEX] = generateLevel(LEVELS-1, model);
|
||||
}
|
||||
|
||||
MekanismRenderer.resetColor();
|
||||
|
||||
cachedCenterFluids.put(fluid, displays);
|
||||
|
||||
return displays;
|
||||
}
|
||||
|
||||
private int getStages(int height)
|
||||
private DisplayInteger generateLevel(int height, Model3D model)
|
||||
{
|
||||
return height*(TankUpdateProtocol.FLUID_PER_TANK/10);
|
||||
}
|
||||
DisplayInteger displayInteger = DisplayInteger.createAndStart();
|
||||
|
||||
public static class SalinationRenderData
|
||||
{
|
||||
public int height;
|
||||
public EnumFacing side;
|
||||
model.minX = 0 + .01;
|
||||
model.minY = 0;
|
||||
model.minZ = 0 + .01;
|
||||
model.maxX = 2 - .01;
|
||||
model.maxY = (float)height/(float)(LEVELS-1) + (height==0?.02:0);
|
||||
model.maxZ = 2 - .01;
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int code = 1;
|
||||
code = 31 * code + height;
|
||||
return code;
|
||||
}
|
||||
MekanismRenderer.renderObject(model);
|
||||
DisplayInteger.endList();
|
||||
|
||||
@Override
|
||||
public boolean equals(Object data)
|
||||
{
|
||||
return data instanceof SalinationRenderData && ((SalinationRenderData)data).height == height &&
|
||||
((SalinationRenderData)data).side == side;
|
||||
}
|
||||
return displayInteger;
|
||||
}
|
||||
|
||||
public static void resetDisplayInts()
|
||||
{
|
||||
cachedCenterFluids.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,13 +29,11 @@ import mekanism.client.ClientTickHandler;
|
||||
import mekanism.common.Tier.BaseTier;
|
||||
import mekanism.common.base.IChunkLoadHandler;
|
||||
import mekanism.common.base.IModule;
|
||||
import mekanism.common.block.states.BlockStateMachine.MachineType;
|
||||
import mekanism.common.block.states.BlockStateTransmitter.TransmitterType;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
import mekanism.common.chunkloading.ChunkManager;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.config.MekanismConfig.usage;
|
||||
import mekanism.common.config.TypeConfigManager;
|
||||
import mekanism.common.content.boiler.SynchronizedBoilerData;
|
||||
import mekanism.common.content.entangloporter.InventoryFrequency;
|
||||
import mekanism.common.content.matrix.SynchronizedMatrixData;
|
||||
@@ -132,7 +130,6 @@ import net.minecraftforge.fml.common.Mod.Instance;
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms;
|
||||
import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
@@ -153,7 +150,7 @@ import com.mojang.authlib.GameProfile;
|
||||
* @author AidanBrady
|
||||
*
|
||||
*/
|
||||
@Mod(modid = "mekanism", name = "Mekanism", version = "9.3.3", guiFactory = "mekanism.client.gui.ConfigGuiFactory",
|
||||
@Mod(modid = "mekanism", name = "Mekanism", version = "9.3.4", guiFactory = "mekanism.client.gui.ConfigGuiFactory",
|
||||
dependencies = "required-after:forge@[14.21.0.2373,);" +
|
||||
"after:redstoneflux;" +
|
||||
"after:mcmultipart;" +
|
||||
@@ -189,7 +186,7 @@ public class Mekanism
|
||||
public static Configuration configuration;
|
||||
|
||||
/** Mekanism version number */
|
||||
public static Version versionNumber = new Version(9, 3, 3);
|
||||
public static Version versionNumber = new Version(9, 3, 4);
|
||||
|
||||
/** MultiblockManagers for various structrures */
|
||||
public static MultiblockManager<SynchronizedTankData> tankManager = new MultiblockManager<SynchronizedTankData>("dynamicTank");
|
||||
|
||||
@@ -7,6 +7,7 @@ import mekanism.api.IConfigCardAccess.ISpecialConfigData;
|
||||
import mekanism.api.energy.IStrictEnergyAcceptor;
|
||||
import mekanism.api.energy.IStrictEnergyStorage;
|
||||
import mekanism.common.integration.computer.IComputerIntegration;
|
||||
import mekanism.common.integration.ic2.IC2Integration;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -17,9 +18,9 @@ import net.minecraftforge.fml.common.Optional.Interface;
|
||||
import net.minecraftforge.fml.common.Optional.InterfaceList;
|
||||
|
||||
@InterfaceList({
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2"),
|
||||
@Interface(iface = "cofh.redstoneflux.api.IEnergyProvider", modid = "redstoneflux"),
|
||||
@Interface(iface = "cofh.redstoneflux.api.IEnergyReceiver", modid = "redstoneflux")
|
||||
@Interface(iface = "cofh.redstoneflux.api.IEnergyReceiver", modid = "redstoneflux"),
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = IC2Integration.MODID),
|
||||
})
|
||||
public interface IAdvancedBoundingBlock extends ICapabilityProvider, IBoundingBlock, ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IStrictEnergyStorage, IEnergyReceiver, IEnergyProvider, IComputerIntegration, ISpecialConfigData, ISecurityTile
|
||||
{
|
||||
|
||||
@@ -6,12 +6,10 @@ import cofh.redstoneflux.api.IEnergyReceiver;
|
||||
import ic2.api.energy.tile.IEnergySink;
|
||||
import ic2.api.energy.tile.IEnergySource;
|
||||
import ic2.api.tile.IEnergyStorage;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import mekanism.api.energy.IStrictEnergyAcceptor;
|
||||
import mekanism.api.energy.IStrictEnergyOutputter;
|
||||
import mekanism.api.energy.IStrictEnergyStorage;
|
||||
import mekanism.common.integration.ic2.IC2Integration;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fml.common.Optional.Interface;
|
||||
@@ -20,10 +18,10 @@ import net.minecraftforge.fml.common.Optional.InterfaceList;
|
||||
@InterfaceList({
|
||||
@Interface(iface = "cofh.redstoneflux.api.IEnergyProvider", modid = "redstoneflux"),
|
||||
@Interface(iface = "cofh.redstoneflux.api.IEnergyReceiver", modid = "redstoneflux"),
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2"),
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = "IC2"),
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergyEmitter", modid = "IC2"),
|
||||
@Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2")
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = IC2Integration.MODID),
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = IC2Integration.MODID),
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergyEmitter", modid = IC2Integration.MODID),
|
||||
@Interface(iface = "ic2.api.tile.IEnergyStorage", modid = IC2Integration.MODID)
|
||||
})
|
||||
public interface IEnergyWrapper extends IStrictEnergyStorage, IEnergyReceiver, IEnergyProvider, IEnergySink, IEnergySource, IEnergyStorage, IStrictEnergyAcceptor, IStrictEnergyOutputter, IInventory
|
||||
{
|
||||
|
||||
@@ -6,9 +6,6 @@ import java.util.UUID;
|
||||
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.common.Mekanism;
|
||||
import mekanism.common.Tier.BaseTier;
|
||||
import mekanism.common.base.IActiveState;
|
||||
@@ -18,7 +15,6 @@ 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;
|
||||
@@ -69,7 +65,6 @@ import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
@@ -109,18 +104,14 @@ import buildcraft.api.tools.IToolWrench;
|
||||
* @author AidanBrady
|
||||
*
|
||||
*/
|
||||
public abstract class BlockBasic extends Block implements ICTMBlock
|
||||
public abstract class BlockBasic extends Block
|
||||
{
|
||||
public CTMData[][] ctmData = new CTMData[16][4];
|
||||
|
||||
public BlockBasic()
|
||||
{
|
||||
super(Material.IRON);
|
||||
setHardness(5F);
|
||||
setResistance(20F);
|
||||
setCreativeTab(Mekanism.tabMekanism);
|
||||
|
||||
initCTMs();
|
||||
}
|
||||
|
||||
public static BlockBasic getBlockBasic(BasicBlock block)
|
||||
@@ -207,21 +198,6 @@ public abstract class BlockBasic extends Block implements ICTMBlock
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IBlockState getExtendedState(IBlockState stateIn, IBlockAccess w, BlockPos pos)
|
||||
{
|
||||
if(stateIn.getBlock() == null || stateIn.getMaterial() == Material.AIR)
|
||||
{
|
||||
return stateIn;
|
||||
}
|
||||
|
||||
IExtendedBlockState state = (IExtendedBlockState)stateIn;
|
||||
CTMBlockRenderContext ctx = new CTMBlockRenderContext(w, pos);
|
||||
|
||||
return state.withProperty(BlockStateBasic.ctmProperty, ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos fromPos)
|
||||
@@ -261,40 +237,6 @@ public abstract class BlockBasic extends Block implements ICTMBlock
|
||||
return blockResistance;
|
||||
}
|
||||
|
||||
public void initCTMs()
|
||||
{
|
||||
switch(getBasicBlock())
|
||||
{
|
||||
case BASIC_BLOCK_1:
|
||||
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);
|
||||
|
||||
ctmData[14][0] = 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);
|
||||
|
||||
break;
|
||||
case BASIC_BLOCK_2:
|
||||
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[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[7][0] = new CTMData(BasicBlockType.BOILER_CASING, BasicBlockType.BOILER_VALVE);
|
||||
ctmData[8][0] = new CTMData(BasicBlockType.BOILER_CASING, BasicBlockType.BOILER_VALVE);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(IBlockState state)
|
||||
{
|
||||
@@ -962,12 +904,9 @@ public abstract class BlockBasic extends Block implements ICTMBlock
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldSideBeRendered(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side)
|
||||
{
|
||||
if(BasicBlockType.get(state) == BasicBlockType.STRUCTURAL_GLASS)
|
||||
if(BasicBlockType.get(state) == BasicBlockType.STRUCTURAL_GLASS && BasicBlockType.get(world.getBlockState(pos.offset(side))) == BasicBlockType.STRUCTURAL_GLASS)
|
||||
{
|
||||
if(!ctmData[10][0].shouldRenderSide(world, pos.offset(side), side))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return super.shouldSideBeRendered(state, world, pos, side);
|
||||
@@ -1013,43 +952,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CTMData getCTMData(IBlockState state)
|
||||
{
|
||||
return ctmData[state.getBlock().getMetaFromState(state)][0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverrideTexture(IBlockState state, EnumFacing side)
|
||||
{
|
||||
BasicBlockType type = state.getValue(getTypeProperty());
|
||||
|
||||
if(type == BasicBlockType.INDUCTION_CELL || type == BasicBlockType.INDUCTION_PROVIDER)
|
||||
{
|
||||
return type.getName() + "_" + state.getValue(BlockStateBasic.tierProperty).getName();
|
||||
}
|
||||
|
||||
if(type == BasicBlockType.THERMAL_EVAPORATION_CONTROLLER)
|
||||
{
|
||||
if(side == state.getValue(BlockStateFacing.facingProperty))
|
||||
{
|
||||
return type.getName() + (state.getValue(BlockStateBasic.activeProperty) ? "_on" : "");
|
||||
}
|
||||
else {
|
||||
return "thermal_evaporation_block";
|
||||
}
|
||||
}
|
||||
|
||||
if(type == BasicBlockType.INDUCTION_PORT)
|
||||
{
|
||||
return type.getName() + (state.getValue(BlockStateBasic.activeProperty) ? "_output" : "");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public PropertyEnum<BasicBlockType> getTypeProperty()
|
||||
{
|
||||
return getBasicBlock().getProperty();
|
||||
|
||||
@@ -6,9 +6,6 @@ import java.util.UUID;
|
||||
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.common.Mekanism;
|
||||
import mekanism.common.Tier.FluidTankTier;
|
||||
import mekanism.common.base.IActiveState;
|
||||
@@ -134,10 +131,8 @@ import buildcraft.api.tools.IToolWrench;
|
||||
* @author AidanBrady
|
||||
*
|
||||
*/
|
||||
public abstract class BlockMachine extends BlockContainer implements ICTMBlock
|
||||
public abstract class BlockMachine extends BlockContainer
|
||||
{
|
||||
public CTMData[] ctmData = new CTMData[16];
|
||||
|
||||
private static final AxisAlignedBB CHARGEPAD_BOUNDS = new AxisAlignedBB(0.0F, 0.0F, 0.0F, 1.0F, 0.06F, 1.0F);
|
||||
private static final AxisAlignedBB TANK_BOUNDS = new AxisAlignedBB(0.125F, 0.0F, 0.125F, 0.875F, 1.0F, 0.875F);
|
||||
private static final AxisAlignedBB LASER_BOUNDS = new AxisAlignedBB(0.25F, 0.0F, 0.25F, 0.75F, 1.0F, 0.75F);
|
||||
@@ -149,8 +144,6 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
|
||||
setHardness(3.5F);
|
||||
setResistance(16F);
|
||||
setCreativeTab(Mekanism.tabMekanism);
|
||||
|
||||
initCTMs();
|
||||
}
|
||||
|
||||
public static BlockMachine getBlockMachine(MachineBlock block)
|
||||
@@ -166,21 +159,6 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
|
||||
}
|
||||
|
||||
public abstract MachineBlock getMachineBlock();
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IBlockState getExtendedState(IBlockState stateIn, IBlockAccess w, BlockPos pos)
|
||||
{
|
||||
if(stateIn.getBlock() == null || stateIn.getMaterial() == Material.AIR)
|
||||
{
|
||||
return stateIn;
|
||||
}
|
||||
|
||||
IExtendedBlockState state = (IExtendedBlockState)stateIn;
|
||||
CTMBlockRenderContext ctx = new CTMBlockRenderContext(w, pos);
|
||||
|
||||
return state.withProperty(BlockStateBasic.ctmProperty, ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStateContainer createBlockState()
|
||||
@@ -230,18 +208,6 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
public void initCTMs()
|
||||
{
|
||||
switch(getMachineBlock())
|
||||
{
|
||||
case MACHINE_BLOCK_1:
|
||||
ctmData[11] = new CTMData(BasicBlockType.TELEPORTER_FRAME, MachineType.TELEPORTER);
|
||||
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
|
||||
@@ -1041,20 +1007,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CTMData getCTMData(IBlockState state)
|
||||
{
|
||||
return ctmData[state.getBlock().getMetaFromState(state)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverrideTexture(IBlockState state, EnumFacing side)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public PropertyEnum<MachineType> getTypeProperty()
|
||||
{
|
||||
return getMachineBlock().getProperty();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mekanism.common.block.states;
|
||||
|
||||
import mekanism.client.render.ctm.PropertyCTMRenderContext;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.Tier.BaseTier;
|
||||
@@ -45,11 +44,10 @@ 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 static final PropertyCTMRenderContext ctmProperty = new PropertyCTMRenderContext();
|
||||
|
||||
public BlockStateBasic(BlockBasic block, PropertyEnum<BasicBlockType> typeProperty)
|
||||
{
|
||||
super(block, new IProperty[] {BlockStateFacing.facingProperty, typeProperty, activeProperty, tierProperty}, new IUnlistedProperty[] {BlockStateBasic.ctmProperty});
|
||||
super(block, new IProperty[] {BlockStateFacing.facingProperty, typeProperty, activeProperty, tierProperty}, new IUnlistedProperty[] {});
|
||||
}
|
||||
|
||||
public static enum BasicBlock
|
||||
@@ -99,11 +97,11 @@ public class BlockStateBasic extends ExtendedBlockState
|
||||
DYNAMIC_VALVE(BasicBlock.BASIC_BLOCK_1, 11, "DynamicValve", TileEntityDynamicValve.class, true, Predicates.<EnumFacing>alwaysFalse(), false, false, false),
|
||||
COPPER_BLOCK(BasicBlock.BASIC_BLOCK_1, 12, "CopperBlock", null, false, Predicates.<EnumFacing>alwaysFalse(), false, false, true),
|
||||
TIN_BLOCK(BasicBlock.BASIC_BLOCK_1, 13, "TinBlock", null, false, Predicates.<EnumFacing>alwaysFalse(), false, false, true),
|
||||
THERMAL_EVAPORATION_CONTROLLER(BasicBlock.BASIC_BLOCK_1, 14, "ThermalEvaporationController", TileEntityThermalEvaporationController.class, true, Predicates.<EnumFacing>alwaysFalse(), false, false, false),
|
||||
THERMAL_EVAPORATION_CONTROLLER(BasicBlock.BASIC_BLOCK_1, 14, "ThermalEvaporationController", TileEntityThermalEvaporationController.class, true, Plane.HORIZONTAL, true, false, false),
|
||||
THERMAL_EVAPORATION_VALVE(BasicBlock.BASIC_BLOCK_1, 15, "ThermalEvaporationValve", TileEntityThermalEvaporationValve.class, true, Predicates.<EnumFacing>alwaysFalse(), false, false, false),
|
||||
THERMAL_EVAPORATION_BLOCK(BasicBlock.BASIC_BLOCK_2, 0, "ThermalEvaporationBlock", TileEntityThermalEvaporationBlock.class, true, Predicates.<EnumFacing>alwaysFalse(), false, false, false),
|
||||
INDUCTION_CASING(BasicBlock.BASIC_BLOCK_2, 1, "InductionCasing", TileEntityInductionCasing.class, true, Predicates.<EnumFacing>alwaysFalse(), false, false, false),
|
||||
INDUCTION_PORT(BasicBlock.BASIC_BLOCK_2, 2, "InductionPort", TileEntityInductionPort.class, true, Predicates.<EnumFacing>alwaysFalse(), false, false, false),
|
||||
INDUCTION_PORT(BasicBlock.BASIC_BLOCK_2, 2, "InductionPort", TileEntityInductionPort.class, true, Predicates.<EnumFacing>alwaysFalse(), true, false, false),
|
||||
INDUCTION_CELL(BasicBlock.BASIC_BLOCK_2, 3, "InductionCell", TileEntityInductionCell.class, true, Predicates.<EnumFacing>alwaysFalse(), false, true, false),
|
||||
INDUCTION_PROVIDER(BasicBlock.BASIC_BLOCK_2, 4, "InductionProvider", TileEntityInductionProvider.class, true, Predicates.<EnumFacing>alwaysFalse(), false, true, false),
|
||||
SUPERHEATING_ELEMENT(BasicBlock.BASIC_BLOCK_2, 5, "SuperheatingElement", TileEntitySuperheatingElement.class, true, Predicates.<EnumFacing>alwaysFalse(), false, false, false),
|
||||
|
||||
@@ -81,7 +81,7 @@ public class BlockStateMachine extends ExtendedBlockState
|
||||
|
||||
public BlockStateMachine(BlockMachine block, PropertyEnum typeProperty)
|
||||
{
|
||||
super(block, new IProperty[] {BlockStateFacing.facingProperty, typeProperty, activeProperty, tierProperty, recipeProperty}, new IUnlistedProperty[] {BlockStateBasic.ctmProperty});
|
||||
super(block, new IProperty[] {BlockStateFacing.facingProperty, typeProperty, activeProperty, tierProperty, recipeProperty}, new IUnlistedProperty[] {});
|
||||
}
|
||||
|
||||
public enum MachineBlock
|
||||
|
||||
@@ -84,7 +84,6 @@ public class MekanismConfig
|
||||
public static boolean machineEffects = true;
|
||||
public static boolean oldTransmitterRender = false;
|
||||
public static boolean replaceSoundsWhenResuming = true;
|
||||
public static boolean renderCTM = true;
|
||||
public static boolean enableAmbientLighting;
|
||||
public static int ambientLightingLevel;
|
||||
public static boolean opaqueTransmitters = false;
|
||||
|
||||
@@ -16,6 +16,7 @@ import mekanism.common.Resource;
|
||||
import mekanism.common.block.states.BlockStateTransmitter.TransmitterType;
|
||||
import mekanism.common.integration.computer.CCPeripheral;
|
||||
import mekanism.common.integration.computer.OCDriver;
|
||||
import mekanism.common.integration.ic2.IC2Integration;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -48,10 +49,10 @@ public final class MekanismHooks
|
||||
|
||||
public void hook()
|
||||
{
|
||||
if(Loader.isModLoaded("CoFHCore")) CoFHCoreLoaded = true;
|
||||
if(Loader.isModLoaded("IC2")) IC2Loaded = true;
|
||||
if(Loader.isModLoaded("Railcraft")) RailcraftLoaded = true;
|
||||
if(Loader.isModLoaded("ThermalExpansion")) TELoaded = true;
|
||||
if(Loader.isModLoaded("cofhcore")) CoFHCoreLoaded = true;
|
||||
if(Loader.isModLoaded("ic2")) IC2Loaded = true;
|
||||
if(Loader.isModLoaded("railcraft")) RailcraftLoaded = true;
|
||||
if(Loader.isModLoaded("thermalexpansion")) TELoaded = true;
|
||||
if(Loader.isModLoaded("ComputerCraft")) CCLoaded = true;
|
||||
if(Loader.isModLoaded("appliedenergistics2")) AE2Loaded = true;
|
||||
if(Loader.isModLoaded("tesla")) TeslaLoaded = true;
|
||||
@@ -82,7 +83,7 @@ public final class MekanismHooks
|
||||
}
|
||||
}
|
||||
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public void hookIC2Recipes()
|
||||
{
|
||||
for(MachineRecipe<IRecipeInput, Collection<ItemStack>> entry : Recipes.macerator.getRecipes())
|
||||
@@ -136,7 +137,7 @@ public final class MekanismHooks
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
|
||||
@Method(modid = "OpenComputers")
|
||||
@Method(modid = "opencomputers")
|
||||
public void loadOCDrivers()
|
||||
{
|
||||
try {
|
||||
|
||||
@@ -2,7 +2,6 @@ package mekanism.common.integration;
|
||||
|
||||
import ic2.api.recipe.Recipes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -14,6 +13,7 @@ import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismFluids;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.Resource;
|
||||
import mekanism.common.integration.ic2.IC2Integration;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
@@ -25,7 +25,6 @@ import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraftforge.fml.common.Optional.Method;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
@@ -288,7 +287,7 @@ public final class OreDictManager
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public static void addIC2BronzeRecipe()
|
||||
{
|
||||
try {
|
||||
|
||||
@@ -12,7 +12,9 @@ import net.minecraftforge.fml.common.Optional.Method;
|
||||
|
||||
public class IC2Integration
|
||||
{
|
||||
@Method(modid = "IC2")
|
||||
public static final String MODID = "ic2";
|
||||
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public static boolean isOutputter(TileEntity tileEntity, EnumFacing side)
|
||||
{
|
||||
IEnergyTile tile = EnergyNet.instance.getSubTile(tileEntity.getWorld(), tileEntity.getPos());
|
||||
@@ -25,7 +27,7 @@ public class IC2Integration
|
||||
return false;
|
||||
}
|
||||
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public static boolean isAcceptor(TileEntity orig, TileEntity tileEntity, EnumFacing side)
|
||||
{
|
||||
IEnergyTile tile = EnergyNet.instance.getSubTile(tileEntity.getWorld(), tileEntity.getPos());
|
||||
@@ -41,7 +43,7 @@ public class IC2Integration
|
||||
return false;
|
||||
}
|
||||
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public static double emitEnergy(IEnergyWrapper from, TileEntity tileEntity, EnumFacing side, double currentSending)
|
||||
{
|
||||
IEnergyTile tile = EnergyNet.instance.getSubTile(tileEntity.getWorld(), tileEntity.getPos());
|
||||
|
||||
@@ -25,6 +25,7 @@ import mekanism.common.base.ITierItem;
|
||||
import mekanism.common.capabilities.ItemCapabilityWrapper;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.integration.forgeenergy.ForgeEnergyItemWrapper;
|
||||
import mekanism.common.integration.ic2.IC2Integration;
|
||||
import mekanism.common.integration.ic2.IC2ItemManager;
|
||||
import mekanism.common.integration.tesla.TeslaItemWrapper;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
@@ -58,8 +59,8 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@InterfaceList({
|
||||
@Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2"),
|
||||
@Interface(iface = "cofh.redstoneflux.api.IEnergyContainerItem", modid = "redstoneflux")
|
||||
@Interface(iface = "cofh.redstoneflux.api.IEnergyContainerItem", modid = "redstoneflux"),
|
||||
@Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = IC2Integration.MODID)
|
||||
})
|
||||
public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, ISpecialElectricItem, ISustainedInventory, IEnergyContainerItem, ISecurityItem, ITierItem
|
||||
{
|
||||
@@ -331,7 +332,7 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public IElectricItemManager getManager(ItemStack itemStack)
|
||||
{
|
||||
return IC2ItemManager.getManager(this);
|
||||
|
||||
@@ -37,6 +37,7 @@ import mekanism.common.block.states.BlockStateMachine.MachineType;
|
||||
import mekanism.common.capabilities.ItemCapabilityWrapper;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.integration.forgeenergy.ForgeEnergyItemWrapper;
|
||||
import mekanism.common.integration.ic2.IC2Integration;
|
||||
import mekanism.common.integration.ic2.IC2ItemManager;
|
||||
import mekanism.common.integration.tesla.TeslaItemWrapper;
|
||||
import mekanism.common.inventory.InventoryPersonalChest;
|
||||
@@ -134,8 +135,8 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
*
|
||||
*/
|
||||
@InterfaceList({
|
||||
@Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2"),
|
||||
@Interface(iface = "cofh.redstoneflux.api.IEnergyContainerItem", modid = "redstoneflux")
|
||||
@Interface(iface = "cofh.redstoneflux.api.IEnergyContainerItem", modid = "redstoneflux"),
|
||||
@Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = IC2Integration.MODID)
|
||||
})
|
||||
public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpecialElectricItem, IFactory, ISustainedInventory, ISustainedTank, IEnergyContainerItem, IFluidItemWrapper, ITierItem, ISecurityItem, IItemNetwork
|
||||
{
|
||||
@@ -785,7 +786,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public IElectricItemManager getManager(ItemStack itemStack)
|
||||
{
|
||||
return IC2ItemManager.getManager(this);
|
||||
|
||||
@@ -12,6 +12,7 @@ import mekanism.common.Mekanism;
|
||||
import mekanism.common.capabilities.ItemCapabilityWrapper;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.integration.forgeenergy.ForgeEnergyItemWrapper;
|
||||
import mekanism.common.integration.ic2.IC2Integration;
|
||||
import mekanism.common.integration.ic2.IC2ItemManager;
|
||||
import mekanism.common.integration.tesla.TeslaItemWrapper;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
@@ -33,7 +34,8 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@InterfaceList({
|
||||
@Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2"),
|
||||
@Interface(iface = "cofh.redstoneflux.api.IEnergyContainerItem", modid = "redstoneflux")
|
||||
@Interface(iface = "cofh.redstoneflux.api.IEnergyContainerItem", modid = "redstoneflux"),
|
||||
@Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = IC2Integration.MODID)
|
||||
})
|
||||
public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpecialElectricItem, IEnergyContainerItem
|
||||
{
|
||||
@@ -177,7 +179,7 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpec
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public IElectricItemManager getManager(ItemStack itemStack)
|
||||
{
|
||||
return IC2ItemManager.getManager(this);
|
||||
|
||||
@@ -14,6 +14,7 @@ import mekanism.common.Mekanism;
|
||||
import mekanism.common.capabilities.ItemCapabilityWrapper;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.integration.forgeenergy.ForgeEnergyItemWrapper;
|
||||
import mekanism.common.integration.ic2.IC2Integration;
|
||||
import mekanism.common.integration.ic2.IC2ItemManager;
|
||||
import mekanism.common.integration.tesla.TeslaItemWrapper;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
@@ -45,7 +46,8 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@InterfaceList({
|
||||
@Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2"),
|
||||
@Interface(iface = "cofh.redstoneflux.api.IEnergyContainerItem", modid = "redstoneflux")
|
||||
@Interface(iface = "cofh.redstoneflux.api.IEnergyContainerItem", modid = "redstoneflux"),
|
||||
@Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = IC2Integration.MODID)
|
||||
})
|
||||
public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpecialElectricItem, IEnergyContainerItem
|
||||
{
|
||||
@@ -213,7 +215,7 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public IElectricItemManager getManager(ItemStack itemStack)
|
||||
{
|
||||
return IC2ItemManager.getManager(this);
|
||||
|
||||
@@ -39,6 +39,11 @@ public class PacketTransmitterUpdate implements IMessageHandler<TransmitterUpdat
|
||||
{
|
||||
EntityPlayer player = PacketHandler.getPlayer(context);
|
||||
|
||||
if(player == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
PacketHandler.handlePacket(new Runnable() {
|
||||
@Override
|
||||
public void run()
|
||||
|
||||
@@ -10,6 +10,7 @@ import mekanism.api.energy.IStrictEnergyAcceptor;
|
||||
import mekanism.common.base.IAdvancedBoundingBlock;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
import mekanism.common.integration.computer.IComputerIntegration;
|
||||
import mekanism.common.integration.ic2.IC2Integration;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
@@ -25,9 +26,9 @@ import net.minecraftforge.fml.common.Optional.InterfaceList;
|
||||
import net.minecraftforge.fml.common.Optional.Method;
|
||||
|
||||
@InterfaceList({
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2"),
|
||||
@Interface(iface = "cofh.redstoneflux.api.IEnergyProvider", modid = "redstoneflux"),
|
||||
@Interface(iface = "cofh.redstoneflux.api.IEnergyReceiver", modid = "redstoneflux")
|
||||
@Interface(iface = "cofh.redstoneflux.api.IEnergyReceiver", modid = "redstoneflux"),
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = IC2Integration.MODID)
|
||||
})
|
||||
public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock implements ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IEnergyReceiver, IEnergyProvider, IComputerIntegration, ISpecialConfigData
|
||||
{
|
||||
@@ -245,7 +246,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public boolean acceptsEnergyFrom(IEnergyEmitter emitter, EnumFacing direction)
|
||||
{
|
||||
IAdvancedBoundingBlock inv = getInv();
|
||||
@@ -341,7 +342,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public double getDemandedEnergy()
|
||||
{
|
||||
IAdvancedBoundingBlock inv = getInv();
|
||||
@@ -349,7 +350,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public double injectEnergy(EnumFacing directionFrom, double amount, double voltage)
|
||||
{
|
||||
IAdvancedBoundingBlock inv = getInv();
|
||||
@@ -362,7 +363,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public int getSinkTier()
|
||||
{
|
||||
IAdvancedBoundingBlock inv = getInv();
|
||||
|
||||
@@ -216,6 +216,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
||||
if(set.cardinality() == 0)
|
||||
{
|
||||
it.remove();
|
||||
break;
|
||||
}
|
||||
|
||||
next = index + 1;
|
||||
@@ -233,6 +234,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
||||
if(set.cardinality() == 0)
|
||||
{
|
||||
it.remove();
|
||||
break;
|
||||
}
|
||||
|
||||
next = index + 1;
|
||||
|
||||
@@ -267,11 +267,11 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im
|
||||
{
|
||||
if(!inventory.get(i).isEmpty())
|
||||
{
|
||||
ItemStack stack = inventory.get(i);
|
||||
ItemStack stack = inventory.get(i).copy();
|
||||
|
||||
inventory.get(i).shrink(1);
|
||||
|
||||
if(stack.getCount() == 0 && stack.getItem().hasContainerItem(stack))
|
||||
if(inventory.get(i).getCount() == 0 && stack.getItem().hasContainerItem(stack))
|
||||
{
|
||||
ItemStack container = stack.getItem().getContainerItem(stack);
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import ic2.api.energy.tile.IEnergyTile;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
@@ -23,6 +22,7 @@ import mekanism.common.capabilities.Capabilities;
|
||||
import mekanism.common.capabilities.CapabilityWrapperManager;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.integration.forgeenergy.ForgeEnergyIntegration;
|
||||
import mekanism.common.integration.ic2.IC2Integration;
|
||||
import mekanism.common.integration.tesla.TeslaIntegration;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.util.CableUtils;
|
||||
@@ -44,9 +44,9 @@ import net.minecraftforge.fml.common.Optional.InterfaceList;
|
||||
import net.minecraftforge.fml.common.Optional.Method;
|
||||
|
||||
@InterfaceList({
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2"),
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = "IC2"),
|
||||
@Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2")
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = IC2Integration.MODID),
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = IC2Integration.MODID),
|
||||
@Interface(iface = "ic2.api.tile.IEnergyStorage", modid = IC2Integration.MODID)
|
||||
})
|
||||
public class TileEntityInductionPort extends TileEntityInductionCasing implements IEnergyWrapper, IConfigurable, IActiveState
|
||||
{
|
||||
@@ -98,7 +98,7 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement
|
||||
return (structure != null && !mode);
|
||||
}
|
||||
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public void register()
|
||||
{
|
||||
if(!world.isRemote)
|
||||
@@ -120,7 +120,7 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement
|
||||
}
|
||||
}
|
||||
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public void deregister()
|
||||
{
|
||||
if(!world.isRemote)
|
||||
@@ -285,28 +285,28 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public int getSinkTier()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public int getSourceTier()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public void setStored(int energy)
|
||||
{
|
||||
setEnergy(energy*general.FROM_IC2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public int addEnergy(int amount)
|
||||
{
|
||||
double toUse = Math.min(Math.min(getMaxInput(), getMaxEnergy()-getEnergy()), amount*general.FROM_IC2);
|
||||
@@ -316,7 +316,7 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public boolean isTeleporterCompatible(EnumFacing side)
|
||||
{
|
||||
return canOutputEnergy(side);
|
||||
@@ -329,49 +329,49 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public boolean acceptsEnergyFrom(IEnergyEmitter emitter, EnumFacing direction)
|
||||
{
|
||||
return sideIsConsumer(direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public boolean emitsEnergyTo(IEnergyAcceptor receiver, EnumFacing direction)
|
||||
{
|
||||
return sideIsOutput(direction) && receiver instanceof IEnergyConductor;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public int getStored()
|
||||
{
|
||||
return (int)Math.round(Math.min(Integer.MAX_VALUE, getEnergy()*general.TO_IC2));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public int getCapacity()
|
||||
{
|
||||
return (int)Math.round(Math.min(Integer.MAX_VALUE, getMaxEnergy()*general.TO_IC2));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public int getOutput()
|
||||
{
|
||||
return (int)Math.round(Math.min(Integer.MAX_VALUE, getMaxOutput()*general.TO_IC2));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public double getDemandedEnergy()
|
||||
{
|
||||
return (getMaxEnergy() - getEnergy())*general.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public double getOfferedEnergy()
|
||||
{
|
||||
return Math.min(getEnergy(), getMaxOutput())*general.TO_IC2;
|
||||
@@ -384,14 +384,14 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public double getOutputEnergyUnitsPerTick()
|
||||
{
|
||||
return getMaxOutput()*general.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public double injectEnergy(EnumFacing direction, double amount, double voltage)
|
||||
{
|
||||
TileEntity tile = getWorld().getTileEntity(getPos().offset(direction));
|
||||
@@ -404,7 +404,7 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public void drawEnergy(double amount)
|
||||
{
|
||||
if(structure != null)
|
||||
|
||||
@@ -19,6 +19,7 @@ import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.frequency.Frequency;
|
||||
import mekanism.common.frequency.FrequencyManager;
|
||||
import mekanism.common.frequency.IFrequencyHandler;
|
||||
import mekanism.common.integration.ic2.IC2Integration;
|
||||
import mekanism.common.network.PacketDataRequest.DataRequestMessage;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
@@ -34,7 +35,7 @@ import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.Optional.Interface;
|
||||
|
||||
@Interface(iface = "ic2.api.tile.IWrenchable", modid = "IC2")
|
||||
@Interface(iface = "ic2.api.tile.IWrenchable", modid = IC2Integration.MODID)
|
||||
public abstract class TileEntityBasicBlock extends TileEntity implements ITileNetwork, IChunkLoadHandler, IFrequencyHandler, ITickable
|
||||
{
|
||||
/** The direction this block is facing. */
|
||||
|
||||
@@ -10,13 +10,13 @@ import ic2.api.energy.tile.IEnergyTile;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import mekanism.common.base.IEnergyWrapper;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
import mekanism.common.capabilities.CapabilityWrapperManager;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.integration.forgeenergy.ForgeEnergyIntegration;
|
||||
import mekanism.common.integration.ic2.IC2Integration;
|
||||
import mekanism.common.integration.tesla.TeslaIntegration;
|
||||
import mekanism.common.util.CapabilityUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
@@ -56,7 +56,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
||||
maxEnergy = BASE_MAX_ENERGY;
|
||||
}
|
||||
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public void register()
|
||||
{
|
||||
if(!world.isRemote)
|
||||
@@ -78,7 +78,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
||||
}
|
||||
}
|
||||
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public void deregister()
|
||||
{
|
||||
if(!world.isRemote)
|
||||
@@ -256,28 +256,28 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public int getSinkTier()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public int getSourceTier()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public void setStored(int energy)
|
||||
{
|
||||
setEnergy(energy*general.FROM_IC2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public int addEnergy(int amount)
|
||||
{
|
||||
setEnergy(getEnergy() + amount*general.FROM_IC2);
|
||||
@@ -285,7 +285,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public boolean isTeleporterCompatible(EnumFacing side)
|
||||
{
|
||||
return sideIsOutput(side);
|
||||
@@ -298,49 +298,49 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public boolean acceptsEnergyFrom(IEnergyEmitter emitter, EnumFacing direction)
|
||||
{
|
||||
return sideIsConsumer(direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public boolean emitsEnergyTo(IEnergyAcceptor receiver, EnumFacing direction)
|
||||
{
|
||||
return sideIsOutput(direction) && receiver instanceof IEnergyConductor;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public int getStored()
|
||||
{
|
||||
return (int)Math.round(Math.min(Integer.MAX_VALUE, getEnergy()*general.TO_IC2));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public int getCapacity()
|
||||
{
|
||||
return (int)Math.round(Math.min(Integer.MAX_VALUE, getMaxEnergy()*general.TO_IC2));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public int getOutput()
|
||||
{
|
||||
return (int)Math.round(Math.min(Integer.MAX_VALUE, getMaxOutput()*general.TO_IC2));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public double getDemandedEnergy()
|
||||
{
|
||||
return (getMaxEnergy() - getEnergy())*general.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public double getOfferedEnergy()
|
||||
{
|
||||
return Math.min(getEnergy(), getMaxOutput())*general.TO_IC2;
|
||||
@@ -353,14 +353,14 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public double getOutputEnergyUnitsPerTick()
|
||||
{
|
||||
return getMaxOutput()*general.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public double injectEnergy(EnumFacing direction, double amount, double voltage)
|
||||
{
|
||||
TileEntity tile = getWorld().getTileEntity(getPos().offset(direction));
|
||||
@@ -374,7 +374,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public void drawEnergy(double amount)
|
||||
{
|
||||
setEnergy(Math.max(getEnergy() - (amount*general.FROM_IC2), 0));
|
||||
|
||||
@@ -3,7 +3,6 @@ package mekanism.generators.client;
|
||||
import java.io.IOException;
|
||||
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.client.render.ctm.CTMRegistry;
|
||||
import mekanism.generators.client.gui.GuiBioGenerator;
|
||||
import mekanism.generators.client.gui.GuiGasGenerator;
|
||||
import mekanism.generators.client.gui.GuiHeatGenerator;
|
||||
@@ -138,10 +137,6 @@ public class GeneratorsClientProxy extends GeneratorsCommonProxy
|
||||
public void preInit()
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
CTMRegistry.registerCTMs("mekanismgenerators", "turbine_vent", "turbine_valve", "turbine_casing", "electromagnetic_coil",
|
||||
"reactor_controller", "reactor_frame", "reactor_port", "reactor_port_output", "reactor_glass", "laser_focus_matrix",
|
||||
"reactor_logic_adapter", "reactor_controller_on", "saturating_condenser");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,11 +2,13 @@ package mekanism.generators.client.render.item;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.client.render.ctm.CTMModelFactory;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import mekanism.generators.client.model.ModelAdvancedSolarGenerator;
|
||||
@@ -32,6 +34,7 @@ import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -189,9 +192,30 @@ public class BakedGeneratorItemModel implements IBakedModel
|
||||
{
|
||||
prevTransform = cameraTransformType;
|
||||
|
||||
return Pair.of(this, CTMModelFactory.transforms.get(cameraTransformType).getMatrix());
|
||||
return Pair.of(this, transforms.get(cameraTransformType).getMatrix());
|
||||
}
|
||||
|
||||
// Copy from old CTM
|
||||
public static Map<TransformType, TRSRTransformation> transforms = ImmutableMap.<TransformType, TRSRTransformation>builder()
|
||||
.put(TransformType.GUI, get(0, 0, 0, 30, 225, 0, 0.625f))
|
||||
.put(TransformType.THIRD_PERSON_RIGHT_HAND, get(0, 2.5f, 0, 75, 45, 0, 0.375f))
|
||||
.put(TransformType.THIRD_PERSON_LEFT_HAND, get(0, 2.5f, 0, 75, 45, 0, 0.375f))
|
||||
.put(TransformType.FIRST_PERSON_RIGHT_HAND, get(0, 0, 0, 0, 45, 0, 0.4f))
|
||||
.put(TransformType.FIRST_PERSON_LEFT_HAND, get(0, 0, 0, 0, 225, 0, 0.4f))
|
||||
.put(TransformType.GROUND, get(0, 2, 0, 0, 0, 0, 0.25f))
|
||||
.put(TransformType.HEAD, get(0, 0, 0, 0, 0, 0, 1))
|
||||
.put(TransformType.FIXED, get(0, 0, 0, 0, 0, 0, 1))
|
||||
.put(TransformType.NONE, get(0, 0, 0, 0, 0, 0, 0))
|
||||
.build();
|
||||
private static TRSRTransformation get(float tx, float ty, float tz, float ax, float ay, float az, float s)
|
||||
{
|
||||
return new TRSRTransformation(
|
||||
new Vector3f(tx / 16, ty / 16, tz / 16),
|
||||
TRSRTransformation.quatFromXYZDegrees(new Vector3f(ax, ay, az)),
|
||||
new Vector3f(s, s, s),
|
||||
null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||
import buildcraft.api.fuels.BuildcraftFuelRegistry;
|
||||
import buildcraft.api.fuels.IFuel;
|
||||
|
||||
@Mod(modid = "mekanismgenerators", name = "MekanismGenerators", version = "9.3.3", dependencies = "required-after:mekanism", guiFactory = "mekanism.generators.client.gui.GeneratorsGuiFactory")
|
||||
@Mod(modid = "mekanismgenerators", name = "MekanismGenerators", version = "9.3.4", dependencies = "required-after:mekanism", guiFactory = "mekanism.generators.client.gui.GeneratorsGuiFactory")
|
||||
@Mod.EventBusSubscriber()
|
||||
public class MekanismGenerators implements IModule
|
||||
{
|
||||
@@ -55,7 +55,7 @@ public class MekanismGenerators implements IModule
|
||||
public static MekanismGenerators instance;
|
||||
|
||||
/** MekanismGenerators version number */
|
||||
public static Version versionNumber = new Version(9, 3, 3);
|
||||
public static Version versionNumber = new Version(9, 3, 4);
|
||||
|
||||
public static MultiblockManager<SynchronizedTurbineData> turbineManager = new MultiblockManager<SynchronizedTurbineData>("industrialTurbine");
|
||||
|
||||
|
||||
@@ -3,9 +3,6 @@ package mekanism.generators.common.block;
|
||||
import java.util.Random;
|
||||
|
||||
import mekanism.api.energy.IEnergizedItem;
|
||||
import mekanism.client.render.ctm.CTMBlockRenderContext;
|
||||
import mekanism.client.render.ctm.CTMData;
|
||||
import mekanism.client.render.ctm.ICTMBlock;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.base.IActiveState;
|
||||
import mekanism.common.base.IBoundingBlock;
|
||||
@@ -82,10 +79,8 @@ import buildcraft.api.tools.IToolWrench;
|
||||
* @author AidanBrady
|
||||
*
|
||||
*/
|
||||
public abstract class BlockGenerator extends BlockContainer implements ICTMBlock
|
||||
public abstract class BlockGenerator extends BlockContainer
|
||||
{
|
||||
public CTMData[] ctmData = new CTMData[16];
|
||||
|
||||
public Random machineRand = new Random();
|
||||
|
||||
private static final AxisAlignedBB SOLAR_BOUNDS = new AxisAlignedBB(0.0F, 0.0F, 0.0F, 1.0F, 0.7F, 1.0F);
|
||||
@@ -97,8 +92,6 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock
|
||||
setHardness(3.5F);
|
||||
setResistance(8F);
|
||||
setCreativeTab(Mekanism.tabMekanism);
|
||||
|
||||
initCTMs();
|
||||
}
|
||||
|
||||
public static BlockGenerator getGeneratorBlock(GeneratorBlock block)
|
||||
@@ -115,36 +108,6 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock
|
||||
|
||||
public abstract GeneratorBlock getGeneratorBlock();
|
||||
|
||||
public void initCTMs()
|
||||
{
|
||||
switch(getGeneratorBlock())
|
||||
{
|
||||
case GENERATOR_BLOCK_1:
|
||||
ctmData[9] = new CTMData(GeneratorType.ELECTROMAGNETIC_COIL);
|
||||
ctmData[10] = new CTMData(GeneratorType.TURBINE_CASING, GeneratorType.TURBINE_VALVE, GeneratorType.TURBINE_VENT);
|
||||
ctmData[11] = new CTMData(GeneratorType.TURBINE_VALVE, GeneratorType.TURBINE_CASING, GeneratorType.TURBINE_VENT);
|
||||
ctmData[12] = new CTMData(GeneratorType.TURBINE_VENT, GeneratorType.TURBINE_CASING, GeneratorType.TURBINE_VALVE);
|
||||
ctmData[13] = new CTMData(GeneratorType.SATURATING_CONDENSER);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IBlockState getExtendedState(IBlockState stateIn, IBlockAccess w, BlockPos pos)
|
||||
{
|
||||
if(stateIn.getBlock() == null || stateIn.getMaterial() == Material.AIR)
|
||||
{
|
||||
return stateIn;
|
||||
}
|
||||
|
||||
IExtendedBlockState state = (IExtendedBlockState)stateIn;
|
||||
CTMBlockRenderContext ctx = new CTMBlockRenderContext(w, pos);
|
||||
|
||||
return state.withProperty(BlockStateBasic.ctmProperty, ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStateContainer createBlockState()
|
||||
{
|
||||
@@ -760,20 +723,7 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CTMData getCTMData(IBlockState state)
|
||||
{
|
||||
return ctmData[state.getBlock().getMetaFromState(state)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverrideTexture(IBlockState state, EnumFacing side)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public PropertyEnum<GeneratorType> getTypeProperty()
|
||||
{
|
||||
return getGeneratorBlock().getProperty();
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
package mekanism.generators.common.block;
|
||||
|
||||
import mekanism.client.render.ctm.CTMBlockRenderContext;
|
||||
import mekanism.client.render.ctm.CTMData;
|
||||
import mekanism.client.render.ctm.ICTMBlock;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.base.IActiveState;
|
||||
import mekanism.common.block.states.BlockStateBasic;
|
||||
import mekanism.common.tile.prefab.TileEntityBasicBlock;
|
||||
import mekanism.common.tile.prefab.TileEntityElectricBlock;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
@@ -39,14 +35,12 @@ import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
|
||||
public abstract class BlockReactor extends Block implements ICTMBlock, ITileEntityProvider
|
||||
public abstract class BlockReactor extends Block implements ITileEntityProvider
|
||||
{
|
||||
public CTMData[] ctmData = new CTMData[16];
|
||||
|
||||
public BlockReactor()
|
||||
{
|
||||
@@ -54,8 +48,6 @@ public abstract class BlockReactor extends Block implements ICTMBlock, ITileEnti
|
||||
setHardness(3.5F);
|
||||
setResistance(8F);
|
||||
setCreativeTab(Mekanism.tabMekanism);
|
||||
|
||||
initCTMs();
|
||||
}
|
||||
|
||||
public static BlockReactor getReactorBlock(ReactorBlock block)
|
||||
@@ -90,41 +82,6 @@ public abstract class BlockReactor extends Block implements ICTMBlock, ITileEnti
|
||||
return state;
|
||||
}
|
||||
|
||||
public void initCTMs()
|
||||
{
|
||||
switch(getReactorBlock())
|
||||
{
|
||||
case REACTOR_BLOCK:
|
||||
ctmData[0] = new CTMData(ReactorBlockType.REACTOR_CONTROLLER, ReactorBlockType.REACTOR_FRAME, ReactorBlockType.REACTOR_PORT, ReactorBlockType.REACTOR_LOGIC_ADAPTER);
|
||||
ctmData[1] = new CTMData(ReactorBlockType.REACTOR_CONTROLLER, ReactorBlockType.REACTOR_FRAME, ReactorBlockType.REACTOR_PORT, ReactorBlockType.REACTOR_LOGIC_ADAPTER);
|
||||
ctmData[2] = new CTMData(ReactorBlockType.REACTOR_CONTROLLER, ReactorBlockType.REACTOR_FRAME, ReactorBlockType.REACTOR_PORT, ReactorBlockType.REACTOR_LOGIC_ADAPTER);
|
||||
ctmData[3] = new CTMData(ReactorBlockType.REACTOR_CONTROLLER, ReactorBlockType.REACTOR_FRAME, ReactorBlockType.REACTOR_PORT, ReactorBlockType.REACTOR_LOGIC_ADAPTER);
|
||||
ctmData[4] = new CTMData(ReactorBlockType.REACTOR_CONTROLLER, ReactorBlockType.REACTOR_FRAME, ReactorBlockType.REACTOR_PORT, ReactorBlockType.REACTOR_LOGIC_ADAPTER);
|
||||
|
||||
break;
|
||||
case REACTOR_GLASS:
|
||||
ctmData[0] = new CTMData(ReactorBlockType.REACTOR_GLASS, ReactorBlockType.LASER_FOCUS_MATRIX);
|
||||
ctmData[1] = new CTMData(ReactorBlockType.REACTOR_GLASS, ReactorBlockType.LASER_FOCUS_MATRIX);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IBlockState getExtendedState(IBlockState stateIn, IBlockAccess w, BlockPos pos)
|
||||
{
|
||||
if(stateIn.getBlock() == null || stateIn.getMaterial() == Material.AIR)
|
||||
{
|
||||
return stateIn;
|
||||
}
|
||||
|
||||
IExtendedBlockState state = (IExtendedBlockState)stateIn;
|
||||
CTMBlockRenderContext ctx = new CTMBlockRenderContext(w, pos);
|
||||
|
||||
return state.withProperty(BlockStateBasic.ctmProperty, ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStateContainer createBlockState()
|
||||
{
|
||||
@@ -280,9 +237,13 @@ public abstract class BlockReactor extends Block implements ICTMBlock, ITileEnti
|
||||
|
||||
if(type == ReactorBlockType.REACTOR_GLASS || type == ReactorBlockType.LASER_FOCUS_MATRIX)
|
||||
{
|
||||
if(!ctmData[meta].shouldRenderSide(world, pos.offset(side), side))
|
||||
{
|
||||
return false;
|
||||
IBlockState stateOffset = world.getBlockState(pos.offset(side));
|
||||
if(this == stateOffset.getBlock()) {
|
||||
int metaOffset = stateOffset.getBlock().getMetaFromState(stateOffset);
|
||||
ReactorBlockType typeOffset = ReactorBlockType.get(getReactorBlock(), metaOffset);
|
||||
if (typeOffset == ReactorBlockType.REACTOR_GLASS || typeOffset == ReactorBlockType.LASER_FOCUS_MATRIX) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,37 +314,7 @@ public abstract class BlockReactor extends Block implements ICTMBlock, ITileEnti
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CTMData getCTMData(IBlockState state)
|
||||
{
|
||||
return ctmData[state.getBlock().getMetaFromState(state)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverrideTexture(IBlockState state, EnumFacing side)
|
||||
{
|
||||
ReactorBlockType type = state.getValue(getTypeProperty());
|
||||
|
||||
if(type == ReactorBlockType.REACTOR_CONTROLLER)
|
||||
{
|
||||
if(side == EnumFacing.UP)
|
||||
{
|
||||
return type.getName() + (state.getValue(BlockStateReactor.activeProperty) ? "_on" : "");
|
||||
}
|
||||
else {
|
||||
return "reactor_frame";
|
||||
}
|
||||
}
|
||||
else if(type == ReactorBlockType.REACTOR_PORT)
|
||||
{
|
||||
return type.getName() + (state.getValue(BlockStateReactor.activeProperty) ? "_output" : "");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public PropertyEnum<ReactorBlockType> getTypeProperty()
|
||||
{
|
||||
return getReactorBlock().getProperty();
|
||||
|
||||
@@ -52,7 +52,7 @@ public class BlockStateGenerator extends ExtendedBlockState
|
||||
|
||||
public BlockStateGenerator(BlockGenerator block, PropertyEnum typeProperty)
|
||||
{
|
||||
super(block, new IProperty[] {BlockStateFacing.facingProperty, typeProperty, activeProperty}, new IUnlistedProperty[] {BlockStateBasic.ctmProperty});
|
||||
super(block, new IProperty[] {BlockStateFacing.facingProperty, typeProperty, activeProperty}, new IUnlistedProperty[] {});
|
||||
}
|
||||
|
||||
public static enum GeneratorBlock
|
||||
|
||||
@@ -34,7 +34,7 @@ public class BlockStateReactor extends ExtendedBlockState
|
||||
|
||||
public BlockStateReactor(BlockReactor block, PropertyEnum<ReactorBlockType> typeProperty)
|
||||
{
|
||||
super(block, new IProperty[] {typeProperty, activeProperty}, new IUnlistedProperty[] {BlockStateBasic.ctmProperty});
|
||||
super(block, new IProperty[] {typeProperty, activeProperty}, new IUnlistedProperty[] {});
|
||||
}
|
||||
|
||||
public static enum ReactorBlock
|
||||
@@ -86,12 +86,12 @@ public class BlockStateReactor extends ExtendedBlockState
|
||||
|
||||
public static enum ReactorBlockType implements IStringSerializable
|
||||
{
|
||||
REACTOR_CONTROLLER(ReactorBlock.REACTOR_BLOCK, 0, "ReactorController", 10, TileEntityReactorController.class, false),
|
||||
REACTOR_CONTROLLER(ReactorBlock.REACTOR_BLOCK, 0, "ReactorController", 10, TileEntityReactorController.class, true),
|
||||
REACTOR_FRAME(ReactorBlock.REACTOR_BLOCK, 1, "ReactorFrame", -1, TileEntityReactorFrame.class, false),
|
||||
REACTOR_PORT(ReactorBlock.REACTOR_BLOCK, 2, "ReactorPort", -1, TileEntityReactorPort.class, false),
|
||||
REACTOR_PORT(ReactorBlock.REACTOR_BLOCK, 2, "ReactorPort", -1, TileEntityReactorPort.class, true),
|
||||
REACTOR_LOGIC_ADAPTER(ReactorBlock.REACTOR_BLOCK, 3, "ReactorLogicAdapter", 15, TileEntityReactorLogicAdapter.class, false),
|
||||
REACTOR_GLASS(ReactorBlock.REACTOR_GLASS, 0, "ReactorGlass", -1, TileEntityReactorGlass.class, false),
|
||||
LASER_FOCUS_MATRIX(ReactorBlock.REACTOR_GLASS, 1, "ReactorLaserFocusMatrix", -1, TileEntityReactorLaserFocusMatrix.class, true);
|
||||
LASER_FOCUS_MATRIX(ReactorBlock.REACTOR_GLASS, 1, "ReactorLaserFocusMatrix", -1, TileEntityReactorLaserFocusMatrix.class, false);
|
||||
|
||||
public ReactorBlock blockType;
|
||||
public int meta;
|
||||
@@ -164,6 +164,11 @@ public class BlockStateReactor extends ExtendedBlockState
|
||||
{
|
||||
return new ItemStack(blockType.getBlock(), amount, meta);
|
||||
}
|
||||
|
||||
public boolean hasActiveTexture()
|
||||
{
|
||||
return activable;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ReactorBlockStateMapper extends StateMapperBase
|
||||
@@ -176,6 +181,13 @@ public class BlockStateReactor extends ExtendedBlockState
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String nameOverride = null;
|
||||
|
||||
if(type.hasActiveTexture())
|
||||
{
|
||||
builder.append(activeProperty.getName());
|
||||
builder.append("=");
|
||||
builder.append(state.getValue(activeProperty));
|
||||
}
|
||||
|
||||
if(builder.length() == 0)
|
||||
{
|
||||
builder.append("normal");
|
||||
|
||||
@@ -18,6 +18,7 @@ import mekanism.common.base.ISustainedTank;
|
||||
import mekanism.common.capabilities.ItemCapabilityWrapper;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.integration.forgeenergy.ForgeEnergyItemWrapper;
|
||||
import mekanism.common.integration.ic2.IC2Integration;
|
||||
import mekanism.common.integration.ic2.IC2ItemManager;
|
||||
import mekanism.common.integration.tesla.TeslaItemWrapper;
|
||||
import mekanism.common.security.ISecurityItem;
|
||||
@@ -72,8 +73,8 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
*/
|
||||
|
||||
@InterfaceList({
|
||||
@Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2"),
|
||||
@Interface(iface = "cofh.redstoneflux.api.IEnergyContainerItem", modid = "redstoneflux")
|
||||
@Interface(iface = "cofh.redstoneflux.api.IEnergyContainerItem", modid = "redstoneflux"),
|
||||
@Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = IC2Integration.MODID)
|
||||
})
|
||||
public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISpecialElectricItem, ISustainedInventory, ISustainedTank, IEnergyContainerItem, ISecurityItem
|
||||
{
|
||||
@@ -418,7 +419,7 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public IElectricItemManager getManager(ItemStack itemStack)
|
||||
{
|
||||
return IC2ItemManager.getManager(this);
|
||||
|
||||
@@ -7,9 +7,6 @@ import ic2.api.energy.tile.IEnergyAcceptor;
|
||||
import ic2.api.energy.tile.IEnergyConductor;
|
||||
import ic2.api.energy.tile.IEnergyEmitter;
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.common.base.FluidHandlerWrapper;
|
||||
import mekanism.common.base.IEnergyWrapper;
|
||||
@@ -20,6 +17,7 @@ import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.config.MekanismConfig.generators;
|
||||
import mekanism.common.integration.computer.IComputerIntegration;
|
||||
import mekanism.common.integration.forgeenergy.ForgeEnergyIntegration;
|
||||
import mekanism.common.integration.ic2.IC2Integration;
|
||||
import mekanism.common.integration.tesla.TeslaIntegration;
|
||||
import mekanism.common.tile.TileEntityGasTank.GasMode;
|
||||
import mekanism.common.util.CableUtils;
|
||||
@@ -89,7 +87,7 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I
|
||||
return false;
|
||||
}
|
||||
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public void register()
|
||||
{
|
||||
if(!world.isRemote)
|
||||
@@ -111,7 +109,7 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I
|
||||
}
|
||||
}
|
||||
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public void deregister()
|
||||
{
|
||||
if(!world.isRemote)
|
||||
@@ -212,35 +210,35 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public int getSinkTier()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public int getSourceTier()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public void setStored(int energy)
|
||||
{
|
||||
setEnergy(energy*general.FROM_IC2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public int addEnergy(int amount)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public boolean isTeleporterCompatible(EnumFacing side)
|
||||
{
|
||||
return canOutputEnergy(side);
|
||||
@@ -253,49 +251,49 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public boolean acceptsEnergyFrom(IEnergyEmitter emitter, EnumFacing direction)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public boolean emitsEnergyTo(IEnergyAcceptor receiver, EnumFacing direction)
|
||||
{
|
||||
return sideIsOutput(direction) && receiver instanceof IEnergyConductor;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public int getStored()
|
||||
{
|
||||
return (int)Math.round(Math.min(Integer.MAX_VALUE, getEnergy()*general.TO_IC2));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public int getCapacity()
|
||||
{
|
||||
return (int)Math.round(Math.min(Integer.MAX_VALUE, getMaxEnergy()*general.TO_IC2));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public int getOutput()
|
||||
{
|
||||
return (int)Math.round(Math.min(Integer.MAX_VALUE, getMaxOutput()*general.TO_IC2));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public double getDemandedEnergy()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public double getOfferedEnergy()
|
||||
{
|
||||
return Math.min(getEnergy(), getMaxOutput())*general.TO_IC2;
|
||||
@@ -308,21 +306,21 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public double getOutputEnergyUnitsPerTick()
|
||||
{
|
||||
return getMaxOutput()*general.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public double injectEnergy(EnumFacing direction, double amount, double voltage)
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
@Method(modid = IC2Integration.MODID)
|
||||
public void drawEnergy(double amount)
|
||||
{
|
||||
if(structure != null)
|
||||
|
||||
@@ -32,7 +32,7 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
@Mod(modid = "mekanismtools", name = "MekanismTools", version = "9.3.3", dependencies = "required-after:mekanism", guiFactory = "mekanism.tools.client.gui.ToolsGuiFactory")
|
||||
@Mod(modid = "mekanismtools", name = "MekanismTools", version = "9.3.4", dependencies = "required-after:mekanism", guiFactory = "mekanism.tools.client.gui.ToolsGuiFactory")
|
||||
@Mod.EventBusSubscriber()
|
||||
public class MekanismTools implements IModule
|
||||
{
|
||||
@@ -43,7 +43,7 @@ public class MekanismTools implements IModule
|
||||
public static MekanismTools instance;
|
||||
|
||||
/** MekanismTools version number */
|
||||
public static Version versionNumber = new Version(9, 3, 3);
|
||||
public static Version versionNumber = new Version(9, 3, 4);
|
||||
|
||||
//Enums: Tools
|
||||
public static ToolMaterial toolOBSIDIAN;
|
||||
|
||||
Reference in new issue
Block a user