the black mesa rail network

This commit is contained in:
Boblet 2023-05-03 14:15:16 +02:00
parent dd2f929821
commit ec63136436
3 changed files with 104 additions and 4 deletions

View File

@ -35,6 +35,16 @@ public abstract class EntityRailCarBase extends Entity {
@Override protected void readEntityFromNBT(NBTTagCompound nbt) { }
@Override protected void writeEntityToNBT(NBTTagCompound nbt) { }
@Override
public boolean canBePushed() {
return true;
}
@Override
public boolean canBeCollidedWith() {
return !this.isDead;
}
@Override
public void onUpdate() {
@ -67,10 +77,11 @@ public abstract class EntityRailCarBase extends Entity {
Vec3 frontPos = getRelPosAlongRail(anchor, this.getLengthSpan());
Vec3 backPos = getRelPosAlongRail(anchor, -this.getLengthSpan());
if(frontPos == null) this.derail();
if(backPos == null) this.derail();
if(frontPos != null && backPos != null) this.rotationYaw = generateYaw(frontPos, backPos);
if(frontPos == null || backPos == null) {
this.derail();
} else {
this.rotationYaw = generateYaw(frontPos, backPos);
}
}
}
}

View File

@ -0,0 +1,43 @@
package com.hbm.entity.train;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public abstract class EntityRailCarRidable extends EntityRailCarBase {
public EntityRailCarRidable(World world) {
super(world);
}
@Override
public boolean interactFirst(EntityPlayer player) {
if(this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != player) {
return true;
} else {
if(!this.worldObj.isRemote) {
player.mountEntity(this);
}
return true;
}
}
@Override
public void onUpdate() {
super.onUpdate();
}
@Override
public void updateRiderPosition() {
Vec3 offset = getRiderSeatPosition();
offset.rotateAroundY(this.rotationYaw);
if(this.riddenByEntity != null) {
this.riddenByEntity.setPosition(this.posX + offset.xCoord, this.posY + offset.yCoord, this.posZ + offset.zCoord);
}
}
/** Returns a Vec3 showing the relative position from the driver to the core */
public abstract Vec3 getRiderSeatPosition();
}

View File

@ -0,0 +1,46 @@
package com.hbm.entity.train;
import com.hbm.blocks.rail.IRailNTM.TrackGauge;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class TrainCargoTram extends EntityRailCarRidable {
/*
*
* _________
* | | \ <--
* | | |___
* | | | | |
* _O\|_|_______|__|_____________________________|/O_
* |____| |____|
* \__________________________________________/
* '( + )' '( + )'
*
*/
public TrainCargoTram(World world) {
super(world);
}
@Override
public double getCurrentSpeed() {
return 0;
}
@Override
public TrackGauge getGauge() {
return TrackGauge.STANDARD;
}
@Override
public double getLengthSpan() {
return 2;
}
@Override
public Vec3 getRiderSeatPosition() {
return Vec3.createVectorHelper(1, 1, 0);
}
}