Skip to content

Commit

Permalink
[2.0.0] Update dependencies, fix graves not being removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Mar 29, 2022
1 parent 7796a95 commit 1d5e687
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 23 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"


modImplementation include("eu.pb4:sgui:1.0.0+1.18.1")
modImplementation include("eu.pb4:sgui:1.0.1+1.18.2")
modImplementation include("eu.pb4:hologram-api:0.2.1+1.18-pre5")
modImplementation include("eu.pb4:placeholder-api:1.1.3+1.17.1")
modImplementation include("eu.pb4:polymer:0.2.0-beta.27+1.18.2-rc1")
modImplementation include("eu.pb4:polymer:0.2.0-beta.36+1.18.2")
modImplementation include("fr.catcore:server-translations-api:1.4.9+1.18.2-rc1")
//modImplementation include("fr.catcore:server-translations-api:1.4.8+1.18-pre1")
modImplementation include("me.lucko:fabric-permissions-api:0.1-SNAPSHOT")
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.18.2
yarn_mappings=1.18.2+build.1
yarn_mappings=1.18.2+build.2
loader_version=0.13.3

#Fabric api
fabric_version=0.47.8+1.18.2
fabric_version=0.48.0+1.18.2
# Mod Properties
mod_version = 2.0.0-rc.5+1.18.2
mod_version = 2.0.0+1.18.2
maven_group = eu.pb4
archives_base_name = graves

Expand Down
26 changes: 14 additions & 12 deletions src/main/java/eu/pb4/graves/grave/Grave.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
import eu.pb4.graves.config.Config;
import eu.pb4.graves.config.ConfigManager;
import eu.pb4.graves.other.*;
import eu.pb4.graves.registry.SafeXPEntity;
import eu.pb4.graves.registry.GraveBlockEntity;
import eu.pb4.graves.ui.GraveGui;
import eu.pb4.placeholders.PlaceholderAPI;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.entity.ExperienceOrbEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -357,8 +356,19 @@ public void destroyGrave(MinecraftServer server, @Nullable PlayerEntity breaker)
}
}

if (config.configData.dropItemsAfterExpiring || !shouldBreak) {
this.dropContent(server);
var world = server.getWorld(RegistryKey.of(Registry.WORLD_KEY, this.getLocation().world()));

if (world != null) {
var chunk = world.getChunk(ChunkSectionPos.getSectionCoord(this.location.x()), ChunkSectionPos.getSectionCoord(this.location.z()));

if (config.configData.dropItemsAfterExpiring || !shouldBreak) {
ItemScatterer.spawn(world, this.location.blockPos(), this.asInventory());
GraveUtils.spawnExp(world, Vec3d.ofCenter(this.location.blockPos()), this.xp);
}

if (chunk.getBlockEntity(this.location.blockPos()) instanceof GraveBlockEntity grave) {
grave.breakBlock();
}
}
}

Expand Down Expand Up @@ -426,14 +436,6 @@ public void quickEquip(ServerPlayerEntity player) {
}
}

public void dropContent(MinecraftServer server) {
var world = server.getWorld(RegistryKey.of(Registry.WORLD_KEY, this.getLocation().world()));
var chunk = world.getChunk(ChunkSectionPos.getSectionCoord(this.location.x()), ChunkSectionPos.getSectionCoord(this.location.z()));

ItemScatterer.spawn(world, this.location.blockPos(), this.asInventory());
GraveUtils.spawnExp(world, Vec3d.ofCenter(this.location.blockPos()), this.xp);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/eu/pb4/graves/mixin/ServerWorldMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@

import java.util.function.Supplier;

@Mixin(ServerWorld.class)
@Mixin(value = ServerWorld.class, priority = 1005)
public abstract class ServerWorldMixin extends World {
protected ServerWorldMixin(MutableWorldProperties properties, RegistryKey<World> registryRef, RegistryEntry<DimensionType> registryEntry, Supplier<Profiler> profiler, boolean isClient, boolean debugWorld, long seed) {
super(properties, registryRef, registryEntry, profiler, isClient, debugWorld, seed);
}

@Inject(method = "canPlayerModifyAt", at = @At("HEAD"), cancellable = true)
private void grave_disallowGraveBreaking(PlayerEntity player, BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
if (this.getBlockEntity(pos) instanceof GraveBlockEntity grave) {
cir.setReturnValue(grave.getGrave() != null && grave.getGrave().canTakeFrom(player));
if (this.getBlockEntity(pos) instanceof GraveBlockEntity grave && grave.getGrave() != null) {
cir.setReturnValue(grave.getGrave().canTakeFrom(player));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/eu/pb4/graves/registry/GraveBlockEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public boolean canAddPlayer(ServerPlayerEntity player) {
}
}

protected void breakBlock() {
public void breakBlock() {
if (ConfigManager.getConfig().configData.keepBlockAfterBreaking) {
world.setBlockState(pos, VisualGraveBlock.INSTANCE.getStateWithProperties(this.getCachedState()), Block.NOTIFY_ALL | Block.FORCE_STATE);

Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
"universal-graves.mixins.json"
],
"depends": {
"fabricloader": ">=0.12.0",
"fabricloader": ">=0.13.0",
"fabric": "*",
"minecraft": ">=1.18.2-rc.1",
"minecraft": ">=1.18.2",
"java": ">=17"
}
}

0 comments on commit 1d5e687

Please sign in to comment.