Skip to content

Commit

Permalink
paintbrush change
Browse files Browse the repository at this point in the history
can now cycle skins by using the brush on the train while sneaking.
using it while not sneaking will now bring up the paint GUI to make it more intuitive.
  • Loading branch information
EternalBlueFlame committed Jan 4, 2024
1 parent 25d005a commit c698890
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/main/java/train/common/api/EntityRollingStock.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -381,6 +382,12 @@ public boolean attackEntityFrom(DamageSource damagesource, float i) {
if (worldObj.isRemote || isDead) {
return true;
}
if(damagesource.getEntity() instanceof EntityPlayerMP){
if(((EntityPlayerMP) damagesource.getEntity()).getHeldItem().getItem() instanceof ItemPaintbrushThing){

}

}
if (damagesource.getEntity() instanceof EntityPlayer && !damagesource.isProjectile()) {
if (this instanceof IPassenger) {
if (canBeDestroyedByPlayer(damagesource)) return false;
Expand Down Expand Up @@ -1718,7 +1725,7 @@ public boolean interactFirst(EntityPlayer entityplayer) {
return true;
}

if (itemstack != null && itemstack.getItem() instanceof ItemPaintbrushThing && entityplayer.isSneaking()) {
if (itemstack != null && itemstack.getItem() instanceof ItemPaintbrushThing) {
if (this.getSpec().getLiveries().size() > 0) {
entityplayer.openGui(Traincraft.instance, GuiIDs.PAINTBRUSH, entityplayer.getEntityWorld(), this.getEntityId(), -1, (int) this.posZ);
}
Expand All @@ -1727,6 +1734,17 @@ public boolean interactFirst(EntityPlayer entityplayer) {
entityplayer.addChatMessage(new ChatComponentText("There are no other colors available."));
}
return true;
} else if (itemstack != null && itemstack.getItem() instanceof ItemPaintbrushThing && entityplayer.isSneaking()){
for (int i = 0; i < this.getSpec().getLiveries().size(); i++) {
if (this.getColor().equals(this.getSpec().getLiveries().get(i))) {
if(this.getSpec().getLiveries().size()>i+1){
setColor(i+1);
} else {
setColor(0);
}
return true;
}
}
}

return worldObj.isRemote;
Expand Down

0 comments on commit c698890

Please sign in to comment.