and now everything is broken

This commit is contained in:
Bob 2023-12-27 17:59:28 +01:00
parent 13debc2cab
commit 8b4e4bf4f3
16 changed files with 4427 additions and 22 deletions

View File

@ -1174,6 +1174,7 @@ public class ModBlocks {
public static Block rail_large_curve;
public static Block rail_large_ramp;
public static Block rail_large_buffer;
public static Block rail_large_switch;
public static Block statue_elb;
public static Block statue_elb_g;
@ -2251,6 +2252,7 @@ public class ModBlocks {
rail_large_curve = new RailStandardCurve().setBlockName("rail_large_curve").setHardness(5.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":rail_standard_straight");
rail_large_ramp = new RailStandardRamp().setBlockName("rail_large_ramp").setHardness(5.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":rail_standard_straight");
rail_large_buffer = new RailStandardBuffer().setBlockName("rail_large_buffer").setHardness(5.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":rail_standard_buffer");
rail_large_switch = new RailStandardSwitch().setBlockName("rail_large_switch").setHardness(5.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":rail_standard_straight");
crate = new BlockCrate(Material.wood).setBlockName("crate").setStepSound(Block.soundTypeWood).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.consumableTab).setBlockTextureName(RefStrings.MODID + ":crate");
crate_weapon = new BlockCrate(Material.wood).setBlockName("crate_weapon").setStepSound(Block.soundTypeWood).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.consumableTab).setBlockTextureName(RefStrings.MODID + ":crate_weapon");
@ -3551,6 +3553,7 @@ public class ModBlocks {
register(rail_large_curve);
register(rail_large_ramp);
register(rail_large_buffer);
register(rail_large_switch);
//Crate
GameRegistry.registerBlock(crate, crate.getUnlocalizedName());

View File

@ -0,0 +1,203 @@
package com.hbm.blocks.rail;
import java.util.ArrayList;
import java.util.List;
import com.hbm.blocks.BlockDummyable;
import com.hbm.entity.train.EntityRailCarBase;
import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.PlayerInformPacket;
import com.hbm.util.BobMathUtil;
import com.hbm.util.ChatBuilder;
import com.hbm.util.ParticleUtil;
import com.hbm.util.Tuple.Pair;
import com.hbm.util.fauxpointtwelve.BlockPos;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.block.material.Material;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public abstract class BlockRailWaypointSystem extends BlockDummyable implements IRailNTM {
public List<RailDef> railDefs = new ArrayList();
public BlockRailWaypointSystem(Material mat) {
super(mat);
}
/** Whether the train at position FROM can move towards the waypoint TO along the supplied railDef, also supplies world and core position */
public boolean canCross(World world, int x, int y, int z, Vec3 from, Vec3 to, RailDef def) {
return true;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
this.setBlockBounds(0F, 0F, 0F, 1F, 0.125F, 1F);
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
this.setBlockBounds(0F, 0F, 0F, 1F, 0.125F, 1F);
return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ);
}
@Override
public Vec3 getSnappingPos(World world, int x, int y, int z, double trainX, double trainY, double trainZ) {
return snapAndMove(world, x, y, z, trainX, trainY, trainZ, 0, 0, 0, 0, new RailContext());
}
@Override
public Vec3 getTravelLocation(World world, int x, int y, int z, double trainX, double trainY, double trainZ, double motionX, double motionY, double motionZ, double speed, RailContext info, MoveContext context) {
return snapAndMove(world, x, y, z, trainX, trainY, trainZ, motionX, motionY, motionZ, speed, info);
}
public Vec3 snapAndMove(World world, int x, int y, int z, double trainX, double trainY, double trainZ, double motionX, double motionY, double motionZ, double speed, RailContext info) {
int[] pos = this.findCore(world, x, y, z);
if(pos == null) return Vec3.createVectorHelper(trainX, trainY, trainZ);
int cX = pos[0];
int cY = pos[1];
int cZ = pos[2];
int meta = world.getBlockMetadata(cX, cY, cZ);
double moveAngle = Math.atan2(motionX, motionZ) * 180D / Math.PI + 90;
Vec3 trainPos = Vec3.createVectorHelper(trainX, trainY, trainZ);
//convert nodes to a list of links with in-world positions
Vec3 train = Vec3.createVectorHelper(trainX, trainY, trainZ);
Vec3 core = Vec3.createVectorHelper(cX + 0.5, cY, cZ + 0.5);
List<List<Pair<Vec3[], RailDef>>> links = new ArrayList();
for(RailDef def : railDefs) {
List<Pair<Vec3[], RailDef>> linkList = new ArrayList();
links.add(linkList);
for(int i = 0; i < def.nodes.size() - 1; i++) {
Vec3 vec1 = getPositionFromNode(world, x, y, z, core, def.nodes.get(i), meta);
Vec3 vec2 = getPositionFromNode(world, x, y, z, core, def.nodes.get(i + 1), meta);
ParticleUtil.spawnDroneLine(world, vec1.xCoord, vec1.yCoord, vec1.zCoord, vec2.xCoord - vec1.xCoord, vec2.yCoord - vec1.yCoord, vec2.zCoord - vec1.zCoord, 0xff0000);
linkList.add(new Pair<Vec3[], RailDef>(new Vec3[] {vec1, vec2}, def));
}
}
//find closest node
Pair<Vec3[], RailDef> closest = null;
Vec3 startingPos = null;
/** closest chain of link definitions */
List<Pair<Vec3[], RailDef>> cDef = null;
double angularDiff = 0;
double linkAngle = 0;
double dist = Double.MAX_VALUE;
/** direction */
boolean d = true;
for(List<Pair<Vec3[], RailDef>> chain : links) {
for(Pair<Vec3[], RailDef> link : chain) {
Vec3[] array = link.getKey();
Vec3 point = getClosestPointOnLink(array[0], array[1], train);
if(point != null) {
Vec3 delta = point.subtract(train);
double length = delta.lengthVector();
if(!canCross(world, cX, cY, cZ, trainPos, point, link.getValue())) continue;
linkAngle = EntityRailCarBase.generateYaw(array[1], array[0]);
angularDiff = BobMathUtil.angularDifference(linkAngle, -moveAngle);
if(angularDiff < -180) { angularDiff += 180; linkAngle += 180; d = false; }
if(angularDiff > 0) { angularDiff -= 180; linkAngle -= 180; d = false; }
if(length < dist) {
closest = link;
startingPos = point;
cDef = chain;
dist = length;
}
}
}
}
if(closest == null) {
return Vec3.createVectorHelper(trainX, trainY, trainZ);
}
double distRemaining = speed;
boolean engaged = false;
Vec3 currentPos = startingPos;
for(int i = d ? 0 : cDef.size() - 1; d ? (i < cDef.size()) : (i >= 0); i += d ? 1 : -1) {
Pair<Vec3[], RailDef> link = cDef.get(i);
Vec3[] array = link.getKey();
if(!engaged) {
if(link == closest) {
engaged = true;
} else {
continue;
}
}
Vec3 nextNode = array[d?1:0];
Vec3 delta = nextNode.subtract(currentPos);
if(!canCross(world, cX, cY, cZ, currentPos, nextNode, link.getValue())) break;
double len = delta.lengthVector();
if(len >= distRemaining) {
info.overshoot = 0;
double newYaw = EntityRailCarBase.generateYaw(nextNode, currentPos);
if(Math.abs(BobMathUtil.angularDifference(newYaw, moveAngle)) < 45) info.yaw = (float) newYaw;
else info.yaw = (float) moveAngle;
delta.normalize();
return Vec3.createVectorHelper(currentPos.xCoord - delta.xCoord * distRemaining / len, currentPos.yCoord - delta.yCoord * distRemaining / len, currentPos.zCoord - delta.zCoord * distRemaining / len);
}
distRemaining -= len;
currentPos = nextNode;
}
if(!world.isRemote) PacketDispatcher.wrapper.sendToAllAround(new PlayerInformPacket(ChatBuilder.start("" + distRemaining).color(EnumChatFormatting.RED).flush(), 1), new TargetPoint(world.provider.dimensionId, x, y, z, 50));
info.overshoot = distRemaining;
info.pos = new BlockPos(currentPos.xCoord, currentPos.yCoord, currentPos.zCoord);
return currentPos;
}
public Vec3 getClosestPointOnLink(Vec3 pointA, Vec3 pointB, Vec3 pointP) {
Vec3 ap = Vec3.createVectorHelper(pointP.xCoord - pointA.xCoord, 0, pointP.zCoord - pointA.zCoord);
Vec3 ab = Vec3.createVectorHelper(pointB.xCoord - pointA.xCoord, 0, pointB.zCoord - pointA.zCoord);
double magAB = ab.xCoord * ab.xCoord + ab.zCoord * ab.zCoord;
double dotProd = ap.xCoord * ab.xCoord + ap.zCoord * ab.zCoord;
double dist = dotProd / magAB;
if(dist < 0) return pointA;
if(dist > 1) return pointB;
if(dist < 0 || dist > 1) return null;
return Vec3.createVectorHelper(pointA.xCoord + ab.xCoord * dist, pointA.yCoord + (pointB.yCoord - pointA.yCoord) * dist, pointA.zCoord + ab.zCoord * dist);
}
/** Creates the in-world position for a node based on the node itself and the core position */
public Vec3 getPositionFromNode(World world, int x, int y, int z, Vec3 core, Vec3 node, int meta) {
float rotation = 0;
if(meta == 12) rotation = 90F / 180F * (float) Math.PI;
if(meta == 14) rotation = 180F / 180F * (float) Math.PI;
if(meta == 13) rotation = 270F / 180F * (float) Math.PI;
Vec3 copy = Vec3.createVectorHelper(node.xCoord, node.yCoord, node.zCoord);
copy.rotateAroundY(rotation);
return core.addVector(copy.xCoord, copy.yCoord, copy.zCoord);
}
public class RailDef {
String name;
public List<Vec3> nodes = new ArrayList();
public RailDef(String name) {
this.name = name;
}
}
}

View File

@ -17,7 +17,7 @@ public interface IRailNTM {
* Inherently safer than simply adding the motion to the position and then snapping, since that may lead to derailing.
* The motion has to be calculated from the train's rotation (rotated 180° when going backwards), the scalar doesn't matter since it's only used for determining orientation in a clear way.
* Motion ends up being *-1 if the train is going in reverse, still pointing forwards despite the speed being negative.
* Also features a double[] wrapper with size 1 which holds the speed value that overshoots the rail.
* Also features RailContext which determines overshoot and the final yaw rotation
* */
public Vec3 getTravelLocation(World world, int x, int y, int z, double trainX, double trainY, double trainZ, double motionX, double motionY, double motionZ, double speed, RailContext info, MoveContext context);
@ -46,8 +46,10 @@ public interface IRailNTM {
public static class MoveContext {
public RailCheckType type;
public double collisionBogieDistance;
public boolean collision = false; //if a buffer stop or similar applies
public double overshoot; //how much of the travel distance was cut short
/** if a buffer stop or similar applies */
public boolean collision = false;
/** how much of the travel distance was cut short */
public double overshoot;
public MoveContext(RailCheckType type, double collisionBogieDistance) {
this.type = type;

View File

@ -1,5 +1,6 @@
package com.hbm.blocks.rail;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
@ -8,6 +9,8 @@ import net.minecraft.world.IBlockAccess;
public interface IRenderRail {
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
@SideOnly(Side.CLIENT) public void renderInventory(Tessellator tessellator, Block block, int metadata);
@SideOnly(Side.CLIENT) public void renderWorld(Tessellator tessellator, Block block, int meta, IBlockAccess world, int x, int y, int z);
}

View File

@ -35,7 +35,7 @@ public class RailNarrowCurve extends BlockDummyable implements IRailNTM, IRender
@Override
public int getRenderType() {
return RailStandardStraight.renderID;
return renderID;
}
@Override

View File

@ -35,7 +35,7 @@ public class RailNarrowStraight extends BlockDummyable implements IRailNTM, IRen
@Override
public int getRenderType() {
return RailStandardStraight.renderID;
return renderID;
}
@Override

View File

@ -34,7 +34,7 @@ public class RailStandardBuffer extends BlockDummyable implements IRailNTM, IRen
@Override
public int getRenderType() {
return RailStandardStraight.renderID;
return renderID;
}
@Override

View File

@ -35,7 +35,7 @@ public class RailStandardCurve extends BlockDummyable implements IRailNTM, IRend
@Override
public int getRenderType() {
return RailStandardStraight.renderID;
return renderID;
}
@Override

View File

@ -41,7 +41,7 @@ public class RailStandardRamp extends BlockDummyable implements IRailNTM, IRende
@Override
public int getRenderType() {
return RailStandardStraight.renderID;
return renderID;
}
@Override

View File

@ -8,7 +8,6 @@ import com.hbm.main.ResourceManager;
import com.hbm.render.util.ObjUtil;
import com.hbm.util.fauxpointtwelve.BlockPos;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
@ -34,8 +33,6 @@ public class RailStandardStraight extends BlockDummyable implements IRailNTM, IR
return null;
}
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
@Override
public int getRenderType() {
return renderID;

View File

@ -0,0 +1,269 @@
package com.hbm.blocks.rail;
import org.lwjgl.opengl.GL11;
import com.hbm.blocks.BlockDummyable;
import com.hbm.lib.Library;
import com.hbm.lib.RefStrings;
import com.hbm.main.ResourceManager;
import com.hbm.render.util.ObjUtil;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.model.obj.WavefrontObject;
import net.minecraftforge.common.util.ForgeDirection;
public class RailStandardSwitch extends BlockRailWaypointSystem implements IRenderRail {
@SideOnly(Side.CLIENT) private IIcon iconSign;
public RailStandardSwitch() {
super(Material.iron);
RailDef main = new RailDef("main");
RailDef side = new RailDef("side");
railDefs.add(main);
railDefs.add(side);
main.nodes.add(Vec3.createVectorHelper(-8.5, 0.1875, 0.5));
main.nodes.add(Vec3.createVectorHelper(-7.5, 0.1875, 0.5));
main.nodes.add(Vec3.createVectorHelper(6.5, 0.1875, 0.5));
main.nodes.add(Vec3.createVectorHelper(7.5, 0.1875, 0.5));
main.nodes.add(Vec3.createVectorHelper(8.5, 0.1875, 0.5));
side.nodes.add(Vec3.createVectorHelper(-8.5, 0.1875, 4.5));
side.nodes.add(Vec3.createVectorHelper(-7.5, 0.1875, 4.5));
side.nodes.add(Vec3.createVectorHelper(-6.5, 0.1875, 4.5));
side.nodes.add(Vec3.createVectorHelper(-5.5, 0.1875, 4.5));
side.nodes.add(Vec3.createVectorHelper(-4.5, 0.1875, 4.5));
side.nodes.add(Vec3.createVectorHelper(-3.5, 0.1875, 4.5));
side.nodes.add(Vec3.createVectorHelper(-2.5, 0.1875, 4.5));
side.nodes.add(Vec3.createVectorHelper(-1.5, 0.1875, 4.5));
side.nodes.add(Vec3.createVectorHelper(-0.5, 0.1875, 4.25));
side.nodes.add(Vec3.createVectorHelper(0.5, 0.1875, 3.9375));
side.nodes.add(Vec3.createVectorHelper(1.5, 0.1875, 3.375));
side.nodes.add(Vec3.createVectorHelper(2.5, 0.1875, 2.4625));
side.nodes.add(Vec3.createVectorHelper(3.5, 0.1875, 1.75));
side.nodes.add(Vec3.createVectorHelper(4.5, 0.1875, 1.1875));
side.nodes.add(Vec3.createVectorHelper(5.5, 0.1875, 0.875));
side.nodes.add(Vec3.createVectorHelper(6.5, 0.1875, 0.625));
side.nodes.add(Vec3.createVectorHelper(7.5, 0.1875, 0.5));
side.nodes.add(Vec3.createVectorHelper(8.5, 0.1875, 0.5));
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
super.registerBlockIcons(iconRegister);
this.iconSign = iconRegister.registerIcon(RefStrings.MODID + ":rail_switch_sign");
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityRailSwitch();
}
@Override
public int getRenderType() {
return renderID;
}
@Override
public int[] getDimensions() {
return new int[] {0, 0, 7, 7, 1, 0};
}
@Override
public int getOffset() {
return 7;
}
@Override
public TrackGauge getGauge(World world, int x, int y, int z) {
return TrackGauge.STANDARD;
}
@Override
public boolean canCross(World world, int x, int y, int z, Vec3 from, Vec3 to, RailDef def) {
TileEntityRailSwitch tile = (TileEntityRailSwitch) world.getTileEntity(x, y, z);
if(tile == null) return true;
ForgeDirection dir = ForgeDirection.getOrientation(tile.getBlockMetadata() - 10);
if(dir == Library.POS_X) if(from.xCoord < to.xCoord) return true;
if(dir == Library.NEG_X) if(from.xCoord > to.xCoord) return true;
if(dir == Library.POS_Z) if(from.zCoord < to.zCoord) return true;
if(dir == Library.NEG_Z) if(from.zCoord > to.zCoord) return true;
if(dir == Library.POS_X) if(to.xCoord < x + 0.5 + 7) return true;
if(dir == Library.NEG_X) if(to.xCoord > x + 0.5 - 7) return true;
if(dir == Library.POS_Z) if(to.zCoord < z + 0.5 + 7) return true;
if(dir == Library.NEG_Z) if(to.zCoord > z + 0.5 - 7) return true;
if(tile.isSwitched) {
if("side".equals(def.name)) return true;
} else {
if("main".equals(def.name)) return true;
}
return false;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(world.isRemote) return true;
if(player.isSneaking()) return false;
int[] pos = this.findCore(world, x, y, z);
if(pos != null) {
TileEntity tile = world.getTileEntity(pos[0], pos[1], pos[2]);
if(tile instanceof TileEntityRailSwitch) {
TileEntityRailSwitch sw = (TileEntityRailSwitch) tile;
sw.isSwitched = !sw.isSwitched;
sw.markDirty();
world.markBlockForUpdate(pos[0], pos[1], pos[2]);
}
}
return true;
}
@Override
public Vec3 snapAndMove(World world, int x, int y, int z, double trainX, double trainY, double trainZ, double motionX, double motionY, double motionZ, double speed, RailContext info) {
return super.snapAndMove(world, x, y, z, trainX, trainY, trainZ, motionX, motionY, motionZ, speed, info);
}
@Override
protected boolean checkRequirement(World world, int x, int y, int z, ForgeDirection dir, int o) {
if(!super.checkRequirement(world, x, y, z, dir, o)) return false;
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
dir = dir.getOpposite();
int dX = dir.offsetX;
int dZ = dir.offsetZ;
int rX = rot.offsetX;
int rZ = rot.offsetZ;
for(int i = 0; i < 4; i++) if(!world.getBlock(x + dX * (2 + i) + rX * 2, y, z + dZ * (2 + i) + rZ * 2).isReplaceable(world, x + dX * (2 + i) + rX * 2, y, z + dZ * (2 + i) + rZ * 2)) return false;
for(int i = 0; i < 2; i++) if(!world.getBlock(x + dX * (4 + i) + rX * 3, y, z + dZ * (4 + i) + rZ * 3).isReplaceable(world, x + dX * (4 + i) + rX * 3, y, z + dZ * (4 + i) + rZ * 3)) return false;
if(!world.getBlock(x + dX * 5 + rX * 4, y, z + dZ * 5 + rZ * 4).isReplaceable(world, x + dX * 5 + rX * 4, y, z + dZ * 5 + rZ * 4)) return false;
for(int j = 0; j < 2; j++) for(int i = 0; i < 2; i++) if(!world.getBlock(x + dX * (6 + j) + rX * (3 + i), y, z + dZ * (6 + j) + rZ * (3 + i)).isReplaceable(world, x + dX * (6 + j) + rX * (3 + i), y, z + dZ * (6 + j) + rZ * (3 + i))) return false;
if(!world.getBlock(x + dX * 7 + rX * 5, y, z + dZ * 7 + rZ * 5).isReplaceable(world, x + dX * 7 + rX * 5, y, z + dZ * 7 + rZ * 5)) return false;
for(int j = 0; j < 7; j++) for(int i = 0; i < 2; i++) if(!world.getBlock(x + dX * (8 + j) + rX * (4 + i), y, z + dZ * (8 + j) + rZ * (4 + i)).isReplaceable(world, x + dX * (8 + j) + rX * (4 + i), y, z + dZ * (8 + j) + rZ * (4 + i))) return false;
return true;
}
@Override
protected void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) {
super.fillSpace(world, x, y, z, dir, o);
BlockDummyable.safeRem = true;
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
dir = dir.getOpposite();
int dX = dir.offsetX;
int dZ = dir.offsetZ;
int rX = rot.offsetX;
int rZ = rot.offsetZ;
for(int i = 0; i < 4; i++) world.setBlock(x + dX * (2 + i) + rX * 2, y, z + dZ * (2 + i) + rZ * 2, this, rot.ordinal(), 3);
for(int i = 0; i < 2; i++) world.setBlock(x + dX * (4 + i) + rX * 3, y, z + dZ * (4 + i) + rZ * 3, this, rot.ordinal(), 3);
world.setBlock(x + dX * 5 + rX * 4, y, z + dZ * 5 + rZ * 4, this, rot.ordinal(), 3);
for(int j = 0; j < 2; j++) for(int i = 0; i < 2; i++) world.setBlock(x + dX * (6 + j) + rX * (3 + i), y, z + dZ * (6 + j) + rZ * (3 + i), this, dir.ordinal(), 3);
world.setBlock(x + dX * 7 + rX * 5, y, z + dZ * 7 + rZ * 5, this, rot.ordinal(), 3);
for(int j = 0; j < 7; j++) for(int i = 0; i < 2; i++) world.setBlock(x + dX * (8 + j) + rX * (4 + i), y, z + dZ * (8 + j) + rZ * (4 + i), this, dir.ordinal(), 3);
BlockDummyable.safeRem = false;
}
@Override
@SideOnly(Side.CLIENT)
public void renderInventory(Tessellator tessellator, Block block, int metadata) {
GL11.glTranslated(0, -0.0625, -0.1875);
GL11.glRotated(90, 0, 1, 0);
GL11.glScaled(0.1, 0.1, 0.1);
tessellator.startDrawingQuads();
ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.rail_standard_switch, "Rail", this.blockIcon, tessellator, 0, false);
tessellator.draw();
}
@Override
@SideOnly(Side.CLIENT)
public void renderWorld(Tessellator tessellator, Block block, int meta, IBlockAccess world, int x, int y, int z) {
if(meta < 12) return;
float rotation = 0;
if(meta == 15) rotation = 90F / 180F * (float) Math.PI;
if(meta == 12) rotation = 180F / 180F * (float) Math.PI;
if(meta == 14) rotation = 270F / 180F * (float) Math.PI;
if(meta == 12) tessellator.addTranslation(0.5F, 0F, 0F);
if(meta == 13) tessellator.addTranslation(-0.5F, 0F, 0F);
if(meta == 14) tessellator.addTranslation(0F, 0F, -0.5F);
if(meta == 15) tessellator.addTranslation(0F, 0F, 0.5F);
tessellator.addTranslation(x + 0.5F, y, z + 0.5F);
ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.rail_standard_switch, "Rail", this.blockIcon, tessellator, rotation, true);
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TileEntityRailSwitch) {
TileEntityRailSwitch sw = (TileEntityRailSwitch) tile;
ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.rail_standard_switch, sw.isSwitched ? "SignTurn" : "SignStraight", this.iconSign, tessellator, rotation, true);
}
tessellator.addTranslation(-x - 0.5F, -y, -z - 0.5F);
if(meta == 12) tessellator.addTranslation(-0.5F, 0F, 0F);
if(meta == 13) tessellator.addTranslation(0.5F, 0F, 0F);
if(meta == 14) tessellator.addTranslation(0F, 0F, 0.5F);
if(meta == 15) tessellator.addTranslation(0F, 0F, -0.5F);
}
public static class TileEntityRailSwitch extends TileEntity {
public boolean isSwitched = false;
@Override public boolean canUpdate() { return false; }
@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbt = new NBTTagCompound();
this.writeToNBT(nbt);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbt);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
this.readFromNBT(pkt.func_148857_g());
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.isSwitched = nbt.getBoolean("isSwitched");
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setBoolean("isSwitched", this.isSwitched);
}
}
}

View File

@ -207,7 +207,6 @@ public abstract class EntityRailCarBase extends Entity implements ILookOverlay {
double z = posZ + rot.zCoord;
dummy.setPosition(x, y, z);
dummy.setSize(def.width, def.height);
dummy.velocityChanged = true;
worldObj.spawnEntityInWorld(dummy);
this.dummies[i] = dummy;
}
@ -215,16 +214,18 @@ public abstract class EntityRailCarBase extends Entity implements ILookOverlay {
this.initDummies = true;
}
for(int i = 0; i < definitions.length; i++) {
DummyConfig def = definitions[i];
BoundingBoxDummyEntity dummy = dummies[i];
Vec3 rot = Vec3.createVectorHelper(def.offset.xCoord, def.offset.yCoord, def.offset.zCoord);
rot.rotateAroundX((float) (this.rotationPitch * Math.PI / 180D));
rot.rotateAroundY((float) (-this.rotationYaw * Math.PI / 180));
double x = renderX + rot.xCoord;
double y = renderY + rot.yCoord;
double z = renderZ + rot.zCoord;
dummy.setPosition(x, y, z);
if(renderY != 0) {
for(int i = 0; i < definitions.length; i++) {
DummyConfig def = definitions[i];
BoundingBoxDummyEntity dummy = dummies[i];
Vec3 rot = Vec3.createVectorHelper(def.offset.xCoord, def.offset.yCoord, def.offset.zCoord);
rot.rotateAroundX((float) (this.rotationPitch * Math.PI / 180D));
rot.rotateAroundY((float) (-this.rotationYaw * Math.PI / 180));
double x = renderX + rot.xCoord;
double y = renderY + rot.yCoord;
double z = renderZ + rot.zCoord;
dummy.setPosition(x, y, z);
}
}
}
}

View File

@ -1467,6 +1467,7 @@ public class ResourceManager {
public static final IModelCustom rail_standard_curve = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/blocks/rail_standard_bend.obj"));
public static final IModelCustom rail_standard_ramp = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/blocks/rail_standard_ramp.obj"));
public static final IModelCustom rail_standard_buffer = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/blocks/rail_standard_buffer.obj"));
public static final IModelCustom rail_standard_switch = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/blocks/rail_standard_switch.obj"));
public static final IModelCustom capacitor = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/blocks/capacitor.obj"));
public static final IModelCustom charge_dynamite = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/blocks/charge_dynamite.obj"));

View File

@ -25,6 +25,7 @@ import com.hbm.blocks.network.BlockCablePaintable.TileEntityCablePaintable;
import com.hbm.blocks.network.CableDiode.TileEntityDiode;
import com.hbm.blocks.network.FluidDuctGauge.TileEntityPipeGauge;
import com.hbm.blocks.network.FluidDuctPaintable.TileEntityPipePaintable;
import com.hbm.blocks.rail.RailStandardSwitch.TileEntityRailSwitch;
import com.hbm.interfaces.IFluidAcceptor;
import com.hbm.interfaces.IFluidSource;
import com.hbm.tileentity.bomb.*;
@ -407,6 +408,8 @@ public class TileMappings {
put(TileEntityDroneDock.class, "tileentity_drone_dock");
put(TileEntityDroneProvider.class, "tileentity_drone_provider");
put(TileEntityDroneRequester.class, "tileentity_drone_requester");
put(TileEntityRailSwitch.class, "tileentity_rail_switch");
}
private static void put(Class<? extends TileEntity> clazz, String... names) {

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 583 B