Skip to content

Commit

Permalink
API moved, mostly. also fixed paint brush gui
Browse files Browse the repository at this point in the history
- Updated the endpoint access for most of the methods to use the redirects.
- Fixed scaling for the paint brush and crafting table GUIs, this fix also removes some data from the registry to help RAM use.
- All the values in TrainRecord that get redirected are now marked as Depreciated as well.
  • Loading branch information
EternalBlueFlame committed Dec 1, 2023
1 parent a448dfc commit 52f614b
Show file tree
Hide file tree
Showing 94 changed files with 120 additions and 156 deletions.
7 changes: 5 additions & 2 deletions src/main/java/train/client/gui/GuiCrafterTier.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,11 @@ protected void drawGuiContainerBackgroundLayer(float f, int t, int g) {
renderEntity.setColor(train.getLiveries().get(color));
}
}

GL11.glScalef(-train.getGuiRenderScale(), train.getGuiRenderScale(), train.getGuiRenderScale());
float scale = renderEntity.getHitboxSize()[0];
if(scale!=0){
scale = 5.8f/(scale /5.8f);
}
GL11.glScalef(-scale, scale, scale);
GL11.glRotatef(180, 0, 0, 1);
GL11.glRotatef(roll, 1, 0, 0);
GL11.glRotatef(yaw, 0, 1, 0);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/train/client/gui/GuiForney.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ protected void drawGuiContainerBackgroundLayer(float f, int t, int g) {
fontRendererObj.drawStringWithShadow("Brake reduction: " + loco.getCurrentBrakeSlowDown(), 1, 50, 0xFFFFFF);
fontRendererObj.drawStringWithShadow("Fuel consumption: 1 every " + loco.getFuelConsumption() + " ticks", 1, 60, 0xFFFFFF);
fontRendererObj.drawStringWithShadow("Fuel: " + loco.getFuel(), 1, 70, 0xFFFFFF);
fontRendererObj.drawStringWithShadow("Power: " + loco.getPower() + " Mhp", 1, 80, 0xFFFFFF);
fontRendererObj.drawStringWithShadow("Power: " + loco.transportMetricHorsePower() + " Mhp", 1, 80, 0xFFFFFF);
fontRendererObj.drawStringWithShadow("State: " + loco.getState(), 1, 90, 0xFFFFFF);
fontRendererObj.drawStringWithShadow("Heat level: " + loco.getOverheatLevel(), 1, 100, 0xFFFFFF);
fontRendererObj.drawStringWithShadow("Maximum Speed: " + (loco.getCustomSpeedGUI()), 1, 110, 0xFFFFFF);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/train/client/gui/GuiLoco2.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ protected void drawGuiContainerBackgroundLayer(float f, int t, int g) {
fontRendererObj.drawStringWithShadow("Fuel consumption: " + ((loco.getFuelConsumption() * 0.2) + "").substring(0, Math.min(((loco.getFuelConsumption() * 0.2) + "").length(), 4)) + " mB/s", 1,
60, 0xFFFFFF);
fontRendererObj.drawStringWithShadow("Fuel: " + loco.getFuel(), 1, 70, 0xFFFFFF);
fontRendererObj.drawStringWithShadow("Power: " + loco.getPower() + " Mhp", 1, 80, 0xFFFFFF);
fontRendererObj.drawStringWithShadow("Power: " + loco.transportMetricHorsePower() + " Mhp", 1, 80, 0xFFFFFF);
fontRendererObj.drawStringWithShadow("State: " + loco.getState(), 1, 90, 0xFFFFFF);
fontRendererObj.drawStringWithShadow("Heat level: " + loco.getOverheatLevel(), 1, 100, 0xFFFFFF);
fontRendererObj.drawStringWithShadow("Maximum Speed: " + (loco.getCustomSpeedGUI()) + " km/h" + " (" + (loco.getCustomSpeedGUI() + loco.getCurrentSpeedSlowDown()) + ")", 1, 110, 0xFFFFFF);
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/train/client/gui/GuiPaintbrushMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ebf.tim.utility.DebugUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
Expand Down Expand Up @@ -259,7 +260,11 @@ public void drawScreen(int mouseX, int mouseY, float par3) {
GL11.glColor4f(1, 1, 1, 1);
GL11.glPushMatrix();
GL11.glTranslated(offsetX + 205 + (i * 95), offsetY + 82, 400);
GL11.glScalef(-record.getGuiRenderScale(), record.getGuiRenderScale(), record.getGuiRenderScale());
float scale = renderEntity.getHitboxSize()[0];
if(scale!=0){
scale = 5.8f/(scale /5.8f);
}
GL11.glScalef(-scale, scale, scale);
GL11.glRotatef(180, 0, 0, 1);
GL11.glRotatef(yaw, 0, 1, 0);
RenderManager.instance.renderEntityWithPosYaw(renderEntity, bogieOffset, 0, 0, 0, 0);
Expand Down
23 changes: 4 additions & 19 deletions src/main/java/train/common/api/AbstractTrains.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,25 +159,10 @@ public AbstractTrains(World world) {
this.setFlag(7, shouldChunkLoad);


/*for (EnumTrains trains : EnumTrains.values()) {
if (trains.getEntityClass().equals(this.getClass())) {
this.setDefaultMass(trains.getMass());
trainSpec = trains;
if (trains.getColors() != null) {
for (int i = 0; i < trains.getColors().length; i++) {
this.acceptedColors.add(AbstractTrains.getColorFromString(trains.getColors()[i]));
}
}
this.setSize(0.98f, 1.98f);
this.setMinecartName(trainSpec.name());
break;
}
}*/
if (getSpec() != null) {
this.setDefaultMass(getSpec().getMass());
this.setDefaultMass(weightKg());
this.setSize(0.98f, 1.98f);
this.setMinecartName(getSpec().getName());
this.setMinecartName(transportName());
}
}

Expand Down Expand Up @@ -696,7 +681,7 @@ public String transportFuelType(){
*example:
* return new int[]{11000, 1000};
* may return null*/
public int[] getTankCapacity(){return null;}
public int[] getTankCapacity(){return new int[]{getSpec().getTankCapacity()};}

/**defines the rider position offsets, with 0 being the center of the entity.
* Each set of coords represents a new rider seat, with the first one being the "driver"
Expand All @@ -710,7 +695,7 @@ public String transportFuelType(){
* example:
* return new float[]{x,y,z};
* may not return null*/
public float[] getHitboxSize(){return new float[]{3,1.5f,0.21f};}
public float[] getHitboxSize(){return new float[]{getOptimalDistance(null)-((float)getSpec().getBogieLocoPosition()*0.5f),1.5f,0.21f};}

/**defines if the transport is immune to explosions*/
public boolean isReinforced(){return false;}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/train/common/api/DieselTrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public DieselTrain(World world, FluidStack[] multiFilter) {

private DieselTrain(World world, FluidStack filter, FluidStack[] multiFilter) {
super(world);
this.maxTank = getSpec().getTankCapacity();
this.maxTank = getTankCapacity()[0];
if (filter == null && multiFilter == null) {
this.theTank = LiquidManager.getInstance().new StandardTank(maxTank);
}if (filter != null) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/train/common/api/LiquidTank.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public LiquidTank(World world) {

private LiquidTank(@Nullable FluidStack liquid, World world) {
super(world);
this.capacity = this.getSpec().getTankCapacity();
this.capacity = getTankCapacity()[0];
this.theTank = new FluidTank(liquid, capacity);
dataWatcher.addObject(4, 0);
dataWatcher.addObject(22, "");
Expand Down
15 changes: 3 additions & 12 deletions src/main/java/train/common/api/Locomotive.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,12 @@ public void setCustomSpeed(double m) {
public float getMaxSpeed() {
if (getSpec() != null) {
if (currentMassPulled > 1) {
float power = (float) currentMassPulled / (((float) getSpec().getMHP()) * 0.37f);
float power = (float) currentMassPulled / (transportMetricHorsePower() * 0.37f);
if (power > 1) {
return getSpec().getMaxSpeed() / (power);
return transportTopSpeed() / (power);
}
}
return getSpec().getMaxSpeed();
return transportTopSpeed();
}
return 50;
}
Expand Down Expand Up @@ -326,15 +326,6 @@ public int getFuelConsumption() {
return fuelRate == 0 ? getSpec().getFuelConsumption() : fuelRate;
}

/**
* Return the power of the loco, used for cart pulling
*
* @see HandleMaxAttachedCarts for calculations
*/
public int getPower() {
return getSpec().getMHP();
}

/**
* Set acceleration rate if rate = 0, default value is used
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/train/common/api/SteamTrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public SteamTrain(World world) {

public SteamTrain(World world, FluidStack filter) {
super(world);
this.maxTank = getSpec().getTankCapacity();
this.maxTank = getTankCapacity()[0];
if (filter == null) {
this.theTank = LiquidManager.getInstance().new StandardTank(maxTank);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/train/common/api/Tender.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public Tender(World world, Fluid fluid, int quantity, FluidStack filter) {

private Tender(FluidStack fluid, World world, FluidStack filter) {
super(world);
this.maxTank = getSpec().getTankCapacity();
this.maxTank = getTankCapacity()[0];
if (filter == null)
this.theTank = LiquidManager.getInstance().new StandardTank(maxTank);
if (filter != null)
Expand Down
10 changes: 3 additions & 7 deletions src/main/java/train/common/api/TrainRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public abstract class TrainRecord {
@Deprecated
public abstract int getMaxSpeed();

@Deprecated
public abstract double getMass();

public abstract int getFuelConsumption();
Expand All @@ -40,6 +41,7 @@ public abstract class TrainRecord {

public abstract double getBrakeRate();

@Deprecated
public abstract int getTankCapacity();

public abstract List<String> getColors();
Expand All @@ -55,11 +57,10 @@ public List<String> getLiveries() {

public abstract Class<Entity> getEntityClass();

public abstract int getGuiRenderScale();

@Deprecated
public abstract String getAdditionnalTooltip();

@Deprecated
public abstract int getCargoCapacity();

public abstract AbstractTrains getEntity(World world);
Expand Down Expand Up @@ -179,11 +180,6 @@ public Class<Entity> getEntityClass() {
return entityClass;
}

@Override
public int getGuiRenderScale() {
return guiRenderScale;
}

@Override
public String getAdditionnalTooltip() {
return additionnalTooltip;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/train/common/core/HandleMaxAttachedCarts.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void PullPhysic(Locomotive cart1) {
if ((cart1).train != null && !(cart1).train.getTrains().isEmpty()) {

for (int j1 = 0; j1 < (cart1).train.getTrains().size(); j1++) {
totalMass += (cart1).train.getTrains().get(j1).mass;
totalMass += (cart1).train.getTrains().get(j1).weightKg();
}
(cart1).currentNumCartsPulled = (cart1).train.getTrains().size() - 1;
(cart1).currentMassPulled = Math.round(totalMass * 10);
Expand All @@ -54,11 +54,11 @@ public static void PullPhysic(Locomotive cart1) {

double power = 0;
if ((cart1).train != null && !(cart1).train.getTrains().isEmpty() && (cart1).train.getTrains().size() > 1) {
power = (cart1).getPower();
power =cart1.transportMetricHorsePower();
for (int i = 0; i < (cart1).train.getTrains().size(); i++) {
EntityRollingStock stock = (cart1).train.getTrains().get(i);
if (stock instanceof Locomotive && stock.uniqueID != (cart1).uniqueID) {
power += ((Locomotive) stock).getPower();
power += stock.transportMetricHorsePower();
}
}
//power = ((Locomotive) cart1).getPower();//((EntityRollingStock) cart1).train.getTrainPower();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/train/common/core/handlers/TrainHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void addRollingStock(EntityRollingStock rolling) {
}

if (rolling instanceof Locomotive) {
trainPower += ((Locomotive) rolling).getPower();
trainPower += rolling.transportMetricHorsePower();
}

train.add(rolling);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class EntityBUnitDD35 extends LiquidTank implements IFluidHandler {
public EntityBUnitDD35(World world) {
super(world);
initFreightWater();
this.theTank = LiquidManager.getInstance().new FilteredTank(getSpec().getTankCapacity(), LiquidManager.dieselFilter());
this.theTank = LiquidManager.getInstance().new FilteredTank(getTankCapacity()[0], LiquidManager.dieselFilter());
}

public EntityBUnitDD35(World world, double d, double d1, double d2) {
Expand Down Expand Up @@ -66,14 +66,14 @@ public void onUpdate() {

if (getAmount() > 0) {
// setColor(getColorFromString("Full"));
setDefaultMass(-getSpec().getMass());
setDefaultMass(-weightKg());
if ((motionX > 0.01 || motionZ > 0.01) && ticksExisted % 40 == 0) {
drain(ForgeDirection.UNKNOWN, 8, true);
}

} else if (getAmount() <= 0) {
// setColor(getColorFromString("Empty"));
setDefaultMass(getSpec().getMass());
setDefaultMass(weightKg());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class EntityBUnitEMDF3 extends LiquidTank implements IFluidHandler {
public EntityBUnitEMDF3(World world) {
super(world);
initFreightWater();
this.theTank = LiquidManager.getInstance().new FilteredTank(getSpec().getTankCapacity(), LiquidManager.dieselFilter());
this.theTank = LiquidManager.getInstance().new FilteredTank(getTankCapacity()[0], LiquidManager.dieselFilter());
}

public EntityBUnitEMDF3(World world, double d, double d1, double d2) {
Expand Down Expand Up @@ -111,14 +111,14 @@ public void onUpdate() {

if (getAmount() > 0) {
// setColor(getColorFromString("Full"));
setDefaultMass(-getSpec().getMass());
setDefaultMass(-weightKg());
if ((motionX > 0.01 || motionZ > 0.01) && ticksExisted % 40 == 0) {
drain(ForgeDirection.UNKNOWN, 6, true);
}

} else if (getAmount() <= 0) {
// setColor(getColorFromString("Empty"));
setDefaultMass(getSpec().getMass());
setDefaultMass(weightKg());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class EntityBUnitEMDF7 extends LiquidTank implements IFluidHandler {
public EntityBUnitEMDF7(World world) {
super(world);
initFreightWater();
this.theTank = LiquidManager.getInstance().new FilteredTank(getSpec().getTankCapacity(), LiquidManager.dieselFilter());
this.theTank = LiquidManager.getInstance().new FilteredTank(getTankCapacity()[0], LiquidManager.dieselFilter());
}

public EntityBUnitEMDF7(World world, double d, double d1, double d2) {
Expand Down Expand Up @@ -66,14 +66,14 @@ public void onUpdate() {

if (getAmount() > 0) {
// setColor(getColorFromString("Full"));
setDefaultMass(-getSpec().getMass());
setDefaultMass(-weightKg());
if ((motionX > 0.01 || motionZ > 0.01) && ticksExisted % 40 == 0) {
drain(ForgeDirection.UNKNOWN, 6, true);
}

} else if (getAmount() <= 0) {
// setColor(getColorFromString("Empty"));
setDefaultMass(getSpec().getMass());
setDefaultMass(weightKg());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public EntityBoulderWagon(World world, double d, double d1, double d2) {

public void initFreightCart() {
numFreightSlots = 1;
freightInventorySize = getSpec().getCargoCapacity();
freightInventorySize = getInventoryRows()*9;
cargoItems = new ItemStack[freightInventorySize];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public EntityBulkheadFlatCart(World world) {

public void initBulkheadFlat() {
numFreightSlots = 9;
freightInventorySize = getSpec().getCargoCapacity();
freightInventorySize = getInventoryRows()*9;
cargoItems = new ItemStack[freightInventorySize];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public EntityFreight100TonHopper(World world) {

public void initFreightGrain() {
numFreightSlots = 9;
freightInventorySize = getSpec().getCargoCapacity();
freightInventorySize = getInventoryRows()*9;
cargoItems = new ItemStack[freightInventorySize];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public EntityFreight5Plank(World world) {

public void initFreightCart() {
numFreightSlots = 36;
freightInventorySize = getSpec().getCargoCapacity();
freightInventorySize = getInventoryRows()*9;
cargoItems = new ItemStack[freightInventorySize];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public EntityFreight7Plank(World world) {

public void initFreightGrain() {
numFreightSlots = 9;
freightInventorySize = getSpec().getCargoCapacity();
freightInventorySize = getInventoryRows()*9;
cargoItems = new ItemStack[freightInventorySize];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public EntityFreightASTFAutorack(World world) {

public void initFreightCart() {
numFreightSlots = 9;
freightInventorySize = getSpec().getCargoCapacity();
freightInventorySize = getInventoryRows()*9;
cargoItems = new ItemStack[freightInventorySize];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public EntityFreightBNSFGon(World world) {

public void initFreightCart() {
numFreightSlots = 9;
freightInventorySize = getSpec().getCargoCapacity();
freightInventorySize = getInventoryRows()*9;
cargoItems = new ItemStack[freightInventorySize];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public EntityFreightBR_Mk1_TPO_Stowage(World world) {

public void initFreightCart() {
numFreightSlots = 36;
freightInventorySize = getSpec().getCargoCapacity();
freightInventorySize = getInventoryRows()*9;
cargoItems = new ItemStack[freightInventorySize];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public EntityFreightBaggageMILW(World world) {

public void initFreightCart() {
numFreightSlots = 9;
freightInventorySize = getSpec().getCargoCapacity();
freightInventorySize = getInventoryRows()*9;
cargoItems = new ItemStack[freightInventorySize];
}

Expand Down
Loading

0 comments on commit 52f614b

Please sign in to comment.