Skip to content

Commit

Permalink
more TC5 APIs backported.
Browse files Browse the repository at this point in the history
  • Loading branch information
EternalBlueFlame committed Jan 5, 2024
1 parent 7f4be14 commit f740f95
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/main/java/train/common/Traincraft.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ public void preInit(FMLPreInitializationEvent event) {
trainCompositeSuit = proxy.addArmor("CompositeSuit");
TCBlocks.init();
TCItems.init();
EntityHandler.init();
proxy.registerTileEntities();
proxy.registerSounds();
proxy.setHook(); // Moved file needed to run JLayer, we need to set a hook in order to retrieve it
Expand Down Expand Up @@ -197,6 +196,7 @@ public void load(FMLInitializationEvent event) {
/* Register the liquids */
tcLog.info("Initialize Fluids");
LiquidManager.getInstance().registerLiquids();
EntityHandler.init();

/* Liquid FX */
proxy.registerTextureFX();
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/train/common/api/AbstractTrains.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import train.common.items.ItemChunkLoaderActivator;
import train.common.items.ItemRollingStock;
import train.common.items.ItemWrench;
import train.common.library.Info;
import train.common.overlaytexture.OverlayTextureManager;

import java.util.*;
Expand Down Expand Up @@ -161,6 +162,7 @@ public void setTrainOwner(String trainOwner) {

public AbstractTrains(World world) {
super(world);
if(world==null){return;}
renderDistanceWeight = 2.0D;
entity_data.putString("color", !getSpec().getLiveries().isEmpty() ? getSpec().getLiveries().get(0) : "");
dataWatcher.addObject(12, entity_data.toXMLString());
Expand Down Expand Up @@ -684,12 +686,12 @@ public String transportFuelType(){
public String[] additionalItemText(){return getSpec().getAdditionnalTooltip().split("\n");}
/**the top speed in km/h for the transport.
* not used tor rollingstock.*/
public int transportTopSpeed(){return getSpec().getMaxSpeed();}
public float transportTopSpeed(){return getSpec().getMaxSpeed();}
/**the top speed in km/h for the transportwhen moving in reverse, default is half for diesel and 75% for others.
* not used tor rollingstock.*/
public float transportTopSpeedReverse(){return this instanceof DieselTrain?transportTopSpeed()*0.5f:transportTopSpeed();}
/**this is the default value to define the acceleration speed and pulling power of a transport.*/
public int transportMetricHorsePower(){return getSpec().getMHP();}
public float transportMetricHorsePower(){return getSpec().getMHP();}
/**the tractive effort for the transport, this is a fallback if metric horsepower (mhp) is not available*/
public float transportTractiveEffort(){return 0;}

Expand Down Expand Up @@ -783,6 +785,13 @@ public Bogie[] bogies(){
* the registerSkins method is only for organization and convenience.*/
public void registerSkins(){}

/**
* return the name for the default TransportSkin of the transport.
*/
public String getDefaultSkin(){
return getSpec().getLiveries().get(0);
}

/**returns a list of models to be used for the transport
* example:
* return new MyModel();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/train/common/api/EntityRollingStock.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public GameProfile getOwner() {

public EntityRollingStock(World world, double d, double d1, double d2) {
super(world, d, d1, d2);
if(world==null){return;}
initRollingStock(world);
setPosition(d, d1 + yOffset, d2);
motionX = 0.0D;
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/train/common/api/Locomotive.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,12 @@ public abstract class Locomotive extends EntityRollingStock implements IInventor

public Locomotive(World world) {
super(world);
if(world==null){return;}
setFuelConsumption(0);
inventorySize = numCargoSlots + numCargoSlots2 + numCargoSlots1;
dataWatcher.addObject(2, 0);
this.setDefaultMass(0);
if(world!=null) {
this.setCustomSpeed(transportTopSpeed());
}
this.setCustomSpeed(transportTopSpeed());
dataWatcher.addObject(3, destination);
dataWatcher.addObject(22, locoState);
dataWatcher.addObject(24, fuelTrain);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/train/common/core/handlers/EntityHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public static void init() {
int trainID= 32;
for(TrainRecord trains : EnumTrains.trains()){
EntityRegistry.registerModEntity(trains.getEntityClass(), trains.getInternalName(), trainID, Traincraft.instance, 512, 1, true);
if(trains.getEntity(null)!=null) {
trains.getEntity(null).registerSkins();
}
trainID++;
if(trainID== 112 || trainID==51){
trainID++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ public boolean isItemValidForSlot(int i, ItemStack itemstack) {
}

@Override
public int transportTopSpeed() { return super.transportTopSpeed()*(ridingEntity instanceof EntityPlayerMP &&(((EntityPlayerMP) ridingEntity).getDisplayName().equals("EternalBlueFlame") || ((EntityPlayerMP) ridingEntity).getDisplayName().equals("minecarftmano9"))?3:1);}
public float transportTopSpeed() { return super.transportTopSpeed()*(ridingEntity instanceof EntityPlayerMP &&(((EntityPlayerMP) ridingEntity).getDisplayName().equals("EternalBlueFlame") || ((EntityPlayerMP) ridingEntity).getDisplayName().equals("minecarftmano9"))?3:1);}

@Override
public int transportMetricHorsePower() {
public float transportMetricHorsePower() {
return super.transportMetricHorsePower()*(ridingEntity instanceof EntityPlayerMP &&(((EntityPlayerMP) ridingEntity).getDisplayName().equals("EternalBlueFlame") || ((EntityPlayerMP) ridingEntity).getDisplayName().equals("minecarftmano9"))?3:1);
}
}
3 changes: 1 addition & 2 deletions src/main/java/train/common/items/ItemRollingStock.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,7 @@ public EntityMinecart placeCart(EntityPlayer player, ItemStack itemstack, World
rollingStock = (EntityRollingStock) train.getEntity(world, i + 0.5F, j + 0.2F, k + 0.5F);
if (train.getLiveries().size()>0) {
if (rollingStock != null) {
//rollingStock.setColor(AbstractTrains.getColorFromString(train.getColors()[0]));
rollingStock.setColor((train.getLiveries().get(0)));
rollingStock.setColor(rollingStock.getDefaultSkin());
}
}
}
Expand Down

0 comments on commit f740f95

Please sign in to comment.