Skip to content

Commit

Permalink
Port to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
Kneelawk committed Aug 1, 2024
1 parent 75cb7ed commit 1a99eaf
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 37 deletions.
16 changes: 8 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'org.cadixdev.licenser' version '0.6.1'
}

Expand All @@ -19,22 +19,22 @@ repositories {
}

archivesBaseName = "libblockatttributes"
version = "0.15.0-pre.4"
version = "0.16.0-pre.1"

license {
header = project.file('misc/LICENSE_HEADER.txt');
newLine = false;
}

dependencies {
minecraft "com.mojang:minecraft:1.20.5"
mappings "net.fabricmc:yarn:1.20.5+build.1:v2"
modCompileOnly "net.fabricmc:fabric-loader:0.15.10"
modLocalRuntime "net.fabricmc:fabric-loader:0.15.9"
minecraft "com.mojang:minecraft:1.21"
mappings "net.fabricmc:yarn:1.21+build.9:v2"
modCompileOnly "net.fabricmc:fabric-loader:0.15.11"
modLocalRuntime "net.fabricmc:fabric-loader:0.15.11"

//Fabric api
modCompileOnly "net.fabricmc.fabric-api:fabric-api:0.97.6+1.20.5"
modLocalRuntime "net.fabricmc.fabric-api:fabric-api:0.97.6+1.20.5"
modCompileOnly "net.fabricmc.fabric-api:fabric-api:0.100.8+1.21"
modLocalRuntime "net.fabricmc.fabric-api:fabric-api:0.100.8+1.21"

// Item-inventory
//modImplementation("com.github.emilyploszaj:item-inventory:v1.1.0") { transitive = false }
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@

@Mixin(FlowableFluid.class)
public interface FlowableFluidAccessor {
@Invoker("getFlowSpeed")
int lba_getFlowSpeed(WorldView worldView);
@Invoker("getMaxFlowDistance")
int lba_getMaxFlowDistance(WorldView worldView);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.BufferAllocator;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.fluid.Fluid;
import net.minecraft.screen.PlayerScreenHandler;
Expand Down Expand Up @@ -226,7 +227,6 @@ protected static void vertex(
vc.overlay(OverlayTexture.DEFAULT_UV);
vc.light(light);
vc.normal(matrices.peek(), nx, ny, nz);
vc.next();
}

public static final class ComponentRenderFaces {
Expand All @@ -248,8 +248,8 @@ public static final class ExpandingVcp implements VertexConsumerProvider {
private final List<RenderLayer> translucent = new ArrayList<>();
private final List<RenderLayer> after = new ArrayList<>();

private final List<BufferBuilder> availableBuffers = new ArrayList<>();
private final Map<RenderLayer, BufferBuilder> activeBuffers = new HashMap<>();
private final Map<RenderLayer, BufferAllocator> layerBuffers = new HashMap<>();
private final Map<RenderLayer, BufferBuilder> pending = new HashMap<>();
private final Set<RenderLayer> knownLayers = new HashSet<>();

public ExpandingVcp() {
Expand All @@ -264,6 +264,7 @@ public ExpandingVcp() {

public void addLayer(RenderLayer layer) {
if (knownLayers.add(layer)) {
layerBuffers.put(layer, new BufferAllocator(1 << 12));
if (((RenderLayerAccessor) layer).libblockattributes_isTranslucent()) {
translucent.add(layer);
} else {
Expand All @@ -274,36 +275,34 @@ public void addLayer(RenderLayer layer) {

public void addLayerBefore(RenderLayer layer) {
if (knownLayers.add(layer)) {
layerBuffers.put(layer, new BufferAllocator(1 << 12));
before.add(layer);
}
}

public void addLayerMiddle(RenderLayer layer) {
if (knownLayers.add(layer)) {
layerBuffers.put(layer, new BufferAllocator(1 << 12));
middle.add(layer);
}
}

public void addLayerAfter(RenderLayer layer) {
if (knownLayers.add(layer)) {
layerBuffers.put(layer, new BufferAllocator(1 << 12));
after.add(layer);
}
}

@Override
public VertexConsumer getBuffer(RenderLayer layer) {
addLayer(layer);
BufferBuilder buffer = activeBuffers.get(layer);
BufferBuilder buffer = pending.get(layer);
if (buffer == null) {
if (availableBuffers.isEmpty()) {
buffer = new BufferBuilder(1 << 12);
} else {
buffer = availableBuffers.remove(availableBuffers.size() - 1);
}
activeBuffers.put(layer, buffer);
}
if (!buffer.isBuilding()) {
buffer.begin(layer.getDrawMode(), layer.getVertexFormat());
// should never be null, thanks to addLayer
BufferAllocator allocator = layerBuffers.get(layer);
buffer = new BufferBuilder(allocator, layer.getDrawMode(), layer.getVertexFormat());
pending.put(layer, buffer);
}
return buffer;
}
Expand All @@ -324,14 +323,14 @@ public void drawDirectly() {
draw(middle);
draw(translucent);
draw(after);
assert activeBuffers.isEmpty();
assert pending.isEmpty();
}

private void draw(List<RenderLayer> layers) {
for (RenderLayer layer : layers) {
BufferBuilder buffer = activeBuffers.remove(layer);
BufferBuilder buffer = pending.remove(layer);
if (buffer != null) {
layer.draw(buffer, RenderSystem.getVertexSorting());
layer.draw(buffer.end());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public abstract class FluidKey {
/** The default {@link #density} (and {@link #thermalCapacity}) that gases use: 1/160. */
public static final FluidAmount DEFAULT_GAS_DENSITY = FluidAmount.of(1, 160);

private static final Identifier MISSING_SPRITE = new Identifier("minecraft", "missingno");
private static final Identifier MISSING_SPRITE = Identifier.ofVanilla("missingno");

public static final JsonDeserializer<FluidKey> DESERIALIZER = (json, type, ctx) -> {
if (json.isJsonNull()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
public final class FluidKeys {
private FluidKeys() {}

public static final Identifier MISSING_SPRITE = new Identifier("minecraft", "missingno");
public static final Identifier MISSING_SPRITE = Identifier.ofVanilla("missingno");

public static final FluidKey EMPTY;
public static final FluidKey LAVA;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

/* package-private */ final class WaterFluidKey extends BiomeSourcedFluidKey {

public static final Identifier SPRITE_STILL = new Identifier("minecraft", "block/water_still");
public static final Identifier SPRITE_FLOWING = new Identifier("minecraft", "block/water_flowing");
public static final Identifier SPRITE_STILL = Identifier.ofVanilla("block/water_still");
public static final Identifier SPRITE_FLOWING = Identifier.ofVanilla("block/water_flowing");

static final WaterFluidKey INSTANCE = new WaterFluidKey();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private LbaModule(String id) {
}

public Identifier id(String path) {
return new Identifier(id, path);
return Identifier.of(id, path);
}

@Nullable
Expand All @@ -48,6 +48,6 @@ public ModContainer getModContainer() {
}

public static Identifier id(String path) {
return new Identifier(MODID, path);
return Identifier.of(MODID, path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class FluidPropertyTester extends VanillaSetupBaseTester {
@Test
public void testFluidProperty() {
FluidKey mana = new SimpleFluidKey(
new FluidKeyBuilder(new Identifier("lba_test:mana"))//
new FluidKeyBuilder(Identifier.of("lba_test:mana"))//
.setName(Text.literal("Mana"))//
.setUnit(FluidUnit.BOTTLE)//
);
Expand Down Expand Up @@ -65,7 +65,7 @@ public static class PurityProp extends FluidProperty<Purity> {
public static final PurityProp INSTANCE = new PurityProp();

private PurityProp() {
super(new Identifier("lba_test:purity"), Purity.class, Purity.NONE);
super(Identifier.of("lba_test:purity"), Purity.class, Purity.NONE);
}

@Override
Expand Down

0 comments on commit 1a99eaf

Please sign in to comment.