Wire connections and bounding boxes for the Marx generator

Some misc stuff
This commit is contained in:
malte0811 2017-06-03 21:06:25 +02:00
parent d4bed0d324
commit 963755af78
11 changed files with 356 additions and 75 deletions

View file

@ -28,7 +28,8 @@ public final class IWProperties {
NO_MODEL,
BOTTOM,
STAGE,
TOP;
TOP,
CONNECTOR;
@Override
public String getName() {

View file

@ -50,13 +50,13 @@ public abstract class TileEntityIWMultiblock extends TileEntityIWBase {
return (w, p)->w.setBlockState(p, getOriginalBlock());
}
@Nullable
public TileEntity master() {
public <T extends TileEntityIWMultiblock> T master(T here) {
if (offset.getX()==0&&offset.getY()==0&&offset.getZ()==0) {
return this;
return here;
}
TileEntity m = world.getTileEntity(pos.subtract(offset));
if (m!=null&&m.getClass().equals(this.getClass())) {
return m;
return (T) m;
}
return null;
}
@ -108,4 +108,16 @@ public abstract class TileEntityIWMultiblock extends TileEntityIWBase {
public Vec3i getSize() {
return size;
}
public int getRight() {
return dot(offset, facing.rotateY().getDirectionVec())*(mirrored?-1:1);
}
public int getForward() {
return dot(offset, facing.getDirectionVec());
}
protected int dot(Vec3i a, Vec3i b) {
return a.getX()*b.getX()+a.getY()*b.getY()+a.getZ()*b.getZ();
}
}

View file

@ -53,6 +53,8 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static malte0811.industrialWires.util.MiscUtils.apply;
public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTile, IBlockBoundsIW, IPlayerInteraction, ITickable, IEBlockInterfaces.ITileDrop {
private PropertyComponents.PanelRenderProperties components = new PropertyComponents.PanelRenderProperties();
private boolean firstTick = true;
@ -215,13 +217,6 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
return components;
}
public AxisAlignedBB apply(Matrix4 mat, AxisAlignedBB in) {
Vec3d min = new Vec3d(in.minX, in.minY, in.minZ);
Vec3d max = new Vec3d(in.maxX, in.maxY, in.maxZ);
min = mat.apply(min);
max = mat.apply(max);
return new AxisAlignedBB(min.xCoord, min.yCoord, min.zCoord, max.xCoord, max.yCoord, max.zCoord);
}
@Nullable
public Pair<PanelComponent, RayTraceResult> getSelectedComponent(EntityPlayer player, Vec3d hit, boolean hitAbs) {

View file

@ -24,6 +24,7 @@ import malte0811.industrialWires.blocks.IWProperties;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
@ -33,6 +34,8 @@ import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -85,4 +88,13 @@ public class BlockHVMultiblocks extends BlockIWMultiblock {
}
return ret;
}
@Nonnull
@Override
protected BlockStateContainer createBlockState() {
BlockStateContainer base = super.createBlockState();
return new ExtendedBlockState(this, base.getProperties().toArray(new IProperty[0]), new IUnlistedProperty[]{
IEProperties.CONNECTIONS
});
}
}

View file

@ -37,7 +37,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World;
import java.util.Set;
@ -131,12 +130,11 @@ public class MultiblockMarx implements IMultiblock {
return false;
}
Set<Connection> existingConns = ImmersiveNetHandler.INSTANCE.getConnections(world, local);
return existingConns==null;
return existingConns==null||existingConns.isEmpty();
};
mirrorLoop:for (int fakeI = 0; fakeI < 2; fakeI++) {
mirrored = !mirrored;
facing = facing.getOpposite();
// PSU
if (!connNoConns.test(offset(pos, facing, mirrored, 0, -3, 0), CONNECTOR_REDSTONE)) {
continue;
@ -200,12 +198,12 @@ public class MultiblockMarx implements IMultiblock {
continue mirrorLoop;
}
}
player.sendMessage(new TextComponentString(stages+" stage Marx generator found. Forming..."));
//REPLACE STRUCTURE
if (!world.isRemote) {
IBlockState noModel = IndustrialWires.hvMultiblocks.getDefaultState().withProperty(BlockHVMultiblocks.type, MARX)
.withProperty(IWProperties.MARX_TYPE, NO_MODEL).withProperty(IEProperties.BOOLEANS[0], mirrored);
IBlockState stageModel = noModel.withProperty(IWProperties.MARX_TYPE, STAGE);
IBlockState connModel = noModel.withProperty(IWProperties.MARX_TYPE, CONNECTOR);
// Main tower
for (int s = 0; s < stages; s++) {
for (int f = -1; f < 2; f++) {
@ -224,8 +222,12 @@ public class MultiblockMarx implements IMultiblock {
}
}
}
//conns
for (int i = 0;i<2;i++) {
set(world, offset(pos, facing, mirrored, i, -3, 0), connModel, stages, pos);
}
//bottom electrode
for (int i = -3;i<5;i++) {
for (int i = -2;i<5;i++) {
if (i>-2&&i<2) {
continue;
}
@ -244,7 +246,6 @@ public class MultiblockMarx implements IMultiblock {
}
return true;
}
player.sendMessage(new TextComponentString("NOT FOUND"));
return false;
}
private void set(World world, BlockPos p, IBlockState state, int stages, BlockPos origin) {

View file

@ -19,17 +19,27 @@
package malte0811.industrialWires.blocks.hv;
import blusunrize.immersiveengineering.api.IEProperties;
import blusunrize.immersiveengineering.api.TargetingInfo;
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
import blusunrize.immersiveengineering.api.energy.wires.WireType;
import blusunrize.immersiveengineering.api.energy.wires.redstone.IRedstoneConnector;
import blusunrize.immersiveengineering.api.energy.wires.redstone.RedstoneWireNetwork;
import blusunrize.immersiveengineering.common.IEContent;
import blusunrize.immersiveengineering.common.blocks.BlockTypes_MetalsIE;
import blusunrize.immersiveengineering.common.blocks.metal.*;
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
import ic2.api.item.IC2Items;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.IIC2Connector;
import malte0811.industrialWires.blocks.IBlockBoundsIW;
import malte0811.industrialWires.blocks.ISyncReceiver;
import malte0811.industrialWires.blocks.IWProperties;
import malte0811.industrialWires.blocks.TileEntityIWMultiblock;
import malte0811.industrialWires.client.render.TileRenderMarx;
import malte0811.industrialWires.network.MessageTileSyncIW;
import malte0811.industrialWires.util.DualEnergyStorage;
import malte0811.industrialWires.util.MiscUtils;
import malte0811.industrialWires.wires.IC2Wiretype;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
@ -37,30 +47,36 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.util.vector.Vector3f;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.HashSet;
import java.util.Set;
import java.util.function.BiConsumer;
public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable, ISyncReceiver {
public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable, ISyncReceiver, IBlockBoundsIW, IImmersiveConnectable, IIC2Connector,
IRedstoneConnector{
// TODO do I want to do this?
public static final Set<TileEntityMarx> dischargingMarxes = new HashSet<>();
private static final String TYPE = "type";
private static final String STAGES = "stages";
private static final String HAS_CONN = "hasConn";
public IWProperties.MarxType type = IWProperties.MarxType.NO_MODEL;
public int stageCount = 0;
public FiringState state = FiringState.CHARGING;
@SideOnly(Side.CLIENT)
public TileRenderMarx.Discharge dischargeData;
private DualEnergyStorage storage = new DualEnergyStorage(10000, 1000);
private boolean hasConnection;
public TileEntityMarx(EnumFacing facing, IWProperties.MarxType type, boolean mirrored) {
this.facing = facing;
@ -74,6 +90,8 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
super.writeNBT(out, updatePacket);
out.setInteger(TYPE, type.ordinal());
out.setInteger(STAGES, stageCount);
out.setBoolean(HAS_CONN, hasConnection);
storage.writeToNbt(out, ENERGY_TAG);
}
@Override
@ -81,6 +99,10 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
super.readNBT(in, updatePacket);
type = IWProperties.MarxType.values()[in.getInteger(TYPE)];
stageCount = in.getInteger(STAGES);
storage = DualEnergyStorage.readFromNBT(in.getCompoundTag(ENERGY_TAG));
hasConnection = in.getBoolean(HAS_CONN);
boundingAabb = null;
renderAabb = null;
}
@Nonnull
@ -93,8 +115,8 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
@SuppressWarnings("unchecked")
@Override
public IBlockState getOriginalBlock() {
int forward = dot(offset, facing.getDirectionVec());
int right = dot(offset, facing.rotateY().getDirectionVec())*(mirrored?-1:1);
int forward = getForward();
int right = getRight();
int up = offset.getY();
if (forward==0) {
return IEContent.blockMetalDevice0.getDefaultState().withProperty(IEContent.blockMetalDevice0.property, BlockTypes_MetalDevice0.CAPACITOR_HV);
@ -146,10 +168,6 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
}
}
private int dot(Vec3i a, Vec3i b) {
return a.getX()*b.getX()+a.getY()*b.getY()+a.getZ()*b.getZ();
}
@Override
public void update() {
if (state==FiringState.FIRE) {
@ -169,7 +187,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
if (world.getTotalWorldTime()%40==0) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setFloat("energy", stageCount*9*9);
IndustrialWires.packetHandler.sendToAll(new MessageTileSyncIW(this, nbt));
// IndustrialWires.packetHandler.sendToAll(new MessageTileSyncIW(this, nbt));
}
}
}
@ -182,58 +200,222 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
@Override
public void onSync(NBTTagCompound nbt) {
state = FiringState.NEXT_TICK;
if (true||dischargeData==null) {
dischargeData = new TileRenderMarx.Discharge();
int count = 1;
while (count<stageCount) {
count <<= 1;
}
dischargeData.vertices = new Vector3f[2*count];
for (int i = 0;i<dischargeData.vertices.length;i++) {
dischargeData.vertices[i] = new Vector3f();
}
dischargeData.vertices[dischargeData.vertices.length-1] = new Vector3f(0, stageCount-1.9375F, 0);
if (dischargeData==null) {
dischargeData = new TileRenderMarx.Discharge(stageCount);
}
dischargeData.energy = nbt.getFloat("energy");
genMarxPoint(0, dischargeData.vertices.length-1);
dischargeData.diameter = dischargeData.energy/(stageCount*15*15);
dischargeData.genMarxPoint(0, dischargeData.vertices.length-1);
}
// Meant to be const
private final Vector3f up = new Vector3f(0, 1, 0);
private final Vector3f side = new Vector3f(0, 0, 1);
//used for calculation buffering
private final Vector3f diff = new Vector3f();
private final Vector3f center = new Vector3f();
private final Vector3f v0 = new Vector3f();
private final Matrix4 transform = new Matrix4();
/**
* @param min The first point of the discharge section to be generated. has to be pre-populated
* @param max The last point of the discharge section to be generated. has to be pre-populated
*/
private void genMarxPoint(int min, int max) {
int toGenerate = (min+max)/2;
Vector3f.sub(dischargeData.vertices[max], dischargeData.vertices[min], diff);
Vector3f.cross(diff, side, v0);
transform.setIdentity();
double noise = Math.sqrt(stageCount)*world.rand.nextDouble()*1/(1+Math.abs(stageCount/2.0-toGenerate))*.5;
if ((max-min)%2==1) {
noise *= (toGenerate-min)/(double)(max-min);
}
v0.scale((float) (noise/v0.length()));
diff.scale(1/diff.length());
transform.rotate(Math.PI*2*world.rand.nextDouble(), diff.x, diff.y, diff.z);
Vector3f.add(dischargeData.vertices[max], dischargeData.vertices[min], center);
center.scale(.5F);
dischargeData.vertices[toGenerate] = transform.apply(v0);
Vector3f.add(dischargeData.vertices[toGenerate], center, dischargeData.vertices[toGenerate]);
if (toGenerate-min>1) {
genMarxPoint(min, toGenerate);
private AxisAlignedBB renderAabb = null;
@Nonnull
@Override
public AxisAlignedBB getRenderBoundingBox() {
if (renderAabb ==null) {
if (type== IWProperties.MarxType.BOTTOM) {
renderAabb = new AxisAlignedBB(pos,
MiscUtils.offset(pos, facing, mirrored, 2, 4, stageCount));
} else {
renderAabb = new AxisAlignedBB(pos, pos);
}
}
if (max-toGenerate>1) {
genMarxPoint(toGenerate, max);
return renderAabb;
}
private AxisAlignedBB boundingAabb = null;
@Override
public AxisAlignedBB getBoundingBox() {
if (boundingAabb==null||true) {
int forward = getForward();
int right = getRight();
int up = offset.getY();
AxisAlignedBB ret = Block.FULL_BLOCK_AABB;
switch (forward) {
case -3://IO
if (right == 1) {
ret = new AxisAlignedBB(5 / 16D, 5 / 16D, .25, 11 / 16D, 11 / 16D, 1);
} else {
ret = new AxisAlignedBB(5 / 16D, 5 / 16D, 7 / 16D, 11 / 16D, 11 / 16D, 1);
}
break;
case -1://charging resistors
if (up == 0) {
ret = new AxisAlignedBB(.375, 0, 0, .625, 1, 1);
} else if (up == stageCount - 1) {
ret = new AxisAlignedBB(.375, 0, 9 / 16D, .625, 5 / 16D, 1);
} else {
ret = new AxisAlignedBB(.375, 0, 9 / 16D, .625, 1, 1);
}
break;
case 1://spark gaps
if (right == 0) {
if (up!=0) {
ret = new AxisAlignedBB(0, 0, 0, 9 / 16D, up == stageCount - 1 ? .5 : 1, 7 / 16D);
} else {
ret = new AxisAlignedBB(7/16D, 0, 0, 9/16D, 5/16D, 1);
}
} else {
if (stageCount - 1 == up) {
ret = new AxisAlignedBB(7 / 16D, 3 / 16D, 0, 9 / 16D, 5 / 16D, 1);
} else {
ret = new AxisAlignedBB(7 / 16D, 0, 0, 1, 1, 7 / 16D);
}
}
break;
case -2://Controller
break;
case 0://Caps
if (up == stageCount - 1) {
ret = new AxisAlignedBB(0, 0, 0, 1, .5, 1);
}
break;
default:
if (right == 0) {
if (forward<4) {
ret = new AxisAlignedBB(7/16D, 0, 0, 9/16D, 5/16D, 1);
} else {
ret = new AxisAlignedBB(0, 0, 0, 9/16D, 5/16D, 9/16D);
}
} else {
if (up==0) {
ret = Block.FULL_BLOCK_AABB;
} else if (forward < 4) {
ret = new AxisAlignedBB(7 / 16D, 3 / 16D, 0, 9 / 16D, 5 / 16D, 1);
} else {
ret = new AxisAlignedBB(6 / 16D, 1 / 16D, 0, 10 / 16D, 5 / 16D, 10 / 16D);
}
}
}
boundingAabb = MiscUtils.apply(getBaseTransform(), ret);
}
return boundingAabb;
}
private Matrix4 getBaseTransform() {
Matrix4 transform = new Matrix4();
transform.translate(.5, 0, .5);
transform.rotate(facing.getHorizontalAngle() * Math.PI / 180, 0, 1, 0);
if (mirrored) {
transform.scale(-1, 1, 1);
}
transform.translate(-.5, 0, -.5);
return transform;
}
//WIRE STUFF
@Override
public boolean canConnect() {
return getForward()==-3;
}
@Override
public boolean isEnergyOutput() {
return getForward()==-3&&getRight()==1;
}
@Override
public int outputEnergy(int amount, boolean simulate, int energyType) {
TileEntityMarx master = master(this);
if (master!=null) {
return (int) master.storage.insertIF(amount, !simulate);
} else {
return 0;
}
}
@Override
public double insertEnergy(double eu, boolean simulate) {
TileEntityMarx master = master(this);
if (master!=null) {
return eu-master.storage.insertEU(eu, !simulate);
} else {
return 0;
}
}
@Override
public BlockPos getConnectionMaster(@Nullable WireType cableType, TargetingInfo target) {
return pos;
}
@Override
public boolean canConnectCable(WireType cableType, TargetingInfo target) {
if (hasConnection) {
return false;
}
if (getRight()==0) {
return cableType==WireType.REDSTONE;
} else {
return cableType==WireType.STEEL||cableType== IC2Wiretype.IC2_TYPES[3];
}
}
@Override
public void connectCable(WireType cableType, TargetingInfo target, IImmersiveConnectable other) {
hasConnection = true;
}
@Override
public WireType getCableLimiter(TargetingInfo target) {
return getRight()==0?WireType.REDSTONE:IC2Wiretype.IC2_TYPES[3];
}
@Override
public boolean allowEnergyToPass(ImmersiveNetHandler.Connection con) {
return false;
}
@Override
public void onEnergyPassthrough(int amount) {
}
@Override
public void removeCable(ImmersiveNetHandler.Connection connection) {
hasConnection = false;
}
@Override
public Vec3d getRaytraceOffset(IImmersiveConnectable link) {
Matrix4 transf = getBaseTransform();
if (getRight()==0) {
return transf.apply(new Vec3d(.5, .5, 7/16D));
} else {
return transf.apply(new Vec3d(.5, .5, 4/16D));
}
}
@Override
public Vec3d getConnectionOffset(ImmersiveNetHandler.Connection con) {
return getRaytraceOffset(null);
}
private RedstoneWireNetwork net = new RedstoneWireNetwork().add(this);
@Override
public void setNetwork(RedstoneWireNetwork net) {
this.net = net;
}
@Override
public RedstoneWireNetwork getNetwork() {
return net;
}
@Override
public void onChange() {
//TODO
}
@Override
public World getConnectorWorld() {
return world;
}
@Override
public void updateInput(byte[] signals) {
//TODO
}
public enum FiringState {
CHARGING,
NEXT_TICK,

View file

@ -111,6 +111,9 @@ public class ClientProxy extends CommonProxy {
IndustrialWires.MODID + ":blocks/ic2_relay_glass"));
ConnLoader.baseModels.put("rs_panel_conn", new ResourceLocation("industrialwires:block/rs_panel_conn.obj"));
ConnLoader.baseModels.put("empty", new ResourceLocation("builtin/generated"));
for (int meta = 0; meta < ItemIC2Coil.subNames.length; meta++) {
ResourceLocation loc = new ResourceLocation(IndustrialWires.MODID, "ic2_wire_coil/" + ItemIC2Coil.subNames[meta]);
ModelBakery.registerItemVariants(IndustrialWires.coil, loc);

View file

@ -18,6 +18,7 @@
package malte0811.industrialWires.client.render;
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
import malte0811.industrialWires.blocks.IWProperties;
import malte0811.industrialWires.blocks.hv.TileEntityMarx;
import malte0811.industrialWires.util.MiscUtils;
@ -29,13 +30,16 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.vector.Vector3f;
public class TileRenderMarx extends TileEntitySpecialRenderer<TileEntityMarx> {
@Override
public void renderTileEntityAt(TileEntityMarx te, double x, double y, double z, float partialTicks, int destroyStage) {
if (te.type== IWProperties.MarxType.BOTTOM&&te.state== TileEntityMarx.FiringState.FIRE) {
final boolean debug = false;
//noinspection PointlessBooleanExpression
if (te.type== IWProperties.MarxType.BOTTOM&&(debug||te.state== TileEntityMarx.FiringState.FIRE)) {
prepare(x, y, z, te);
Tessellator tes = Tessellator.getInstance();
VertexBuffer vb = tes.getBuffer();
@ -59,8 +63,8 @@ public class TileRenderMarx extends TileEntitySpecialRenderer<TileEntityMarx> {
tes.draw();
GlStateManager.popMatrix();
}
cleanUp();
te.state = TileEntityMarx.FiringState.CHARGING;
}
}
private void prepare(double x, double y, double z, TileEntityMarx te) {
@ -112,5 +116,60 @@ public class TileRenderMarx extends TileEntitySpecialRenderer<TileEntityMarx> {
public float energy;
public Vector3f[] vertices;
public float diameter = .25F;
public final int stageCount;
public Discharge(int stages) {
stageCount = stages;
int count = 1;
while (count<stageCount) {
count <<= 1;
}
count = 8;
vertices = new Vector3f[2*count];
vertices[0] = new Vector3f(0, -.5F, 0);
for (int i = 1;i<vertices.length;i++) {
vertices[i] = new Vector3f();
}
vertices[vertices.length-1] = new Vector3f(0, stageCount-1.9375F, 0);
}
// Meant to be const
private final Vector3f up = new Vector3f(0, 1, 0);
private final Vector3f side = new Vector3f(0, 0, 1);
//used for calculation buffering
private final Vector3f diff = new Vector3f();
private final Vector3f center = new Vector3f();
private final Vector3f v0 = new Vector3f();
private final Matrix4 transform = new Matrix4();
/**
* @param min The first point of the discharge section to be generated. has to be pre-populated
* @param max The last point of the discharge section to be generated. has to be pre-populated
*/
public void genMarxPoint(int min, int max) {
World world = Minecraft.getMinecraft().world;
int toGenerate = (min+max)/2;
Vector3f.sub(vertices[max], vertices[min], diff);
Vector3f.cross(diff, side, v0);
transform.setIdentity();
double noise = Math.sqrt(diff.length())*world.rand.nextDouble()*1/(1+Math.abs(stageCount/2.0-toGenerate))*.75;
if ((max-min)%2==1) {
noise *= (toGenerate-min)/(double)(max-min);
}
v0.scale((float) (noise/v0.length()));
diff.scale(1/diff.length());
transform.rotate(Math.PI*2*world.rand.nextDouble(), diff.x, diff.y, diff.z);
Vector3f.add(vertices[max], vertices[min], center);
center.scale(.5F);
vertices[toGenerate] = transform.apply(v0);
//IELogger.info(toGenerate+" with noise "+noise+" shift-to-noise "+vertices[toGenerate].length()/noise);
Vector3f.add(vertices[toGenerate], center, vertices[toGenerate]);
if (toGenerate-min>1) {
genMarxPoint(min, toGenerate);
}
if (max-toGenerate>1) {
genMarxPoint(toGenerate, max);
}
}
}
}

View file

@ -22,6 +22,7 @@ import blusunrize.immersiveengineering.common.util.IELogger;
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
import malte0811.industrialWires.client.RawQuad;
import malte0811.industrialWires.client.gui.GuiPanelCreator;
import malte0811.industrialWires.util.MiscUtils;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderGlobal;
@ -165,7 +166,7 @@ public abstract class PanelComponent {
double px = te.getPos().getX() - TileEntityRendererDispatcher.staticPlayerX;
double py = te.getPos().getY() - TileEntityRendererDispatcher.staticPlayerY;
double pz = te.getPos().getZ() - TileEntityRendererDispatcher.staticPlayerZ;
RenderGlobal.drawSelectionBoundingBox(te.apply(te.getComponents().getPanelTopTransform(), getBlockRelativeAABB()).expandXyz(0.002).offset(px, py, pz),
RenderGlobal.drawSelectionBoundingBox(MiscUtils.apply(te.getComponents().getPanelTopTransform(), getBlockRelativeAABB()).expandXyz(0.002).offset(px, py, pz),
0.0F, 0.0F, 0.0F, 0.4F);
GlStateManager.depthMask(true);
GlStateManager.enableTexture2D();

View file

@ -21,11 +21,15 @@ package malte0811.industrialWires.util;
import blusunrize.immersiveengineering.api.ApiUtils;
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
import com.google.common.collect.ImmutableSet;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@ -94,4 +98,12 @@ public final class MiscUtils {
}
return p.offset(f, forward).offset(f.rotateY(), right).add(0, up, 0);
}
@Nonnull
public static AxisAlignedBB apply(@Nonnull Matrix4 mat, @Nonnull AxisAlignedBB in) {
Vec3d min = new Vec3d(in.minX, in.minY, in.minZ);
Vec3d max = new Vec3d(in.maxX, in.maxY, in.maxZ);
min = mat.apply(min);
max = mat.apply(max);
return new AxisAlignedBB(min.xCoord, min.yCoord, min.zCoord, max.xCoord, max.yCoord, max.zCoord);
}
}

View file

@ -27,6 +27,9 @@
},
"no_model": {
"model": "builtin/generated"
},
"connector": {
"model": "immersiveengineering:smartmodel/conn_empty"
}
},
"facing": {