Skip to content

Commit

Permalink
- Updates to 1.17
Browse files Browse the repository at this point in the history
- Fixes #24
- Fixes #22
- Fixes #16
  • Loading branch information
Haven-King committed Jun 14, 2021
1 parent f0508b6 commit 39080ed
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 40 deletions.
14 changes: 6 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ repositories {
maven {
url "https://hephaestus.dev/release"
}
maven {
url "https://maven.terraformersmc.com/releases"
}
mavenLocal()
}

Expand All @@ -24,11 +27,11 @@ minecraft {
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modCompile "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modImplementation ("io.github.prospector:modmenu:${project.mod_menu_version}") {
modImplementation ("com.terraformersmc:modmenu:${project.mod_menu_version}") {
exclude group: "net.fabricmc.fabric-api"
}

Expand All @@ -42,14 +45,9 @@ dependencies {
processResources {
inputs.property "version", project.version

from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"
filesMatching("fabric.mod.json") {
expand "version": project.version
}

from(sourceSets.main.resources.srcDirs) {
exclude "fabric.mod.json"
}
}

// ensure that the encoding is set to UTF-8, no matter what the system default is
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
minecraft_version = 1.16.5
yarn_mappings = 1.16.5+build.4
loader_version = 0.11.1
minecraft_version = 1.17
yarn_mappings = 1.17+build.10
loader_version = 0.11.5

# Mod Properties
mod_version = 1.1.0
mod_version = 1.2.0+1.17
maven_group = dev.hephaestus
archives_base_name = sax

# Dependencies
fabric_version = 0.30.3+1.16
fiblib_version = 1.0.2
mod_menu_version = 1.14.6+build.31
fabric_version = 0.35.1+1.17
fiblib_version = 1.1.0+1.17
mod_menu_version = 2.0.2
Binary file removed gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 0 additions & 6 deletions gradle/wrapper/gradle-wrapper.properties

This file was deleted.

6 changes: 0 additions & 6 deletions src/main/java/dev/hephaestus/sax/SAX.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@

import com.mojang.brigadier.arguments.BoolArgumentType;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.suggestion.SuggestionProvider;
import dev.hephaestus.fiblib.api.BlockFib;
import dev.hephaestus.fiblib.api.BlockFibRegistry;
import dev.hephaestus.sax.server.Config;
import dev.hephaestus.sax.util.FastCaster;
import dev.hephaestus.sax.util.ObfuscatedWorld;
import dev.hephaestus.sax.util.Profiler;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerEntityEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.minecraft.block.Block;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
Expand All @@ -27,7 +22,6 @@
import org.apache.logging.log4j.Logger;

import java.util.Map;
import java.util.concurrent.CompletableFuture;

public class SAX implements ModInitializer {
public static final String MODID = "sax";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package dev.hephaestus.sax.mixin;

import dev.hephaestus.fiblib.impl.FibLib;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.network.ServerPlayerInteractionManager;
import net.minecraft.world.GameMode;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(ServerPlayerInteractionManager.class)
public class MixinServerPlayerInteractionManager {
@Shadow @Final protected ServerPlayerEntity player;

@Inject(method = "changeGameMode", at = @At("RETURN"))
public void resendChunks(GameMode gameMode, CallbackInfoReturnable<Boolean> cir) {
FibLib.resendChunks(this.player);
}
}
10 changes: 7 additions & 3 deletions src/main/java/dev/hephaestus/sax/mixin/MixinServerWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

@Mixin(ServerWorld.class)
public class MixinServerWorld implements ObfuscatedWorld {
@Shadow @Final private List<ServerPlayerEntity> players;
@Shadow @Final List<ServerPlayerEntity> players;
@Unique private final Map<UUID, DeObfuscator> deObfuscatorMap = new HashMap<>();

@Inject(method = "addPlayer", at = @At("TAIL"))
Expand All @@ -29,8 +29,12 @@ private void addDeobfuscator(ServerPlayerEntity player, CallbackInfo ci) {
}

@Inject(method = "removePlayer", at = @At("TAIL"))
private void removeDeobfuscator(ServerPlayerEntity player, CallbackInfo ci) {
this.deObfuscatorMap.remove(player.getUuid()).remove();
private void removeDeobfuscator(ServerPlayerEntity player, Entity.RemovalReason reason, CallbackInfo ci) {
DeObfuscator deObfuscator = this.deObfuscatorMap.remove(player.getUuid());

if (deObfuscator != null) {
deObfuscator.remove();
}
}

@Inject(method = "tickEntity", at = @At("TAIL"))
Expand Down
27 changes: 19 additions & 8 deletions src/main/java/dev/hephaestus/sax/server/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.lib.gson.JsonReader;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.util.Identifier;
Expand All @@ -16,7 +15,7 @@
import java.io.Writer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

// Simple config for now
Expand All @@ -26,24 +25,36 @@ public class Config {

private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();

public static final HashMap<Block, Block> HIDDEN = new HashMap<>();
public static final Map<Block, Block> HIDDEN = new LinkedHashMap<>();
public static byte CHUNK_RADIUS = 4;
public static boolean LENIENT = false;
public static int TICK_RATE = 10;

static {
HIDDEN.put(Blocks.DIAMOND_ORE, Blocks.STONE);
HIDDEN.put(Blocks.EMERALD_ORE, Blocks.STONE);
HIDDEN.put(Blocks.COAL_ORE, Blocks.STONE);
HIDDEN.put(Blocks.IRON_ORE, Blocks.STONE);
HIDDEN.put(Blocks.COPPER_ORE, Blocks.STONE);
HIDDEN.put(Blocks.GOLD_ORE, Blocks.STONE);
HIDDEN.put(Blocks.COAL_ORE, Blocks.STONE);
HIDDEN.put(Blocks.DIAMOND_ORE, Blocks.STONE);
HIDDEN.put(Blocks.EMERALD_ORE, Blocks.STONE);
HIDDEN.put(Blocks.REDSTONE_ORE, Blocks.STONE);
HIDDEN.put(Blocks.LAPIS_ORE, Blocks.STONE);
HIDDEN.put(Blocks.MOSSY_COBBLESTONE, Blocks.STONE);
HIDDEN.put(Blocks.SPAWNER, Blocks.CAVE_AIR);

HIDDEN.put(Blocks.DEEPSLATE_COAL_ORE, Blocks.DEEPSLATE);
HIDDEN.put(Blocks.DEEPSLATE_IRON_ORE, Blocks.DEEPSLATE);
HIDDEN.put(Blocks.DEEPSLATE_COPPER_ORE, Blocks.DEEPSLATE);
HIDDEN.put(Blocks.DEEPSLATE_GOLD_ORE, Blocks.DEEPSLATE);
HIDDEN.put(Blocks.DEEPSLATE_DIAMOND_ORE, Blocks.DEEPSLATE);
HIDDEN.put(Blocks.DEEPSLATE_EMERALD_ORE, Blocks.DEEPSLATE);
HIDDEN.put(Blocks.DEEPSLATE_REDSTONE_ORE, Blocks.DEEPSLATE);
HIDDEN.put(Blocks.DEEPSLATE_LAPIS_ORE, Blocks.DEEPSLATE);

HIDDEN.put(Blocks.NETHER_GOLD_ORE, Blocks.NETHERRACK);
HIDDEN.put(Blocks.NETHER_QUARTZ_ORE, Blocks.NETHERRACK);
HIDDEN.put(Blocks.ANCIENT_DEBRIS, Blocks.NETHERRACK);

HIDDEN.put(Blocks.MOSSY_COBBLESTONE, Blocks.STONE);
HIDDEN.put(Blocks.SPAWNER, Blocks.CAVE_AIR);
}

public static void load() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/dev/hephaestus/sax/server/DeObfuscator.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public void remove() {
private void action() {
set(this.player.getCameraPosVec(1F), this.startPos);

int chunkX = this.player.chunkX;
int chunkZ = this.player.chunkZ;
int chunkX = this.player.getBlockX() >> 4;
int chunkZ = this.player.getBlockZ() >> 4;

ServerWorld world = this.player.getServerWorld();
this.chunkManager = world.getChunkManager();
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/sax.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"package": "dev.hephaestus.sax.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
"MixinServerPlayerInteractionManager",
"MixinServerWorld",
"MixinWorldChunk",
"VisionAccessor"
Expand Down

0 comments on commit 39080ed

Please sign in to comment.