Skip to content

Commit

Permalink
Merge pull request #5
Browse files Browse the repository at this point in the history
* Attempt to update to latest biny and newer gradle, loom, and mod vers…

* Undo migration to newer biny mappings

* Update to latest biny mappings (correctly this time)

* Get mod working on StationAPI alpha.3

* Remove mixin extras; Update AMI version; Fix version number

* Changed StationAPI version compatibility in fabric.mod.json
  • Loading branch information
telvarost authored Jan 7, 2025
1 parent 948b1fc commit 69956c9
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 82 deletions.
28 changes: 18 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'babric-loom' version '1.4.2'
id 'fabric-loom' version '1.8.12'
id 'babric-loom-extension' version '1.8.9'
id 'maven-publish'
}

Expand All @@ -11,7 +12,6 @@ version = project.mod_version
group = project.maven_group

loom {
gluedMinecraftJar()
customMinecraftManifest.set("https://babric.github.io/manifest-polyfill/${minecraft_version}.json")
intermediaryUrl.set("https://maven.glass-launcher.net/babric/babric/intermediary/%1\$s/intermediary-%1\$s-v2.jar")
}
Expand Down Expand Up @@ -48,6 +48,7 @@ repositories {
name = 'Jitpack'
url = 'https://jitpack.io'
}
// Used for another StationAPI dependency
exclusiveContent {
forRepository {
maven {
Expand All @@ -70,19 +71,26 @@ dependencies {

implementation "org.slf4j:slf4j-api:1.8.0-beta4"
implementation 'org.apache.logging.log4j:log4j-slf4j18-impl:2.17.2'
implementation(include("me.carleslc:Simple-Yaml:1.8.4") as Dependency)

modImplementation "net.modificationstation:StationAPI:${project.stapi_version}"

// Optional, but convenient mods for mod creators and users alike.
modImplementation("com.github.calmilamsy:ModMenu:${project.modmenu_version}") {
modImplementation("net.glasslauncher.mods:ModMenu:${project.modmenu_version}") {
transitive false
}

modImplementation("net.glasslauncher.mods:glass-networking:${project.glass_networking_version}") {
transitive false
}

modImplementation("net.glasslauncher.mods:GlassConfigAPI:${project.gcapi_version}") {
transitive false
}

modImplementation("net.glasslauncher.mods:AlwaysMoreItems:${project.alwaysmoreitems_version}") {
transitive false
}
// modImplementation("net.glasslauncher.mods:GlassConfigAPI:${project.gcapi_version}") {
// transitive false
// }
// modImplementation("net.glasslauncher:HowManyItems-Fabric-Unofficial:${project.howmanyitems_version}") {
// transitive false
// }
}

processResources {
Expand Down Expand Up @@ -127,4 +135,4 @@ publishing {
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
}
15 changes: 8 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ org.gradle.daemon=false
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=b1.7.3
yarn_mappings=b1.7.3+a00e3b0
loader_version=0.14.24-babric.1
yarn_mappings=b1.7.3+c6a9668
loader_version=0.15.6-babric.1

# Mod Properties
mod_version=1.1.5
mod_version=1.1.6
maven_group=net.mine_diver
archives_base_name=SmoothBeta

# Dependencies
stapi_version=2.0-alpha.1
stapi_version=2.0.0-alpha.3

# Extra Dependencies
gcapi_version=1.1.6
howmanyitems_version=5.0.13
modmenu_version=v1.8.5-beta.3
glass_networking_version=1.0.3
gcapi_version=3.0.2
alwaysmoreitems_version=1.4.0
modmenu_version=1.8.5-beta.9
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,45 @@
import net.mine_diver.smoothbeta.client.render.gl.GlUniform;
import net.mine_diver.smoothbeta.client.render.gl.VertexBuffer;
import net.mine_diver.smoothbeta.mixin.client.multidraw.RenderListAccessor;
import net.minecraft.class_472;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.client.render.world.ChunkRenderer;
import net.modificationstation.stationapi.api.util.math.Vec3f;

import java.nio.IntBuffer;
import java.util.ArrayList;
import java.util.List;

public class RenderRegion extends class_472 {
public class RenderRegion extends ChunkRenderer {

private final RenderListAccessor _super = (RenderListAccessor) this;
private final SmoothWorldRenderer stationWorldRenderer;
private final List<VertexBuffer> buffers = new ArrayList<>();

public RenderRegion(WorldRenderer worldRenderer) {
_super.smoothbeta_setField_2486(IntBuffer.allocate(0));
_super.smoothbeta_setGlListBuffer(IntBuffer.allocate(0));
stationWorldRenderer = ((SmoothWorldRenderer) worldRenderer);
}

@Override
public void method_1912(int i, int j, int k, double d, double e, double f) {
super.method_1912(i, j, k, d, e, f);
public void init(int i, int j, int k, double d, double e, double f) {
super.init(i, j, k, d, e, f);
buffers.clear();
}

@Override
public void method_1910(int i) {
public void addGlList(int i) {
throw new UnsupportedOperationException("Call lists can't be added to VBO regions!");
}

public void addBuffer(VertexBuffer buffer) {
buffers.add(buffer);
}

public void method_1909() {
if (!_super.smoothbeta_getField_2487() || buffers.isEmpty()) return;
public void render() {
if (!_super.smoothbeta_getInitialized() || buffers.isEmpty()) return;
Shader shader = Shaders.getTerrainShader();
GlUniform chunkOffset = shader.chunkOffset;
chunkOffset.set(_super.smoothbeta_getField_2480() - _super.smoothbeta_getField_2483(), _super.smoothbeta_getField_2481() - _super.smoothbeta_getField_2484(), _super.smoothbeta_getField_2482() - _super.smoothbeta_getField_2485());
chunkOffset.set(_super.smoothbeta_getX() - _super.smoothbeta_getOffsetX(), _super.smoothbeta_getY() - _super.smoothbeta_getOffsetY(), _super.smoothbeta_getZ() - _super.smoothbeta_getOffsetZ());
chunkOffset.upload();
for (VertexBuffer vertexBuffer : buffers) vertexBuffer.uploadToPool();
stationWorldRenderer.smoothbeta_getTerrainVboPool().drawAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.nio.ByteBuffer;
import java.nio.IntBuffer;

@SuppressWarnings("removal")
public class VboPool implements AutoCloseable {
@SuppressWarnings("deprecation")
private static final MinecraftAccessor mc = ((MinecraftAccessor) FabricLoader.getInstance().getGameInstance());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import net.minecraft.class_243;
import net.minecraft.class_326;
import net.minecraft.class_43;
import net.minecraft.class_51;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkCache;
import net.minecraft.world.chunk.ChunkSource;
import net.minecraft.world.chunk.storage.ChunkStorage;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -18,23 +18,23 @@

import java.util.Map;

@Mixin(class_326.class)
@Mixin(ChunkCache.class)
abstract class MixinServerChunkCache {

@Shadow private Map<Integer, class_43> field_1229;
@Shadow private Map<Integer, Chunk> chunkByPos;

@Shadow public abstract class_43 method_1807(int chunkX, int chunkZ);
@Shadow public abstract Chunk loadChunk(int chunkX, int chunkZ);

@Unique
private Int2ObjectMap<class_43> smoothbeta$serverChunkCache;
private Int2ObjectMap<Chunk> smoothbeta$serverChunkCache;

@Inject(
method = "<init>",
at = @At("RETURN")
)
private void getMap(World level, class_243 arg1, class_51 arg2, CallbackInfo ci) {
private void getMap(World level, ChunkStorage arg1, ChunkSource arg2, CallbackInfo ci) {
smoothbeta$serverChunkCache = new Int2ObjectOpenHashMap<>();
field_1229 = smoothbeta$serverChunkCache;
chunkByPos = smoothbeta$serverChunkCache;
}

// TODO: replace with ASM
Expand All @@ -43,7 +43,7 @@ private void getMap(World level, class_243 arg1, class_51 arg2, CallbackInfo ci)
* @author mine_diver
*/
@Overwrite
public boolean method_1802(int chunkX, int chunkZ) {
public boolean isChunkLoaded(int chunkX, int chunkZ) {
return smoothbeta$serverChunkCache.containsKey(ChunkPos.hashCode(chunkX, chunkZ));
}

Expand All @@ -53,8 +53,8 @@ public boolean method_1802(int chunkX, int chunkZ) {
* @author mine_diver
*/
@Overwrite
public class_43 method_1806(int chunkX, int chunkZ) {
class_43 var3 = smoothbeta$serverChunkCache.get(ChunkPos.hashCode(chunkX, chunkZ));
return var3 == null ? method_1807(chunkX, chunkZ) : var3;
public Chunk getChunk(int chunkX, int chunkZ) {
Chunk var3 = smoothbeta$serverChunkCache.get(ChunkPos.hashCode(chunkX, chunkZ));
return var3 == null ? loadChunk(chunkX, chunkZ) : var3;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
@Mixin(BlockEntityRenderDispatcher.class)
class MixinTileEntityRenderDispatcher {

@Shadow private Map<Class<? extends BlockEntity>, BlockEntityRenderer> field_1564;
@Shadow private Map<Class<? extends BlockEntity>, BlockEntityRenderer> renderers;

@Redirect(
method = "<init>()V",
at = @At(
value = "FIELD",
target = "Lnet/minecraft/client/render/block/entity/BlockEntityRenderDispatcher;field_1564:Ljava/util/Map;",
target = "Lnet/minecraft/client/render/block/entity/BlockEntityRenderDispatcher;renderers:Ljava/util/Map;",
opcode = Opcodes.PUTFIELD
)
)
private void overrideMap(BlockEntityRenderDispatcher instance, Map<Class<? extends BlockEntity>, BlockEntityRenderer> value) {
field_1564 = new IdentityHashMap<>();
renderers = new IdentityHashMap<>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import net.mine_diver.smoothbeta.client.render.VboPool;
import net.mine_diver.smoothbeta.client.render.gl.VertexBuffer;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.class_42;
import net.minecraft.client.Minecraft;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.block.BlockRenderManager;
import net.minecraft.client.render.chunk.ChunkBuilder;
import net.minecraft.world.WorldRegion;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
Expand Down Expand Up @@ -69,7 +69,7 @@ private void smoothbeta_init(CallbackInfo ci) {
)
private void smoothbeta_startRenderingTerrain(
CallbackInfo ci,
int var1, int var2, int var3, int var4, int var5, int var6, HashSet<BlockEntity> var7, int var8, class_42 var9, BlockRenderManager var10, int var11
int var1, int var2, int var3, int var4, int var5, int var6, HashSet<BlockEntity> var7, int var8, WorldRegion var9, BlockRenderManager var10, int var11
) {
smoothbeta_currentBufferIndex = var11;
((SmoothTessellator) tessellator).smoothbeta_startRenderingTerrain(this);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
package net.mine_diver.smoothbeta.mixin.client.multidraw;

import net.minecraft.class_472;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

import java.nio.IntBuffer;
import net.minecraft.client.render.world.ChunkRenderer;

@Mixin(class_472.class)
@Mixin(ChunkRenderer.class)
public interface RenderListAccessor {
@Accessor("field_2486")
void smoothbeta_setField_2486(IntBuffer buffer);
@Accessor("glListBuffer")
void smoothbeta_setGlListBuffer(IntBuffer buffer);

@Accessor("field_2487")
boolean smoothbeta_getField_2487();
@Accessor("initialized")
boolean smoothbeta_getInitialized();

@Accessor("field_2480")
int smoothbeta_getField_2480();
@Accessor("x")
int smoothbeta_getX();

@Accessor("field_2481")
int smoothbeta_getField_2481();
@Accessor("y")
int smoothbeta_getY();

@Accessor("field_2482")
int smoothbeta_getField_2482();
@Accessor("z")
int smoothbeta_getZ();

@Accessor("field_2483")
float smoothbeta_getField_2483();
@Accessor("offsetX")
float smoothbeta_getOffsetX();

@Accessor("field_2484")
float smoothbeta_getField_2484();
@Accessor("offsetY")
float smoothbeta_getOffsetY();

@Accessor("field_2485")
float smoothbeta_getField_2485();
@Accessor("offsetZ")
float smoothbeta_getOffsetZ();
}
Loading

0 comments on commit 69956c9

Please sign in to comment.