Skip to content

Commit

Permalink
Update to 1.18
Browse files Browse the repository at this point in the history
  • Loading branch information
DaFuqs committed Nov 30, 2021
1 parent 53c300a commit 120de45
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 57 deletions.
11 changes: 5 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id 'fabric-loom' version '0.8-SNAPSHOT'
id 'fabric-loom' version '0.10-SNAPSHOT'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = project.archives_base_name
version = project.mod_version
Expand All @@ -27,10 +27,9 @@ dependencies {
modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
}

modApi("com.terraformersmc:modmenu:${project.modmenu_version}")

modImplementation('net.kyrptonaught:quickshulker:1.2.2-1.17')
//modImplementation('net.kyrptonaught:quickshulker:1.2.2-1.17')
}

processResources {
Expand All @@ -46,7 +45,7 @@ processResources {
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
it.options.release = 16
it.options.release = 17
}

// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
org.gradle.jvmargs=-Xmx2G

# Fabric Properties
minecraft_version=1.17.1
yarn_mappings=1.17.1+build.64
loader_version=0.12.5
minecraft_version=1.18
yarn_mappings=1.18+build.1
loader_version=0.12.6

# Mod Properties
mod_version=2.3.0
mod_version=2.4.0-1.18.0
maven_group=de.dafuqs.lootcrates
archives_base_name=ModularLootcrates

# Dependencies
fabric_version=0.42.1+1.17
fabric_version=0.43.1+1.18
cloth_config_version=5.0.34
modmenu_version=2.0.2
6 changes: 5 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7 changes: 3 additions & 4 deletions src/main/java/de/dafuqs/lootcrates/LootCrateDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.MapColor;
import net.minecraft.block.Material;
import net.minecraft.client.util.SpriteIdentifier;
Expand Down Expand Up @@ -91,7 +90,7 @@ public FabricItemSettings getBlockItemSettings() {
}

public FabricBlockSettings getChestBlockSettings() {
FabricBlockSettings blockSettings = FabricBlockSettings.of(Material.METAL, mapColor).luminance(luminance).breakByTool(FabricToolTags.PICKAXES);
FabricBlockSettings blockSettings = FabricBlockSettings.of(Material.METAL, mapColor).luminance(luminance);

if(LootCrates.CONFIG.ChestCrateHardness < 0) {
blockSettings = blockSettings.strength(-1.0F, 3600000.0F).dropsNothing();
Expand All @@ -110,7 +109,7 @@ public FabricBlockSettings getChestBlockSettings() {
}

public FabricBlockSettings getShulkerBlockSettings() {
FabricBlockSettings blockSettings = FabricBlockSettings.of(Material.SHULKER_BOX, mapColor).luminance(luminance).breakByTool(FabricToolTags.PICKAXES);
FabricBlockSettings blockSettings = FabricBlockSettings.of(Material.SHULKER_BOX, mapColor).luminance(luminance);

if(LootCrates.CONFIG.ShulkerCrateHardness < 0) {
blockSettings = blockSettings.strength(-1.0F, 3600000.0F).dropsNothing();
Expand All @@ -126,7 +125,7 @@ public FabricBlockSettings getShulkerBlockSettings() {
}

public FabricBlockSettings getLootBarrelBlockSettings() {
FabricBlockSettings blockSettings = FabricBlockSettings.of(Material.WOOD, mapColor).luminance(luminance).breakByTool(FabricToolTags.PICKAXES);
FabricBlockSettings blockSettings = FabricBlockSettings.of(Material.WOOD, mapColor).luminance(luminance);

if(LootCrates.CONFIG.LootBarrelHardness < 0) {
blockSettings = blockSettings.strength(-1.0F, 3600000.0F).dropsNothing();
Expand Down
26 changes: 14 additions & 12 deletions src/main/java/de/dafuqs/lootcrates/LootCrates.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import net.minecraft.util.math.Position;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.registry.Registry;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand All @@ -38,7 +39,7 @@
public class LootCrates implements ModInitializer {

public static final String MOD_ID = "lootcrates";
public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
private static final Logger LOGGER = LogManager.getLogger(MOD_ID);
public static LootCratesConfig CONFIG;

public static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.build(
Expand Down Expand Up @@ -86,12 +87,12 @@ public class LootCrates implements ModInitializer {
public void onInitialize() {

// Config
LOGGER.info("[LootCrates] Loading config...");
log(Level.INFO, "Loading config...");
AutoConfig.register(LootCratesConfig.class, JanksonConfigSerializer::new);
CONFIG = AutoConfig.getConfigHolder(LootCratesConfig.class).getConfig();

// All the different types of crates
LOGGER.info("[LootCrates] Loading crate definitions...");
log(Level.INFO, "Loading crate definitions...");
LootCrateDefinition commonLootCrate = new LootCrateDefinition(LootCrateRarity.COMMON, Rarity.COMMON, MapColor.DIRT_BROWN, 0, false, false);
LootCrateDefinition uncommonLootCrate = new LootCrateDefinition(LootCrateRarity.UNCOMMON, Rarity.UNCOMMON, MapColor.YELLOW, 0, false, false);
LootCrateDefinition rareLootCrate = new LootCrateDefinition(LootCrateRarity.RARE, Rarity.RARE, MapColor.BLUE, 0, false, false);
Expand All @@ -113,22 +114,23 @@ public void onInitialize() {

// The block entity type
LootCratesBlockEntityType.register();

LOGGER.info("[LootCrates] Registering sounds...");
log(Level.INFO, "Registering sounds...");
Registry.register(Registry.SOUND_EVENT, CHEST_UNLOCKS_SOUND_ID, CHEST_UNLOCKS_SOUND_EVENT);

LOGGER.info("[LootCrates] Loading LootCratesWorldgenSettings.json...");


log(Level.INFO, "Loading LootCratesWorldgenSettings.json and registering the replacer");
LootCratesWorldgenReplacer.initialize();

LOGGER.info("[LootCrates] Finished LootCratesWorldgenSettings.json...");

if(CONFIG.ReplaceVanillaWorldgenChests) {
ServerTickEvents.END_SERVER_TICK.register(server -> {
LootCratesWorldgenReplacer.tick(server);
});
}

LOGGER.info("[LootCrates] Finished!");
log(Level.INFO, "Finished!");
}

public static void log(Level logLevel, String message) {
LOGGER.log(logLevel, "[LootCrates] " + message);
}

}
4 changes: 2 additions & 2 deletions src/main/java/de/dafuqs/lootcrates/blocks/LootCrateBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable Livi

@Override
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
world.getBlockTickScheduler().schedule(pos, this, getRandomTickTime(world.random));
world.createAndScheduleBlockTick(pos, this, getRandomTickTime(world.random));

BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof LootCrateBlockEntity) {
Expand Down Expand Up @@ -175,7 +175,7 @@ public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState
ScheduledTickEvent scheduledTickEvent = ((LootCrateBlockEntity) blockEntity).getRandomTickEvent();

if(scheduledTickEvent != ScheduledTickEvent.NONE) {
world.getBlockTickScheduler().schedule(pos, this, getRandomTickTime(world.random));
world.createAndScheduleBlockTick(pos, this, getRandomTickTime(world.random));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,11 @@ protected LootCrateBlockEntity(BlockEntityType<?> blockEntityType, BlockPos bloc
}

@Override
public NbtCompound writeNbt(NbtCompound tag) {
public void writeNbt(NbtCompound tag) {
super.writeNbt(tag);

Inventories.writeNbt(tag, this.inventory, false);
tag = addLootCrateBlockTags(tag);

return tag;
addLootCrateBlockTags(tag);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private static boolean canOpen(BlockState state, World world, BlockPos pos, Shul
if (entity.getAnimationStage() != ShulkerBoxBlockEntity.AnimationStage.CLOSED) {
return true;
} else {
Box box = ShulkerEntity.method_33347(state.get(FACING), 0.0F, 0.5F).offset(pos).contract(1.0E-6D);
Box box = ShulkerEntity.calculateBoundingBox(state.get(FACING), 0.0F, 0.5F).offset(pos).contract(1.0E-6D);
return world.isSpaceEmpty(box);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void updateAnimation(World world, BlockPos pos, BlockState state) {
private void pushEntities(World world, BlockPos pos, BlockState state) {
if (state.getBlock() instanceof ShulkerLootCrateBlock) {
Direction direction = state.get(ShulkerBoxBlock.FACING);
Box box = ShulkerEntity.method_33347(direction, this.prevAnimationProgress, this.animationProgress).offset(pos);
Box box = ShulkerEntity.calculateBoundingBox(direction, this.prevAnimationProgress, this.animationProgress).offset(pos);
List<Entity> list = world.getOtherEntities(null, box);
if (!list.isEmpty()) {
for (Entity entity : list) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.dafuqs.lootcrates.compat;
/*package de.dafuqs.lootcrates.compat;
import de.dafuqs.lootcrates.LootCrateAtlas;
import de.dafuqs.lootcrates.LootCrates;
Expand Down Expand Up @@ -237,4 +237,4 @@ public void saveNbtToStack(ItemStack stack, long lastReplenishTimeTick, boolean
}
}
}
}
}*/
4 changes: 2 additions & 2 deletions src/main/java/de/dafuqs/lootcrates/items/LootBagItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand han
public List<ItemStack> getLootTableContents(ServerPlayerEntity player, ItemStack lootBagItemStack) {
Identifier lootTableId = getLootTableIdentifier(lootBagItemStack);
if(lootTableId != null) {
LootTable lootTable = player.getServerWorld().getServer().getLootManager().getTable(lootTableId);
LootTable lootTable = player.getWorld().getServer().getLootManager().getTable(lootTableId);
if(lootTable != null) {
LootContext.Builder builder = (new LootContext.Builder(player.getServerWorld()).parameter(LootContextParameters.ORIGIN, player.getPos())).random(getLootTableSeed(lootBagItemStack));
LootContext.Builder builder = (new LootContext.Builder(player.getWorld()).parameter(LootContextParameters.ORIGIN, player.getPos())).random(getLootTableSeed(lootBagItemStack));
builder.luck(player.getLuck()).parameter(LootContextParameters.THIS_ENTITY, player);
return lootTable.generateLoot(builder.build(LootContextTypes.CHEST));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package de.dafuqs.lootcrates.mixin;

import net.minecraft.world.HeightLimitView;
import net.minecraft.world.chunk.ProtoChunk;
import net.minecraft.world.chunk.Chunk;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(ProtoChunk.class)
public interface ProtoChunkAccessor {
@Mixin(Chunk.class)
public interface ChunkAccessor {

@Accessor("world")
@Accessor("heightLimitView")
HeightLimitView getWorld();

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import net.minecraft.world.HeightLimitView;
import net.minecraft.world.World;
import net.minecraft.world.chunk.ProtoChunk;
import org.apache.logging.log4j.core.jmx.Server;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -32,7 +31,7 @@ private static void noteChestForLootCrateConversion(BlockView world, Random rand
if(LootCrates.CONFIG.ReplaceVanillaWorldgenChests) {
RegistryKey<World> worldRegistryKey;
if(world instanceof ProtoChunk protoChunk) {
ProtoChunkAccessor protoChunkAccessor = ((ProtoChunkAccessor) protoChunk);
ChunkAccessor protoChunkAccessor = ((ChunkAccessor) protoChunk);
HeightLimitView heightLimitView = protoChunkAccessor.getWorld();
if(heightLimitView instanceof ChunkRegion chunkRegion) {
worldRegistryKey = chunkRegion.toServerWorld().getRegistryKey();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package de.dafuqs.lootcrates.worldgen;

import blue.endless.jankson.annotation.Nullable;
import de.dafuqs.lootcrates.enums.LootCrateRarity;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;

public class LootCrateReplacementEntry {

Expand All @@ -23,4 +23,5 @@ public LootCrateReplacementEntry(@Nullable LootCrateRarity lootCrateRarity, @Nul
this.lockType = lockType;
this.weight = weight;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public static void initialize() {

configReader = new FileReader(configFile);
} catch (IOException ioException) {
LootCrates.LOGGER.log(Level.ERROR, "[LootCrates] Could not generate config file under " + configFile.getAbsolutePath() + ".\n" + ioException.getLocalizedMessage());
LootCrates.log(Level.ERROR, "Could not generate config file under " + configFile.getAbsolutePath() + ".\n" + ioException.getLocalizedMessage());
return;
}
}
Expand All @@ -212,7 +212,7 @@ public static void initialize() {
try {
jsonElement = (JsonElement) JsonHelper.deserialize(GSON, configReader, (Class) JsonElement.class);
} catch (Exception e) {
LootCrates.LOGGER.error("[LootCrates] Could not parse the LootCratesWorldgenSettings.json5: " + e.getLocalizedMessage());
LootCrates.log(Level.ERROR, "Could not parse the LootCratesWorldgenSettings.json5: " + e.getLocalizedMessage());
return;
}

Expand Down Expand Up @@ -291,7 +291,7 @@ public static void tick(MinecraftServer server) {
try {
blockEntity = serverWorld.getBlockEntity(replacementPosition.blockPos);
} catch (Exception e) {
LootCrates.LOGGER.error("[LootCrates] Error while replacing a container with loot table '" + replacementPosition.lootTable + "' in the world '" + replacementPosition.worldKey + "' at '" + replacementPosition.blockPos + "' ) + " + e.getLocalizedMessage());
LootCrates.log(Level.ERROR, "Error while replacing a container with loot table '" + replacementPosition.lootTable + "' in the world '" + replacementPosition.worldKey + "' at '" + replacementPosition.blockPos + "' ) + " + e.getLocalizedMessage());
continue;
}
if(blockEntity != null && !(blockEntity instanceof LootCrateBlockEntity)) {
Expand Down Expand Up @@ -344,7 +344,7 @@ public static void tick(MinecraftServer server) {
}
}
} catch (Exception e) {
LootCrates.LOGGER.error("[LootCrates] Error while replacing a container with loot table '" + replacementPosition.lootTable + "' in the world '" + replacementPosition.worldKey + "' at '" + replacementPosition.blockPos + "') + " + e.getLocalizedMessage());
LootCrates.log(Level.ERROR, "Error while replacing a container with loot table '" + replacementPosition.lootTable + "' in the world '" + replacementPosition.worldKey + "' at '" + replacementPosition.blockPos + "') + " + e.getLocalizedMessage());
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"lootcrates.mixins.json"
],
"depends": {
"fabricloader": ">=0.11.3",
"minecraft": ">=1.17.0",
"fabric": ">=0.36.0",
"minecraft": ">=1.18.0",
"fabricloader": ">=0.12.6",
"fabric": "*",
"cloth-config2": ">=5.0.34"
},
"suggests": {
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/lootcrates.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"required": true,
"minVersion": "0.8",
"package": "de.dafuqs.lootcrates.mixin",
"compatibilityLevel": "JAVA_16",
"compatibilityLevel": "JAVA_17",
"mixins": [
"BlockEntityMixin",
"ChunkAccessor",
"LootableContainerBlockEntityMixin",
"LootTableAccessor",
"ProtoChunkAccessor"
"LootTableAccessor"
],
"client": [
],
Expand Down

0 comments on commit 120de45

Please sign in to comment.