Skip to content

Commit 51db23d

Browse files
committed
Port to 1.19.4
1 parent 59b0adb commit 51db23d

13 files changed

+77
-63
lines changed

build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ java.toolchain.languageVersion = JavaLanguageVersion.of(17)
1313

1414
println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
1515
minecraft {
16-
mappings channel: 'parchment', version: '2023.02.05-1.19.3'
16+
mappings channel: 'parchment', version: '1.19.3-2023.03.12-1.19.4'
1717

1818
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
1919

@@ -76,9 +76,9 @@ repositories {
7676
}
7777

7878
dependencies {
79-
minecraft 'net.minecraftforge:forge:1.19.3-44.1.20'
79+
minecraft 'net.minecraftforge:forge:1.19.4-45.1.0'
8080

81-
implementation fg.deobf("curse.maven:top-245211:4159743")
81+
implementation fg.deobf("curse.maven:the-one-probe-245211:4442439")
8282
}
8383

8484
jar {

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ org.gradle.jvmargs=-Xmx3G
44
org.gradle.daemon=false
55

66
#version info
7-
minecraft_version=1.19.3
7+
minecraft_version=1.19.4
88
mod_version=1.1.6.2

src/main/java/platinpython/rgbblocks/RGBBlocks.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static void rgbBlocksTab(CreativeModeTabEvent.Register event) {
7777
ItemStack stack = new ItemStack(ItemRegistry.PAINT_BUCKET.get());
7878
stack.getOrCreateTag().putInt("color", -1);
7979
return stack;
80-
}).displayItems((enabledFeatures, output, displayOperatorCreativeTab) -> {
80+
}).displayItems((displayParameters, output) -> {
8181
List<ItemStack> items = new ArrayList<>(
8282
RegistryHandler.ITEMS.getEntries()
8383
.stream()

src/main/java/platinpython/rgbblocks/block/RGBConcretePowderBlock.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import net.minecraft.world.level.block.EntityBlock;
1515
import net.minecraft.world.level.block.entity.BlockEntity;
1616
import net.minecraft.world.level.block.state.BlockState;
17+
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
1718
import net.minecraft.world.phys.HitResult;
1819
import platinpython.rgbblocks.entity.RGBFallingBlockEntity;
1920
import platinpython.rgbblocks.tileentity.RGBTileEntity;
@@ -46,13 +47,20 @@ public void tick(BlockState state, ServerLevel worldIn, BlockPos pos, RandomSour
4647
BlockEntity tileEntity = worldIn.getBlockEntity(pos);
4748
RGBFallingBlockEntity fallingBlockEntity = new RGBFallingBlockEntity(worldIn, (double) pos.getX() + 0.5D,
4849
pos.getY(), (double) pos.getZ() + 0.5D,
50+
state.hasProperty(
51+
BlockStateProperties.WATERLOGGED) ?
52+
state.setValue(
53+
BlockStateProperties.WATERLOGGED,
54+
Boolean.valueOf(false)
55+
) :
4956
state,
5057
tileEntity instanceof RGBTileEntity ?
5158
((RGBTileEntity) tileEntity).getColor() :
5259
0
5360
);
54-
this.falling(fallingBlockEntity);
61+
worldIn.setBlock(pos, state.getFluidState().createLegacyBlock(), 3);
5562
worldIn.addFreshEntity(fallingBlockEntity);
63+
this.falling(fallingBlockEntity);
5664
}
5765
}
5866

src/main/java/platinpython/rgbblocks/client/gui/ScreenUtils.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,15 @@
1010
import org.joml.Matrix4f;
1111

1212
public class ScreenUtils {
13-
public static void fillGradient(PoseStack pPoseStack, int x1, int y1, int x2, int y2, int colorFrom, int colorTo,
14-
int blitOffset) {
15-
RenderSystem.disableTexture();
13+
public static void fillGradient(PoseStack pPoseStack, int x1, int y1, int x2, int y2, int colorFrom, int colorTo) {
1614
RenderSystem.enableBlend();
17-
RenderSystem.defaultBlendFunc();
1815
RenderSystem.setShader(GameRenderer::getPositionColorShader);
1916
Tesselator tesselator = Tesselator.getInstance();
2017
BufferBuilder bufferbuilder = tesselator.getBuilder();
2118
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
22-
fillGradient(pPoseStack.last().pose(), bufferbuilder, x1, y1, x2, y2, blitOffset, colorFrom, colorTo);
19+
fillGradient(pPoseStack.last().pose(), bufferbuilder, x1, y1, x2, y2, 0, colorFrom, colorTo);
2320
tesselator.end();
2421
RenderSystem.disableBlend();
25-
RenderSystem.enableTexture();
2622
}
2723

2824
private static void fillGradient(Matrix4f matrix4f, BufferBuilder builder, int x1, int y1, int x2, int y2, int z,

src/main/java/platinpython/rgbblocks/client/gui/screen/ColorSelectScreen.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public class ColorSelectScreen extends Screen {
4040
public ColorSelectScreen(int colorIn, boolean isRGBSelected) {
4141
super(Component.empty());
4242
Color color = new Color(colorIn);
43-
this.red = (double) color.getRed();
44-
this.green = (double) color.getGreen();
45-
this.blue = (double) color.getBlue();
43+
this.red = color.getRed();
44+
this.green = color.getGreen();
45+
this.blue = color.getBlue();
4646

4747
float[] hsb = Color.RGBtoHSB((int) red, (int) green, (int) blue);
4848
this.hue = hsb[0] * MAX_VALUE_HUE;

src/main/java/platinpython/rgbblocks/client/gui/widget/ColorSlider.java

+41-33
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package platinpython.rgbblocks.client.gui.widget;
22

3+
import com.mojang.blaze3d.systems.RenderSystem;
34
import com.mojang.blaze3d.vertex.PoseStack;
45
import net.minecraft.client.Minecraft;
56
import net.minecraft.client.gui.components.AbstractSliderButton;
@@ -63,63 +64,70 @@ public void setValueInt(int value) {
6364
}
6465

6566
@Override
66-
public void renderButton(PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) {
67+
public void renderWidget(PoseStack poseStack, int mouseX, int mouseY, float partialTicks) {
6768
if (this.visible) {
6869
Minecraft minecraft = Minecraft.getInstance();
69-
fill(matrixStack, this.getX(), this.getY(), this.getX() + this.width, this.getY() + this.height, 0xFF000000);
70+
fill(poseStack, this.getX(), this.getY(), this.getX() + this.width, this.getY() + this.height, 0xFF000000);
7071
if (minecraft.screen instanceof ColorSelectScreen) {
7172
ColorSelectScreen screen = (ColorSelectScreen) minecraft.screen;
7273
switch (type) {
7374
case RED:
74-
renderRedBackground(matrixStack, screen);
75+
renderRedBackground(poseStack, screen);
7576
break;
7677
case GREEN:
77-
renderGreenBackground(matrixStack, screen);
78+
renderGreenBackground(poseStack, screen);
7879
break;
7980
case BLUE:
80-
renderBlueBackground(matrixStack, screen);
81+
renderBlueBackground(poseStack, screen);
8182
break;
8283
case HUE:
83-
renderHueBackground(matrixStack, screen);
84+
renderHueBackground(poseStack, screen);
8485
break;
8586
case SATURATION:
86-
renderSaturationBackground(matrixStack, screen);
87+
renderSaturationBackground(poseStack, screen);
8788
break;
8889
case BRIGHTNESS:
89-
renderBrightnessBackground(matrixStack, screen);
90+
renderBrightnessBackground(poseStack, screen);
9091
break;
9192
}
9293
}
9394

94-
this.renderBg(matrixStack, minecraft, mouseX, mouseY);
95+
RenderSystem.setShaderTexture(0, SLIDER_LOCATION);
96+
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, this.alpha);
97+
RenderSystem.enableBlend();
98+
RenderSystem.defaultBlendFunc();
99+
RenderSystem.enableDepthTest();
100+
AbstractSliderButton.blitNineSliced(poseStack, this.getX() + (int) (this.value * (double) (this.width - 8)),
101+
this.getY(), 8, 20, 20, 4, 200, 20, 0, this.getHandleTextureY()
102+
);
95103

96-
drawCenteredString(matrixStack, minecraft.font, this.getMessage(), this.getX() + this.width / 2,
97-
this.getY() - (this.height) / 10 * 7, getFGColor()
104+
drawCenteredString(poseStack, minecraft.font, this.getMessage(), this.getX() + this.width / 2,
105+
this.getY() - this.height / 10 * 7, getFGColor()
98106
);
99107
}
100108
}
101109

102110
private void renderRedBackground(PoseStack matrixStack, ColorSelectScreen screen) {
103111
int leftColor = new Color(0x00, screen.greenSlider.getValueInt(), screen.blueSlider.getValueInt()).getRGB();
104112
int rightColor = new Color(0xFF, screen.greenSlider.getValueInt(), screen.blueSlider.getValueInt()).getRGB();
105-
ScreenUtils.fillGradient(matrixStack, this.getX() + 1, this.getY() + 1, this.getX() + this.width - 1, this.getY() + this.height - 1,
106-
leftColor, rightColor, this.getBlitOffset()
113+
ScreenUtils.fillGradient(matrixStack, this.getX() + 1, this.getY() + 1, this.getX() + this.width - 1,
114+
this.getY() + this.height - 1, leftColor, rightColor
107115
);
108116
}
109117

110118
private void renderGreenBackground(PoseStack matrixStack, ColorSelectScreen screen) {
111119
int leftColor = new Color(screen.redSlider.getValueInt(), 0x00, screen.blueSlider.getValueInt()).getRGB();
112120
int rightColor = new Color(screen.redSlider.getValueInt(), 0xFF, screen.blueSlider.getValueInt()).getRGB();
113-
ScreenUtils.fillGradient(matrixStack, this.getX() + 1, this.getY() + 1, this.getX() + this.width - 1, this.getY() + this.height - 1,
114-
leftColor, rightColor, this.getBlitOffset()
121+
ScreenUtils.fillGradient(matrixStack, this.getX() + 1, this.getY() + 1, this.getX() + this.width - 1,
122+
this.getY() + this.height - 1, leftColor, rightColor
115123
);
116124
}
117125

118126
private void renderBlueBackground(PoseStack matrixStack, ColorSelectScreen screen) {
119127
int leftColor = new Color(screen.redSlider.getValueInt(), screen.greenSlider.getValueInt(), 0x00).getRGB();
120128
int rightColor = new Color(screen.redSlider.getValueInt(), screen.greenSlider.getValueInt(), 0xFF).getRGB();
121-
ScreenUtils.fillGradient(matrixStack, this.getX() + 1, this.getY() + 1, this.getX() + this.width - 1, this.getY() + this.height - 1,
122-
leftColor, rightColor, this.getBlitOffset()
129+
ScreenUtils.fillGradient(matrixStack, this.getX() + 1, this.getY() + 1, this.getX() + this.width - 1,
130+
this.getY() + this.height - 1, leftColor, rightColor
123131
);
124132
}
125133

@@ -130,23 +138,23 @@ private void renderHueBackground(PoseStack matrixStack, ColorSelectScreen screen
130138
(float) (screen.saturationSlider.getValueInt() / ColorSelectScreen.MAX_VALUE_SB),
131139
(float) (screen.brightnessSlider.getValueInt() / ColorSelectScreen.MAX_VALUE_SB)
132140
);
133-
ScreenUtils.fillGradient(matrixStack, lerp.apply(0), this.getY() + 1, lerp.apply(17), this.getY() + this.height - 1,
134-
color.apply(0), color.apply(17), this.getBlitOffset()
141+
ScreenUtils.fillGradient(matrixStack, lerp.apply(0), this.getY() + 1, lerp.apply(17),
142+
this.getY() + this.height - 1, color.apply(0), color.apply(17)
135143
);
136-
ScreenUtils.fillGradient(matrixStack, lerp.apply(17), this.getY() + 1, lerp.apply(34), this.getY() + this.height - 1,
137-
color.apply(17), color.apply(34), this.getBlitOffset()
144+
ScreenUtils.fillGradient(matrixStack, lerp.apply(17), this.getY() + 1, lerp.apply(34),
145+
this.getY() + this.height - 1, color.apply(17), color.apply(34)
138146
);
139-
ScreenUtils.fillGradient(matrixStack, lerp.apply(34), this.getY() + 1, lerp.apply(50), this.getY() + this.height - 1,
140-
color.apply(34), color.apply(50), this.getBlitOffset()
147+
ScreenUtils.fillGradient(matrixStack, lerp.apply(34), this.getY() + 1, lerp.apply(50),
148+
this.getY() + this.height - 1, color.apply(34), color.apply(50)
141149
);
142-
ScreenUtils.fillGradient(matrixStack, lerp.apply(50), this.getY() + 1, lerp.apply(66), this.getY() + this.height - 1,
143-
color.apply(50), color.apply(66), this.getBlitOffset()
150+
ScreenUtils.fillGradient(matrixStack, lerp.apply(50), this.getY() + 1, lerp.apply(66),
151+
this.getY() + this.height - 1, color.apply(50), color.apply(66)
144152
);
145-
ScreenUtils.fillGradient(matrixStack, lerp.apply(66), this.getY() + 1, lerp.apply(82), this.getY() + this.height - 1,
146-
color.apply(66), color.apply(82), this.getBlitOffset()
153+
ScreenUtils.fillGradient(matrixStack, lerp.apply(66), this.getY() + 1, lerp.apply(82),
154+
this.getY() + this.height - 1, color.apply(66), color.apply(82)
147155
);
148-
ScreenUtils.fillGradient(matrixStack, lerp.apply(82), this.getY() + 1, lerp.apply(100), this.getY() + this.height - 1,
149-
color.apply(82), color.apply(100), this.getBlitOffset()
156+
ScreenUtils.fillGradient(matrixStack, lerp.apply(82), this.getY() + 1, lerp.apply(100),
157+
this.getY() + this.height - 1, color.apply(82), color.apply(100)
150158
);
151159
}
152160

@@ -157,8 +165,8 @@ private void renderSaturationBackground(PoseStack matrixStack, ColorSelectScreen
157165
int rightColor = Color.HSBtoRGB((float) (screen.hueSlider.getValue() / ColorSelectScreen.MAX_VALUE_HUE), 1.0f,
158166
(float) (screen.brightnessSlider.getValue() / ColorSelectScreen.MAX_VALUE_SB)
159167
);
160-
ScreenUtils.fillGradient(matrixStack, this.getX() + 1, this.getY() + 1, this.getX() + this.width - 1, this.getY() + this.height - 1,
161-
leftColor, rightColor, this.getBlitOffset()
168+
ScreenUtils.fillGradient(matrixStack, this.getX() + 1, this.getY() + 1, this.getX() + this.width - 1,
169+
this.getY() + this.height - 1, leftColor, rightColor
162170
);
163171
}
164172

@@ -171,8 +179,8 @@ private void renderBrightnessBackground(PoseStack matrixStack, ColorSelectScreen
171179
(float) (screen.saturationSlider.getValue() / ColorSelectScreen.MAX_VALUE_SB),
172180
1.0f
173181
);
174-
ScreenUtils.fillGradient(matrixStack, this.getX() + 1, this.getY() + 1, this.getX() + this.width - 1, this.getY() + this.height - 1,
175-
leftColor, rightColor, this.getBlitOffset()
182+
ScreenUtils.fillGradient(matrixStack, this.getX() + 1, this.getY() + 1, this.getX() + this.width - 1,
183+
this.getY() + this.height - 1, leftColor, rightColor
176184
);
177185
}
178186
}

src/main/java/platinpython/rgbblocks/client/renderer/entity/RGBFallingBlockRenderer.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
import com.mojang.blaze3d.vertex.PoseStack;
44
import net.minecraft.client.renderer.MultiBufferSource;
5-
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
65
import net.minecraft.client.renderer.entity.EntityRenderer;
76
import net.minecraft.client.renderer.entity.EntityRendererProvider.Context;
87
import net.minecraft.client.renderer.entity.ItemRenderer;
98
import net.minecraft.client.renderer.texture.OverlayTexture;
109
import net.minecraft.resources.ResourceLocation;
10+
import net.minecraft.world.item.ItemDisplayContext;
1111
import net.minecraft.world.item.ItemStack;
1212
import platinpython.rgbblocks.RGBBlocks;
1313
import platinpython.rgbblocks.entity.RGBFallingBlockEntity;
@@ -28,8 +28,8 @@ public void render(RGBFallingBlockEntity fallingBlockEntity, float entityYaw, fl
2828
poseStack.translate(0.0D, 0.5D, 0.0D);
2929
ItemStack stack = new ItemStack(fallingBlockEntity.getBlockState().getBlock());
3030
stack.getOrCreateTag().putInt("color", fallingBlockEntity.getColor());
31-
itemRenderer.renderStatic(stack, TransformType.NONE, packedLight, OverlayTexture.NO_OVERLAY, poseStack, buffer,
32-
fallingBlockEntity.getId()
31+
itemRenderer.renderStatic(stack, ItemDisplayContext.NONE, packedLight, OverlayTexture.NO_OVERLAY, poseStack,
32+
buffer, null, fallingBlockEntity.getId()
3333
);
3434
poseStack.popPose();
3535
}

src/main/java/platinpython/rgbblocks/entity/RGBFallingBlockEntity.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ protected void readAdditionalSaveData(CompoundTag compound) {
5454
@Override
5555
public void writeSpawnData(FriendlyByteBuf buffer) {
5656
buffer.writeInt(color);
57-
buffer.writeWithCodec(BlockState.CODEC, blockState);
57+
buffer.writeJsonWithCodec(BlockState.CODEC, blockState);
5858
}
5959

6060
@Override
6161
public void readSpawnData(FriendlyByteBuf additionalData) {
6262
color = additionalData.readInt();
63-
blockState = additionalData.readWithCodec(BlockState.CODEC);
63+
blockState = additionalData.readJsonWithCodec(BlockState.CODEC);
6464
}
6565

6666
@Override

src/main/java/platinpython/rgbblocks/item/crafting/ShapelessDurabilityAwarePaintBucketRecipe.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.google.gson.JsonObject;
55
import com.google.gson.JsonParseException;
66
import net.minecraft.core.NonNullList;
7+
import net.minecraft.core.RegistryAccess;
78
import net.minecraft.network.FriendlyByteBuf;
89
import net.minecraft.resources.ResourceLocation;
910
import net.minecraft.util.GsonHelper;
@@ -64,15 +65,15 @@ public NonNullList<ItemStack> getRemainingItems(CraftingContainer craftingInvent
6465
}
6566

6667
@Override
67-
public ItemStack assemble(CraftingContainer craftingInventory) {
68+
public ItemStack assemble(CraftingContainer craftingInventory, RegistryAccess registryAccess) {
6869
int color = 0;
6970
for (int i = 0; i < craftingInventory.getContainerSize(); i++) {
7071
if (craftingInventory.getItem(i).getItem() instanceof PaintBucketItem) {
7172
color = craftingInventory.getItem(i).getOrCreateTag().getInt("color");
7273
break;
7374
}
7475
}
75-
ItemStack result = super.assemble(craftingInventory);
76+
ItemStack result = super.assemble(craftingInventory, registryAccess);
7677
result.getOrCreateTag().putInt("color", color);
7778
return result;
7879
}
@@ -129,7 +130,7 @@ public void toNetwork(FriendlyByteBuf buffer, ShapelessDurabilityAwarePaintBucke
129130
ingredient.toNetwork(buffer);
130131
}
131132

132-
buffer.writeItem(recipe.getResultItem());
133+
buffer.writeItem(recipe.getResultItem(RegistryAccess.EMPTY));
133134
}
134135
}
135136
}

src/main/java/platinpython/rgbblocks/item/crafting/ShapelessNoReturnRecipe.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.google.gson.JsonObject;
55
import com.google.gson.JsonParseException;
66
import net.minecraft.core.NonNullList;
7+
import net.minecraft.core.RegistryAccess;
78
import net.minecraft.network.FriendlyByteBuf;
89
import net.minecraft.resources.ResourceLocation;
910
import net.minecraft.util.GsonHelper;
@@ -82,7 +83,7 @@ public void toNetwork(FriendlyByteBuf buffer, ShapelessNoReturnRecipe recipe) {
8283
ingredient.toNetwork(buffer);
8384
}
8485

85-
buffer.writeItem(recipe.getResultItem());
86+
buffer.writeItem(recipe.getResultItem(RegistryAccess.EMPTY));
8687
}
8788
}
8889
}

src/main/resources/META-INF/mods.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
modLoader="javafml"
2-
loaderVersion="[44,)"
2+
loaderVersion="[45,)"
33
license="MIT"
44
issueTrackerURL="https://github.com/PlatinPython/RGBBlocks/issues"
55

@@ -17,13 +17,13 @@ issueTrackerURL="https://github.com/PlatinPython/RGBBlocks/issues"
1717
[[dependencies.rgbblocks]]
1818
modId="forge"
1919
mandatory=true
20-
versionRange="[44,)"
20+
versionRange="[45,)"
2121
ordering="NONE"
2222
side="BOTH"
2323

2424
[[dependencies.rgbblocks]]
2525
modId="minecraft"
2626
mandatory=true
27-
versionRange="[1.19.3,1.19.4)"
27+
versionRange="1.19.4"
2828
ordering="NONE"
2929
side="BOTH"

0 commit comments

Comments
 (0)