Skip to content

Commit

Permalink
didnt fix what i wanted, but maybe fixed something?
Browse files Browse the repository at this point in the history
  • Loading branch information
EternalBlueFlame committed Dec 22, 2023
1 parent 1bda1fa commit ca31cc2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
9 changes: 6 additions & 3 deletions src/main/java/train/client/render/RenderRollingStock.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.util.Vec3;
import org.lwjgl.opengl.GL11;
import train.common.Traincraft;
import train.common.api.AbstractTrains;
import train.common.api.EntityRollingStock;
import train.common.api.Locomotive;
import train.common.api.TrainRenderRecord;
Expand Down Expand Up @@ -459,9 +460,11 @@ protected ResourceLocation getEntityTexture(Entity entity) {
}

public static ResourceLocation getTexture(Entity entity) {
TrainRenderRecord render = Traincraft.instance.traincraftRegistry.getTrainRenderRecord(entity.getClass());
if (render != null) {
return render.getTextureFile(((EntityRollingStock) entity).getColor());
if(entity instanceof AbstractTrains) {
TrainRenderRecord render = Traincraft.instance.traincraftRegistry.getTrainRenderRecord(entity.getClass());
if (render != null) {
return render.getTextureFile(((AbstractTrains) entity).getColor());
}
}
return null;
}
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/train/common/api/AbstractTrains.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public void setColor(int color) {

public void setColor(String color) {
TrainRecord trainRecord = Traincraft.instance.traincraftRegistry.findTrainRecordByItem(getCartItem().getItem());
if (trainRecord != null && trainRecord.getLiveries() != null) {
if (trainRecord != null && trainRecord.getLiveries() != null && trainRecord.getLiveries().size()>0) {
if (color.equals("-1") || !trainRecord.getLiveries().contains(color)) {
color = (trainRecord.getLiveries().get(trainRecord.getLiveries().indexOf(color)+1>trainRecord.getLiveries().size()-1?0:trainRecord.getLiveries().indexOf(color)+1));
}
Expand All @@ -328,7 +328,11 @@ public void setRenderPitch(float pitch) {

public String getColor() {
entity_data.updateData(dataWatcher.getWatchableObjectString(12));
return entity_data.getString("color");
if(entity_data.hasString("color")) {
return entity_data.getString("color");
} else {
return trainSpec.getLiveries().get(0);
}
}

@Override
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/train/common/api/TrainRecord.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package train.common.api;

import ebf.tim.utility.DebugUtil;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.world.World;
Expand Down Expand Up @@ -94,7 +95,7 @@ public static TrainRecord makeEntry(String entryName, String internalName, Class
* #param entryName is depreciated
* #param additionalTooltip is depreciated.
*/
public static TrainRecord makeEntry(final String entryName, final String internalName, final Class entityClass, final Item item, final String trainType, final int MHP, final int maxSpeed, final double mass, final int fuelConsumption, final int waterConsumption, final int heatingTime, final double accelerationRate, final double brakeRate, final int tankCapacity, final int cargoCapacity, final String[] colors, final int guiRenderScale, final double bogieLocoPositions, final String additionnalTooltip) {
public static TrainRecord makeEntry(final String entryName, final String internalName, final Class entityClass, final Item item, final String trainType, final int MHP, final int maxSpeed, final double mass, final int fuelConsumption, final int waterConsumption, final int heatingTime, final double accelerationRate, final double brakeRate, final int tankCapacity, final int cargoCapacity, final String[] colors, int guiRenderScale, final double bogieLocoPositions, final String additionnalTooltip) {
return new TrainRecord() {
@Override
public String getName() {
Expand Down Expand Up @@ -163,7 +164,7 @@ public int getTankCapacity() {

@Override
public List<String> getColors() {
if (colors == null) {
if (colors == null || colors.length==0) {
return new ArrayList<>();
} else {
return Arrays.asList(colors);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/train/common/items/ItemRollingStock.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer,
if (par3World.isRemote) {
return false;
}
if(tileentity!=null && tileentity instanceof TileTCRail){
if(tileentity instanceof TileTCRail){
TileTCRail tile = (TileTCRail) tileentity;
if (tile.getType().equals(TrackTypes.SMALL_STRAIGHT.getLabel())
||tile.getType().equals(TrackTypes.MEDIUM_STRAIGHT.getLabel())
Expand Down Expand Up @@ -229,7 +229,7 @@ public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer,
par2EntityPlayer.addChatMessage(new ChatComponentText("Place me on a straight piece of track !"));
return false;
}
else if(tileentity!=null && tileentity instanceof TileTCRailGag){
else if(tileentity instanceof TileTCRailGag){

TileTCRailGag tileGag = (TileTCRailGag) tileentity;
TileTCRail tile = (TileTCRail) par3World.getTileEntity(tileGag.originX, tileGag.originY, tileGag.originZ);
Expand Down

0 comments on commit ca31cc2

Please sign in to comment.