Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Edivad99 committed Dec 22, 2024
1 parent b0b525c commit 081c764
Show file tree
Hide file tree
Showing 91 changed files with 627 additions and 540 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ loader_version_range=[4,)
neo_gradle_version=7.0.165

## Parchment
neogradle.subsystems.parchment.minecraftVersion=1.21.1
neogradle.subsystems.parchment.mappingsVersion=2024.11.17
neogradle.subsystems.parchment.minecraftVersion=1.21.3
neogradle.subsystems.parchment.mappingsVersion=2024.12.07

## Mod Properties
mod_version=1.2.3
Expand Down
4 changes: 2 additions & 2 deletions src/api/java/mods/railcraft/api/item/MinecartFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ This work (the API) is licensed under the "MIT" License,
package mods.railcraft.api.item;

import org.jetbrains.annotations.Nullable;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.vehicle.AbstractMinecart;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;

@FunctionalInterface
public interface MinecartFactory {

@Nullable
AbstractMinecart createMinecart(
ItemStack itemStack, double x, double y, double z, ServerLevel level);
ItemStack itemStack, Level level, double x, double y, double z);
}
3 changes: 0 additions & 3 deletions src/main/java/mods/railcraft/Railcraft.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,8 @@
import mods.railcraft.world.item.RailcraftItems;
import mods.railcraft.world.item.alchemy.RailcraftPotions;
import mods.railcraft.world.item.component.RailcraftDataComponents;
import mods.railcraft.world.item.crafting.BlastFurnaceRecipe;
import mods.railcraft.world.item.crafting.CrusherRecipe;
import mods.railcraft.world.item.crafting.RailcraftRecipeSerializers;
import mods.railcraft.world.item.crafting.RailcraftRecipeTypes;
import mods.railcraft.world.item.crafting.RollingRecipe;
import mods.railcraft.world.level.block.RailcraftBlocks;
import mods.railcraft.world.level.block.entity.BlastFurnaceBlockEntity;
import mods.railcraft.world.level.block.entity.CokeOvenBlockEntity;
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/mods/railcraft/charge/ChargeNetworkImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ protected void constructGrid() {

@Override
public void zap(Entity entity, Charge.DamageOrigin origin, float damage) {
if (!(entity.level() instanceof ServerLevel level)) {
if (!(entity.level() instanceof ServerLevel serverLevel)) {
return;
}
// logical server
Expand All @@ -699,7 +699,7 @@ public void zap(Entity entity, Charge.DamageOrigin origin, float damage) {
for (var entry : protections.entrySet()) {
if (remainingDamage > 0.1F) {
var result = entry.getValue()
.zap(livingEntity.getItemBySlot(entry.getKey()), level,
.zap(livingEntity.getItemBySlot(entry.getKey()), serverLevel,
livingEntity, remainingDamage);
livingEntity.setItemSlot(entry.getKey(), result.stack());
remainingDamage -= result.damagePrevented();
Expand All @@ -709,9 +709,9 @@ public void zap(Entity entity, Charge.DamageOrigin origin, float damage) {
}
}
if (remainingDamage > 0.1F
&& entity.hurt(origin == Charge.DamageOrigin.BLOCK
? RailcraftDamageSources.electric(level.registryAccess())
: RailcraftDamageSources.trackElectric(level.registryAccess()), remainingDamage)) {
&& entity.hurtServer(serverLevel, origin == Charge.DamageOrigin.BLOCK
? RailcraftDamageSources.electric(serverLevel.registryAccess())
: RailcraftDamageSources.trackElectric(serverLevel.registryAccess()), remainingDamage)) {
this.removeCharge(chargeCost, false);
Charge.zapEffectProvider().zapEffectDeath(entity.level(),
entity.getX(), entity.getY(), entity.getZ());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public void zapEffectSurface(BlockState blockState, Level level, BlockPos pos) {
0.1F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);

for (var side : Direction.values()) {
if (!Block.shouldRenderFace(blockState, level, pos, side, pos.relative(side))) {
if (!Block.shouldRenderFace(level, pos, blockState,
level.getBlockState(pos.relative(side)), side)) {
continue;
}
var normal = Vec3.atLowerCornerOf(side.getUnitVec3i());
Expand Down
19 changes: 9 additions & 10 deletions src/main/java/mods/railcraft/client/ClientManager.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package mods.railcraft.client;

import org.jetbrains.annotations.NotNull;
import org.joml.Vector3f;
import com.mojang.blaze3d.shaders.FogShape;
import com.mojang.blaze3d.systems.RenderSystem;
import org.joml.Vector4f;
import mods.railcraft.Railcraft;
import mods.railcraft.RailcraftConfig;
import mods.railcraft.Translations;
Expand Down Expand Up @@ -75,6 +73,7 @@
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.ParticleEngine;
import net.minecraft.client.renderer.BiomeColors;
import net.minecraft.client.renderer.FogParameters;
import net.minecraft.client.renderer.FogRenderer;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.ClickEvent;
Expand Down Expand Up @@ -301,19 +300,19 @@ public ResourceLocation getFlowingTexture() {

@Override
@NotNull
public Vector3f modifyFogColor(Camera camera, float partialTick,
ClientLevel level, int renderDistance, float darkenWorldAmount, Vector3f fluidFogColor) {
public Vector4f modifyFogColor(Camera camera, float partialTick,
ClientLevel level, int renderDistance, float darkenWorldAmount, Vector4f fluidFogColor) {
var x = Integer.parseInt("6A", 16) / 255f;
var y = Integer.parseInt("62", 16) / 255f;
var z = Integer.parseInt("00", 16) / 255f;
return new Vector3f(x, y, z);
return new Vector4f(x, y, z, fluidFogColor.w());
}

@Override
public void modifyFogRender(Camera camera, FogRenderer.FogMode mode, float renderDistance,
float partialTick, float nearDistance, float farDistance, FogShape shape) {
RenderSystem.setShaderFogStart(0);
RenderSystem.setShaderFogEnd(3f);
public FogParameters modifyFogRender(Camera camera, FogRenderer.FogMode mode,
float renderDistance, float partialTick, FogParameters fogParameters) {
return new FogParameters(0, 3f, fogParameters.shape(),
fogParameters.red(), fogParameters.green(), fogParameters.blue(), fogParameters.alpha());
}
}, RailcraftFluidTypes.CREOSOTE.get());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import mods.railcraft.client.util.GuiUtil;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;

Expand Down Expand Up @@ -45,8 +46,8 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia
this.renderBackground(guiGraphics, mouseX, mouseY, partialTicks);
int centredX = (this.width - this.windowWidth) / 2;
int centredY = (this.height - this.windowHeight) / 2;
guiGraphics.blit(this.backgroundTexture, centredX, centredY, 0, 0,
this.windowWidth, this.windowHeight);
guiGraphics.blit(RenderType::guiTextured, this.backgroundTexture, centredX, centredY, 0, 0,
this.windowWidth, this.windowHeight, 256, 256);
var poseStack = guiGraphics.pose();
poseStack.pushPose();
poseStack.translate(centredX, centredY, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,8 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia
RenderSystem.setShaderTexture(0, BOOK_LOCATION);
int xOffset = (this.width - IMAGE_WIDTH) / 2;
int yOffset = (this.height - IMAGE_HEIGHT) / 2;
guiGraphics.blit(BOOK_LOCATION, xOffset, yOffset, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);
guiGraphics.blit(RenderType::guiTextured, BOOK_LOCATION, xOffset, yOffset, 0, 0, IMAGE_WIDTH,
IMAGE_HEIGHT, 256, 256);
if (this.editingTitle) {
boolean flag = this.frameTick / 6 % 2 == 0;
var formattedcharsequence = FormattedCharSequence.composite(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.PageButton;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
Expand Down Expand Up @@ -114,7 +115,8 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia
RenderSystem.setShaderTexture(0, BOOK_LOCATION);
int xOffset = (this.width - IMAGE_WIDTH) / 2;
int yOffset = (this.height - IMAGE_HEIGHT) / 2;
guiGraphics.blit(BOOK_LOCATION, xOffset, yOffset, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);
guiGraphics.blit(RenderType::guiTextured, BOOK_LOCATION, xOffset, yOffset, 0, 0, IMAGE_WIDTH,
IMAGE_HEIGHT, 256, 256);

int l = this.font.width(this.pageMsg);
guiGraphics.drawString(this.font, this.pageMsg, xOffset - l + 225, yOffset + 15, 0, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import mods.railcraft.world.inventory.slot.RailcraftSlot;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory;
Expand Down Expand Up @@ -67,7 +68,8 @@ protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int mouseX,
int x = (this.width - this.getXSize()) / 2;
int y = (this.height - this.getYSize()) / 2;

guiGraphics.blit(getWidgetsTexture(), x, y, 0, 0, this.getXSize(), this.getYSize());
guiGraphics.blit(RenderType::guiTextured, getWidgetsTexture(), x, y, 0, 0, this.getXSize(),
this.getYSize(), 256, 256);

int relativeMouseX = mouseX - this.leftPos;
int relativeMouseY = mouseY - this.topPos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.jetbrains.annotations.Nullable;
import mods.railcraft.gui.widget.Widget;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;

Expand All @@ -27,8 +28,8 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {

public void render(ResourceLocation widgetLocation, GuiGraphics guiGraphics, int centreX, int centreY,
int mouseX, int mouseY) {
guiGraphics.blit(widgetLocation, centreX + this.widget.x, centreY + this.widget.y, this.widget.u,
this.widget.v, this.widget.w, this.widget.h);
guiGraphics.blit(RenderType::guiTextured, widgetLocation, centreX + this.widget.x, centreY + this.widget.y,
this.widget.u, this.widget.v, this.widget.w, this.widget.h, 256, 256);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import mods.railcraft.client.gui.screen.inventory.WidgetRenderer;
import mods.railcraft.gui.widget.AnalogGaugeWidget;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
Expand Down Expand Up @@ -83,7 +84,7 @@ public void render(ResourceLocation widgetLocation, GuiGraphics guiGraphics, int

BufferUploader.drawWithShader(buffer.buildOrThrow());

guiGraphics.blit(widgetLocation, centreX + this.widget.ox, centreY + this.widget.oy, this.widget.ou,
this.widget.ov, 4, 3);
guiGraphics.blit(RenderType::guiTextured, widgetLocation, centreX + this.widget.ox, centreY + this.widget.oy, this.widget.ou,
this.widget.ov, 4, 3, 256, 256);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import mods.railcraft.client.util.RenderUtil;
import mods.railcraft.gui.widget.FluidGaugeWidget;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.ARGB;
import net.minecraft.util.Mth;

public class FluidGaugeRenderer extends WidgetRenderer<FluidGaugeWidget> {
Expand Down Expand Up @@ -45,27 +45,23 @@ public void render(ResourceLocation widgetLocation, GuiGraphics guiGraphics, int
/ (float) this.widget.tank.getCapacity();

var color = RenderUtil.getColorARGB(fluidStack);
var alpha = ARGB.alpha(color) / 255.0F;
var red = ARGB.red(color) / 255.0F;
var green = ARGB.green(color) / 255.0F;
var blue = ARGB.blue(color) / 255.0F;

for (var col = 0; col < this.widget.w / 16; col++) {
for (var row = 0; row <= this.widget.h / 16; row++) {
guiGraphics.blit(centreX + this.widget.x + col * 16, centreY + this.widget.y + row * 16 - 1,
0, 16, 16, fluidIcon, red, green, blue, alpha);
guiGraphics.blit(RenderType::guiTextured, fluidIcon.atlasLocation(), centreX + this.widget.x + col * 16,
centreY + this.widget.y + row * 16 - 1, 0, 16, 16, color, 256, 256);
}
}

var mask = Mth.floor(this.widget.h * scale);
if (mask == 0 && fluidStack.getAmount() > 0) {
mask = 1;
}
guiGraphics.blit(widgetLocation, centreX + this.widget.x, centreY + this.widget.y - 1,
this.widget.x,
this.widget.y - 1, this.widget.w, this.widget.h - mask + 1);
guiGraphics.blit(widgetLocation, centreX + this.widget.x, centreY + this.widget.y,
this.widget.u,
this.widget.v, this.widget.w, this.widget.h);
guiGraphics.blit(RenderType::guiTextured, widgetLocation, centreX + this.widget.x,
centreY + this.widget.y - 1, this.widget.x, this.widget.y - 1, this.widget.w,
this.widget.h - mask + 1, 256, 256);
guiGraphics.blit(RenderType::guiTextured, widgetLocation, centreX + this.widget.x,
centreY + this.widget.y, this.widget.u, this.widget.v, this.widget.w,
this.widget.h, 256, 256);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import mods.railcraft.client.gui.screen.inventory.WidgetRenderer;
import mods.railcraft.gui.widget.GaugeWidget;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;

Expand All @@ -19,12 +20,12 @@ public void render(ResourceLocation widgetLocation, GuiGraphics guiGraphics, int
int scale = Math.round(this.widget.getMeasurement() *
(this.widget.isVertical() ? this.widget.h : this.widget.w));
if (this.widget.isVertical()) {
guiGraphics.blit(widgetLocation, centreX + this.widget.x,
guiGraphics.blit(RenderType::guiTextured, widgetLocation, centreX + this.widget.x,
centreY + this.widget.y + this.widget.h - scale,
this.widget.u, this.widget.v + this.widget.h - scale, this.widget.w, scale);
this.widget.u, this.widget.v + this.widget.h - scale, this.widget.w, scale, 256, 256);
} else {
guiGraphics.blit(widgetLocation, centreX + this.widget.x, centreY + this.widget.y,
this.widget.u, this.widget.v, scale, this.widget.h);
guiGraphics.blit(RenderType::guiTextured, widgetLocation, centreX + this.widget.x,
centreY + this.widget.y, this.widget.u, this.widget.v, scale, this.widget.h, 256, 256);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.Tooltip;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
Expand Down Expand Up @@ -51,10 +52,11 @@ public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float
int h = this.texturePosition.height();
int w = this.texturePosition.width();

guiGraphics.blit(WIDGETS_LOCATION, this.getX(), this.getY(), xOffset, yOffset + i * h, this.width / 2, h);
guiGraphics.blit(WIDGETS_LOCATION, this.getX() + this.width / 2, this.getY(),
xOffset + w - this.width / 2,
yOffset + i * h, this.width / 2, h);
guiGraphics.blit(RenderType::guiTextured, WIDGETS_LOCATION, this.getX(), this.getY(), xOffset,
yOffset + i * h, this.width / 2, h, 256, 256);
guiGraphics.blit(RenderType::guiTextured, WIDGETS_LOCATION, this.getX() + this.width / 2,
this.getY(), xOffset + w - this.width / 2, yOffset + i * h,
this.width / 2, h, 256, 256);
int j = getFGColor();
guiGraphics.drawCenteredString(font, this.getMessage(), this.getX() + this.width / 2,
this.getY() + (this.height - 8) / 2, j | Mth.ceil(this.alpha * 255.0F) << 24);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.inventory.PageButton;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;

public class RailcraftPageButton extends PageButton {
Expand All @@ -28,6 +29,7 @@ public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float
j += 13;
}

guiGraphics.blit(this.atlasLocation, this.getX(), this.getY(), i, j, 23, 13);
guiGraphics.blit(RenderType::guiTextured, this.atlasLocation, this.getX(), this.getY(), i, j,
23, 13, 256, 256);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
public class RailcraftBlockTagsProvider extends BlockTagsProvider {

public RailcraftBlockTagsProvider(PackOutput packOutput,
CompletableFuture<HolderLookup.Provider> lookupProvider,
ExistingFileHelper fileHelper) {
super(packOutput, lookupProvider, RailcraftConstants.ID, fileHelper);
CompletableFuture<HolderLookup.Provider> registries, ExistingFileHelper fileHelper) {
super(packOutput, registries, RailcraftConstants.ID, fileHelper);
}

@SuppressWarnings("unchecked")
@Override
protected void addTags(HolderLookup.Provider provider) {
protected void addTags(HolderLookup.Provider registries) {
this.tag(RailcraftTags.Blocks.BALLAST)
.addTag(Tags.Blocks.GRAVELS);
this.tag(RailcraftTags.Blocks.TRACK_UNDERCUTTER_INVALID_BALLAST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
public class RailcraftDamageTypeTagsProvider extends DamageTypeTagsProvider {

public RailcraftDamageTypeTagsProvider(PackOutput packOutput,
CompletableFuture<HolderLookup.Provider> lookupProvider,
ExistingFileHelper existingFileHelper) {
super(packOutput, lookupProvider, RailcraftConstants.ID, existingFileHelper);
CompletableFuture<HolderLookup.Provider> registries, ExistingFileHelper existingFileHelper) {
super(packOutput, registries, RailcraftConstants.ID, existingFileHelper);
}

@Override
protected void addTags(HolderLookup.Provider provider) {
protected void addTags(HolderLookup.Provider registries) {
//FIXME: Have to use addOptional, as the add method causes an error
// about missing references for some reason
this.tag(DamageTypeTags.BYPASSES_ARMOR)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public class RailcraftDataMapProvider extends DataMapProvider {
private static final int CREOSOTE_BUCKET_BURN_TIME = 800;

public RailcraftDataMapProvider(PackOutput packOutput,
CompletableFuture<HolderLookup.Provider> lookupProvider) {
super(packOutput, lookupProvider);
CompletableFuture<HolderLookup.Provider> registries) {
super(packOutput, registries);
}

@Override
protected void gather(HolderLookup.Provider provider) {
protected void gather(HolderLookup.Provider registries) {
this.builder(NeoForgeDataMaps.FURNACE_FUELS)
.add(RailcraftBlocks.COAL_COKE_BLOCK.getId(), new FurnaceFuel(COAL_COKE_BURN_TIME * 10), false)
.add(RailcraftItems.COAL_COKE.getId(), new FurnaceFuel(COAL_COKE_BURN_TIME), false)
Expand Down
Loading

0 comments on commit 081c764

Please sign in to comment.