Skip to content

Commit

Permalink
omg he did
Browse files Browse the repository at this point in the history
-Fixed dupe when breaking trains sometimes. Happened because an entity can die twice in a single tick??? dumb game
-Added page memory to the paint bucket GUI; when you open the UI it will default to the entities current skin instead of the default. Maybe add to config later
-Added "Random" button to paint bucket GUI. Will select and apply a random skin out of the available skins.
  • Loading branch information
broscolotos committed Aug 10, 2023
1 parent 31ff7d7 commit 0136050
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/main/java/ebf/tim/entities/GenericRailTransport.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public class GenericRailTransport extends EntityMinecart implements IEntityAddit
/**calculated movement speed, first value is used for GUI and speed, second is used for render effects.*/
@Deprecated //TODO: value 1 gets the number right more often, but value 2 gets direction right. HOW
public float[] velocity=new float[]{0,0};
public int forceBackupTimer =0, syncTimer=0;
public int forceBackupTimer =0, syncTimer=0, deathTick=0;
public float pullingWeight=0;

private float ticksSinceLastVelocityChange=1;
Expand Down Expand Up @@ -636,7 +636,8 @@ public boolean attackEntityFrom(DamageSource damageSource, float p_70097_2_){
}

//on Destruction
if (health<1 && !getWorld().isRemote){
if (health<1 && !getWorld().isRemote && deathTick==0){
deathTick=this.ticksExisted;
//since it was a player be sure we remove the entity from the logging.
ServerLogger.deleteWagon(this);
//be sure we drop the inventory items on death.
Expand Down
29 changes: 25 additions & 4 deletions src/main/java/ebf/tim/gui/GUIPaintBucket.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import ebf.tim.TrainsInMotion;
import ebf.tim.api.SkinRegistry;
import ebf.tim.api.TransportSkin;
import ebf.tim.entities.GenericRailTransport;
import ebf.tim.networking.PacketPaint;
Expand All @@ -18,10 +19,7 @@
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.Project;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.*;

/**
*@author Oskiek
Expand Down Expand Up @@ -67,6 +65,8 @@ public int compare(TransportSkin o1, TransportSkin o2) {
skinList.add(s.modid + ":" + s.name);
}
}
currentTransportSkin = entity.getCurrentSkin();
page = skinList.indexOf(currentTransportSkin.modid + ":" + currentTransportSkin.getName());
}

Keyboard.enableRepeatEvents(true);
Expand Down Expand Up @@ -183,6 +183,27 @@ public void onClick() {
public FontRenderer getFont(){return fontRendererObj;}
}
);
buttonList.add(
new GUIButton(percentLeft(83) - 61, percentTop(56), 40, 20, "Random") {
@Override
public String getHoverText() {
return "Randomize Skin";
}

@Override
public void onClick() {
TransportSkin random = SkinRegistry.getTransportSkins(entity.getClass()).get(SkinRegistry.getTransportSkins(entity.getClass()).keySet().toArray()[new Random().nextInt(SkinRegistry.getTransportSkins(entity.getClass()).keySet().size())]);
page = skinList.indexOf(random.modid + ":" + random.getName());
TrainsInMotion.keyChannel.sendToServer(new PacketPaint(skinList.get(page), entity.getEntityId()));
mc.displayGuiScreen(null);
}

@Override
public FontRenderer getFont() {
return fontRendererObj;
}
}
);
break;
}
}
Expand Down

0 comments on commit 0136050

Please sign in to comment.