Skip to content

Commit

Permalink
Removed emblems #94
Browse files Browse the repository at this point in the history
  • Loading branch information
Edivad99 committed Jan 30, 2024
2 parents a46a1ca + 001cd57 commit c6187b1
Show file tree
Hide file tree
Showing 11 changed files with 2 additions and 203 deletions.
3 changes: 0 additions & 3 deletions src/main/java/mods/railcraft/client/ClientManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import mods.railcraft.api.core.RailcraftConstants;
import mods.railcraft.api.signal.SignalAspect;
import mods.railcraft.api.signal.SignalUtil;
import mods.railcraft.client.emblem.EmblemClientUtil;
import mods.railcraft.client.emblem.EmblemPackageManagerImpl;
import mods.railcraft.client.gui.screen.inventory.BlastFurnaceScreen;
import mods.railcraft.client.gui.screen.inventory.CartDispenserScreen;
import mods.railcraft.client.gui.screen.inventory.CokeOvenScreen;
Expand Down Expand Up @@ -98,7 +96,6 @@ public static void init(IEventBus modEventBus) {

shuntingAuraRenderer = new ShuntingAuraRenderer();
SignalUtil._setTuningAuraHandler(new TuningAuraHandlerImpl());
EmblemClientUtil._setPackageManager(new EmblemPackageManagerImpl());
}

public static ShuntingAuraRenderer getShuntingAuraRenderer() {
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/mods/railcraft/client/emblem/Emblem.java

This file was deleted.

35 changes: 0 additions & 35 deletions src/main/java/mods/railcraft/client/emblem/EmblemClientUtil.java

This file was deleted.

10 changes: 0 additions & 10 deletions src/main/java/mods/railcraft/client/emblem/EmblemItemRenderer.java

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import mods.railcraft.world.entity.vehicle.locomotive.Locomotive;
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -18,10 +17,6 @@ public class DefaultLocomotiveRenderer extends LocomotiveRenderer<Locomotive> {
private final EntityModel<? super Locomotive> snowLayer;
private final ResourceLocation[] textures;
private final float[][] color = new float[3][];
private float emblemSize = 0.15F;
private float emblemOffsetX = 0.47F;
private float emblemOffsetY = -0.17F;
private float emblemOffsetZ = -0.515F;

public DefaultLocomotiveRenderer(EntityRendererProvider.Context context, String modelTag,
EntityModel<? super Locomotive> model,
Expand All @@ -45,13 +40,6 @@ public DefaultLocomotiveRenderer(EntityRendererProvider.Context context, String
this.color[2] = new float[] {1.0F, 1.0F, 1.0F};
}

public void setEmblemPosition(float size, float offsetX, float offsetY, float offsetZ) {
this.emblemSize = size;
this.emblemOffsetX = offsetX;
this.emblemOffsetY = offsetY;
this.emblemOffsetZ = offsetZ;
}

@Override
public void renderBody(Locomotive cart, float time, PoseStack poseStack,
MultiBufferSource renderTypeBuffer, int packedLight, float red, float green, float blue,
Expand All @@ -77,43 +65,11 @@ public void renderBody(Locomotive cart, float time, PoseStack poseStack,
this.snowLayer.renderToBuffer(poseStack, vertexBuilder, packedLight,
OverlayTexture.NO_OVERLAY, 1, 1, 1, 1);
}

this.getEmblemTexture(cart).ifPresent(emblemTexture -> {

var vertexBuilder = renderTypeBuffer.getBuffer(RenderType.entityTranslucent(emblemTexture));

// float size = 0.22F;
// float offsetX = -0.25F;
// float offsetY = -0.25F;
// float offsetZ = -0.46F;
// TODO: Test this!


vertexBuilder.vertex(emblemOffsetX - emblemSize, emblemOffsetY - emblemSize, emblemOffsetZ)
.uv(0, 0).endVertex();
vertexBuilder.vertex(emblemOffsetX - emblemSize, emblemOffsetY + emblemSize, emblemOffsetZ)
.uv(0, 1).endVertex();
vertexBuilder.vertex(emblemOffsetX + emblemSize, emblemOffsetY + emblemSize, emblemOffsetZ)
.uv(1, 1).endVertex();
vertexBuilder.vertex(emblemOffsetX + emblemSize, emblemOffsetY + -emblemSize, emblemOffsetZ)
.uv(1, 0).endVertex();

vertexBuilder.vertex(emblemOffsetX + emblemSize, emblemOffsetY + -emblemSize, -emblemOffsetZ)
.uv(0, 0).endVertex();
vertexBuilder.vertex(emblemOffsetX + emblemSize, emblemOffsetY + emblemSize, -emblemOffsetZ)
.uv(0, 1).endVertex();
vertexBuilder.vertex(emblemOffsetX - emblemSize, emblemOffsetY + emblemSize, -emblemOffsetZ)
.uv(1, 1).endVertex();
vertexBuilder.vertex(emblemOffsetX - emblemSize, emblemOffsetY - emblemSize, -emblemOffsetZ)
.uv(1, 0).endVertex();

});
// OpenGL.glDisable(GL11.GL_BLEND);
poseStack.popPose();
}

@Override
public ResourceLocation getTextureLocation(Locomotive loco) {
public ResourceLocation getTextureLocation(Locomotive locomotive) {
throw new IllegalStateException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@ public ElectricLocomotiveRenderer(EntityRendererProvider.Context context) {
RailcraftConstants.rl("textures/entity/locomotive/" + modelTag + "/lamp_on.png");
this.lampTextureOff =
RailcraftConstants.rl("textures/entity/locomotive/" + modelTag + "/lamp_off.png");
this.setEmblemPosition(0.2F, -0.03F, -0.41F, -0.505F);
}

@Override
public void renderBody(Locomotive cart, float time, PoseStack poseStack,
MultiBufferSource renderTypeBuffer, int packedLight, float red, float green, float blue,
float alpha) {
super.renderBody(cart, time, poseStack, renderTypeBuffer, packedLight, red, green, blue,
alpha);
super.renderBody(cart, time, poseStack, renderTypeBuffer, packedLight, red, green, blue, alpha);
poseStack.pushPose();
poseStack.scale(-1, -1, 1);
poseStack.translate(0.05F, 0, 0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package mods.railcraft.client.renderer.entity.cart;

import java.util.Optional;
import mods.railcraft.client.emblem.EmblemClientUtil;
import mods.railcraft.season.Seasons;
import mods.railcraft.world.entity.vehicle.locomotive.Locomotive;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.DyeColor;

public abstract class LocomotiveRenderer<T extends Locomotive>
Expand All @@ -26,9 +23,4 @@ protected float[] getSecondaryColor(T loco) {
? DyeColor.LIGHT_GRAY.getTextureDiffuseColors()
: loco.getSecondaryColor();
}

protected Optional<ResourceLocation> getEmblemTexture(T loco) {
return loco.getEmblem()
.map(EmblemClientUtil.packageManager()::getEmblemTextureLocation);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ public abstract class Locomotive extends RailcraftMinecart implements
SynchedEntityData.defineId(Locomotive.class, EntityDataSerializers.INT);
private static final EntityDataAccessor<Integer> SECONDARY_COLOR =
SynchedEntityData.defineId(Locomotive.class, EntityDataSerializers.INT);
private static final EntityDataAccessor<String> EMBLEM =
SynchedEntityData.defineId(Locomotive.class, EntityDataSerializers.STRING);
private static final EntityDataAccessor<String> DESTINATION =
SynchedEntityData.defineId(Locomotive.class, EntityDataSerializers.STRING);
private static final EntityDataAccessor<Optional<GameProfile>> OWNER =
Expand Down Expand Up @@ -128,7 +126,6 @@ protected void defineSynchedData() {
this.entityData.define(SPEED, (byte) Speed.NORMAL.ordinal());
this.entityData.define(LOCK, (byte) Lock.UNLOCKED.ordinal());
this.entityData.define(REVERSE, false);
this.entityData.define(EMBLEM, "");
this.entityData.define(DESTINATION, "");
this.entityData.define(OWNER, Optional.empty());
}
Expand Down Expand Up @@ -163,10 +160,6 @@ protected void loadFromItemStack(ItemStack itemStack) {
if (tag.contains("lock", Tag.TAG_STRING)) {
Lock.getByName(tag.getString("lock")).ifPresent(this::setLock);
}

if (tag.contains("emblem", Tag.TAG_STRING)) {
this.setEmblem(tag.getString("emblem"));
}
}

@Override
Expand Down Expand Up @@ -214,7 +207,6 @@ public ItemStack getPickResult() {
LocomotiveItem.setItemColorData(itemStack,
this.getPrimaryDyeColor(), this.getSecondaryDyeColor());
LocomotiveItem.setItemWhistleData(itemStack, this.whistlePitch);
this.getEmblem().ifPresent(emblem -> LocomotiveItem.setEmblem(itemStack, emblem));
if (this.hasCustomName()) {
itemStack.setHoverName(this.getCustomName());
}
Expand Down Expand Up @@ -291,19 +283,6 @@ public void setLock(Lock lock) {
this.entityData.set(LOCK, (byte) lock.ordinal());
}

public Optional<String> getEmblem() {
var value = this.getEntityData().get(EMBLEM);
return value.isEmpty() ? Optional.empty() : Optional.of(value);
}

public void setEmblem(@Nullable String emblem) {
if (getEmblem().isEmpty()) {
this.getEntityData().set(EMBLEM, emblem);
} else if (!getEmblem().get().equals(emblem)) {
this.getEntityData().set(EMBLEM, emblem);
}
}

@Override
public String getDestination() {
return this.getEntityData().get(DESTINATION);
Expand Down Expand Up @@ -728,8 +707,6 @@ public void addAdditionalSaveData(CompoundTag tag) {

tag.putBoolean("flipped", this.flipped);

this.getEmblem().ifPresent(emblem -> tag.putString("emblem", emblem));

tag.putString("dest", StringUtils.defaultIfBlank(getDestination(), ""));

tag.putString("mode", this.getMode().getSerializedName());
Expand All @@ -756,8 +733,6 @@ public void readAdditionalSaveData(CompoundTag tag) {

this.flipped = tag.getBoolean("flipped");

this.setEmblem(tag.getString("emblem"));

this.setDestination(tag.getString("dest"));

this.setMode(Mode.getByName(tag.getString("mode")).orElse(Mode.IDLE));
Expand Down
32 changes: 0 additions & 32 deletions src/main/java/mods/railcraft/world/item/LocomotiveItem.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package mods.railcraft.world.item;

import java.util.List;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.Nullable;
import com.mojang.authlib.GameProfile;
import mods.railcraft.Translations;
import mods.railcraft.api.item.Filter;
import mods.railcraft.api.item.MinecartFactory;
import mods.railcraft.client.emblem.EmblemClientUtil;
import net.minecraft.ChatFormatting;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.nbt.Tag;
Expand Down Expand Up @@ -59,12 +57,6 @@ public void appendHoverText(ItemStack stack, @Nullable Level level, List<Compone
var whistleText = whistle < 0 ? "???" : String.format("%.2f", whistle);
tooltip.add(Component.translatable(Translations.Tips.LOCOMOTIVE_ITEM_WHISTLE, whistleText)
.withStyle(ChatFormatting.GRAY));

getEmblem(stack)
.flatMap(EmblemClientUtil.packageManager()::getEmblem)
.ifPresent(emblem -> tooltip.add(
Component.translatable("gui.railcraft.locomotive.tips.item.emblem",
emblem.displayName())));
}

public static void setItemColorData(ItemStack stack, DyeColor primaryColor,
Expand Down Expand Up @@ -97,30 +89,6 @@ public static GameProfile getOwner(ItemStack stack) {
return NbtUtils.readGameProfile(tag);
}

public static void setEmblem(ItemStack stack, String emblemIdentifier) {
var tag = stack.getOrCreateTag();
tag.putString("emblem", emblemIdentifier);
}

public static Optional<String> getEmblem(ItemStack stack) {
var tag = stack.getOrCreateTag();
return !tag.contains("emblem", Tag.TAG_STRING)
? Optional.empty()
: Optional.of(tag.getString("emblem"));
}

public static void setModel(ItemStack stack, String modelTag) {
var tag = stack.getOrCreateTag();
tag.putString("model", modelTag);
}

public static String getModel(ItemStack stack) {
var tag = stack.getOrCreateTag();
if (!tag.contains("model", Tag.TAG_STRING))
return "default";
return tag.getString("model");
}

public static DyeColor getPrimaryColor(ItemStack stack) {
var tag = stack.getOrCreateTag();
if (tag.contains("primaryColor", Tag.TAG_INT)) {
Expand Down

0 comments on commit c6187b1

Please sign in to comment.