Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/1.21.4 #23

Merged
merged 6 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.8-SNAPSHOT'
id 'fabric-loom' version '1.9-SNAPSHOT'
id 'maven-publish'
}

Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21
yarn_mappings=1.21+build.9
loader_version=0.16.2
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.1
loader_version=0.16.9

# Fabric API
fabric_version=0.102.0+1.21
fabric_version=0.111.0+1.21.4

# Mod Properties
mod_version=2.0.1-1.21+
mod_version=2.0.2-1.21.4+
maven_group=xd.arkosammy
archives_base_name=creeperhealing

# Monkey Config
monkey_config_version=0.1.2+1.21

# Creeper Overhaul
creeper_overhaul_version=pv1EuPwm
creeper_overhaul_version=LvGcZBEq

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.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.registry.RegistryKey;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
Expand All @@ -21,7 +22,7 @@ public interface AffectedBlock {

RegistryKey<World> getWorldRegistryKey();

World getWorld(MinecraftServer server);
ServerWorld getWorld(MinecraftServer server);

long getBlockTimer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryKey;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
Expand Down Expand Up @@ -56,7 +57,7 @@ public RegistryKey<World> getWorldRegistryKey() {
}

@Override
public World getWorld(@NotNull MinecraftServer server) {
public ServerWorld getWorld(@NotNull MinecraftServer server) {
return server.getWorld(this.getWorldRegistryKey());
}

Expand Down Expand Up @@ -92,7 +93,6 @@ public void tick(ExplosionEvent explosionEvent, MinecraftServer server) {
return;
}
this.tryHealing(server, explosionEvent);
this.setPlaced();
}

@Override
Expand All @@ -109,6 +109,7 @@ protected String getAffectedBlockType() {

protected void tryHealing(MinecraftServer server, ExplosionEvent currentExplosionEvent) {

this.setPlaced();
BlockState state = this.getBlockState();
BlockPos pos = this.getBlockPos();
World world = this.getWorld(server);
Expand Down Expand Up @@ -198,7 +199,6 @@ private void handleChestBlockIfNeeded(ExplosionEvent explosionEvent, BlockState
continue;
}
singleAffectedBlock.tryHealing(server, explosionEvent);
singleAffectedBlock.setPlaced();
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.block.BlockState;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import xd.arkosammy.creeperhealing.blocks.AffectedBlock;
Expand Down Expand Up @@ -39,7 +40,7 @@ public Stream<AffectedBlock> getAffectedBlocks() {
}

@Override
public World getWorld(MinecraftServer server) {
public ServerWorld getWorld(MinecraftServer server) {
return server.getWorld(this.affectedBlocks.getFirst().getWorldRegistryKey());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package xd.arkosammy.creeperhealing.explosions;

import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.World;
import xd.arkosammy.creeperhealing.blocks.AffectedBlock;
import xd.arkosammy.creeperhealing.blocks.SingleAffectedBlock;
import xd.arkosammy.creeperhealing.config.ConfigUtils;
Expand All @@ -28,7 +28,7 @@ protected ExplosionHealingMode getHealingMode() {

// Change the timers of each affected block based on their blast resistance
@Override
public void setup(World world) {
public void setup(ServerWorld world) {
Random random = world.getRandom();
for (AffectedBlock affectedBlock : this.getAffectedBlocks().toList()) {
if (!(affectedBlock instanceof SingleAffectedBlock singleAffectedBlock)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.SharedConstants;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.GameRules;
import net.minecraft.world.LightType;
Expand All @@ -28,7 +29,7 @@ protected ExplosionHealingMode getHealingMode() {
}

@Override
public void setup(World world) {
public void setup(ServerWorld world) {
if (!world.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package xd.arkosammy.creeperhealing.explosions;

import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import xd.arkosammy.creeperhealing.blocks.AffectedBlock;

import java.util.List;
Expand All @@ -23,7 +23,7 @@ protected ExplosionHealingMode getHealingMode() {


@Override
public void setup(World world) {
public void setup(ServerWorld world) {

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package xd.arkosammy.creeperhealing.explosions;

import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import xd.arkosammy.creeperhealing.blocks.AffectedBlock;
import xd.arkosammy.creeperhealing.blocks.SingleAffectedBlock;
import xd.arkosammy.creeperhealing.config.ConfigUtils;
Expand All @@ -24,7 +24,7 @@ protected ExplosionHealingMode getHealingMode() {
}

@Override
public void setup(World world) {
public void setup(ServerWorld world) {
final int difficultyMultiplier = switch (world.getDifficulty()) {
case PEACEFUL -> -2;
case EASY -> -1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package xd.arkosammy.creeperhealing.explosions;

import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
import net.minecraft.server.world.ServerWorld;
import xd.arkosammy.creeperhealing.blocks.AffectedBlock;

import java.util.stream.Stream;

public interface ExplosionEvent {

void setup(World world);
void setup(ServerWorld world);

Stream<AffectedBlock> getAffectedBlocks();

World getWorld(MinecraftServer server);
ServerWorld getWorld(MinecraftServer server);

long getHealTimer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.jetbrains.annotations.Nullable;

@ApiStatus.Internal
public interface ExplosionDuck {
public interface ExplosionImplDuck {

boolean creeperhealing$shouldHeal();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Pair;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import xd.arkosammy.creeperhealing.blocks.AffectedBlock;
import xd.arkosammy.creeperhealing.blocks.SingleAffectedBlock;
Expand All @@ -18,13 +18,13 @@
public class DefaultExplosionFactory implements ExplosionEventFactory<AbstractExplosionEvent> {

private final Map<BlockPos, Pair<BlockState, BlockEntity>> affectedStatesAndBlockEntities;
private final World world;
private final ServerWorld world;
private final int blastRadius;
private final Set<BlockPos> affectedPositions = new HashSet<>();
private final BlockPos center;
private final List<BlockPos> vanillaAffectedPositions;

public DefaultExplosionFactory(Map<BlockPos, Pair<BlockState, BlockEntity>> affectedStatesAndBlockEntities, List<BlockPos> vanillaAffectedPositions, List<BlockPos> indirectlyExplodedPositions, World world) {
public DefaultExplosionFactory(Map<BlockPos, Pair<BlockState, BlockEntity>> affectedStatesAndBlockEntities, List<BlockPos> vanillaAffectedPositions, List<BlockPos> indirectlyExplodedPositions, ServerWorld world) {
this.affectedStatesAndBlockEntities = affectedStatesAndBlockEntities;
this.world = world;
this.affectedPositions.addAll(vanillaAffectedPositions);
Expand Down Expand Up @@ -53,7 +53,7 @@ public DefaultExplosionFactory(Map<BlockPos, Pair<BlockState, BlockEntity>> affe
}

@Override
public @Nullable AbstractExplosionEvent createExplosionEvent(List<BlockPos> affectedPositions, World world) {
public @Nullable AbstractExplosionEvent createExplosionEvent(List<BlockPos> affectedPositions, ServerWorld world) {
List<AffectedBlock> affectedBlocks = this.processAffectedPositions(affectedPositions, world);
if (affectedBlocks == null || affectedBlocks.isEmpty()) {
return null;
Expand Down Expand Up @@ -111,12 +111,12 @@ public List<BlockPos> getAffectedPositions() {
}

@Override
public World getWorld() {
public ServerWorld getWorld() {
return this.world;
}

@Nullable
private List<AffectedBlock> processAffectedPositions(List<BlockPos> affectedPositions, World world) {
private List<AffectedBlock> processAffectedPositions(List<BlockPos> affectedPositions, ServerWorld world) {
List<BlockPos> positionsToHeal = ExplosionUtils.filterPositionsToHeal(affectedPositions, (pos) -> this.affectedStatesAndBlockEntities.get(pos).getLeft());
if (positionsToHeal.isEmpty()) {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package xd.arkosammy.creeperhealing.explosions.factories;

import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import xd.arkosammy.creeperhealing.blocks.AffectedBlock;
import xd.arkosammy.creeperhealing.explosions.ExplosionEvent;
Expand All @@ -13,13 +13,13 @@ public interface ExplosionEventFactory<T extends ExplosionEvent> {
@Nullable
List<BlockPos> getAffectedPositions();

World getWorld();
ServerWorld getWorld();

@Nullable
T createExplosionEvent();

@Nullable
T createExplosionEvent(List<BlockPos> affectedPositions, World world);
T createExplosionEvent(List<BlockPos> affectedPositions, ServerWorld world);

@Nullable
T createExplosionEvent(List<AffectedBlock> affectedBlocks, long healTimer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.spongepowered.asm.mixin.injection.At;
import xd.arkosammy.creeperhealing.config.ConfigSettings;
import xd.arkosammy.creeperhealing.config.ConfigUtils;
import xd.arkosammy.creeperhealing.explosions.ducks.ExplosionDuck;
import xd.arkosammy.creeperhealing.explosions.ducks.ExplosionImplDuck;
import xd.arkosammy.creeperhealing.util.ExcludedBlocks;
import xd.arkosammy.creeperhealing.util.ExplosionUtils;
import xd.arkosammy.monkeyconfig.settings.BooleanSetting;
Expand All @@ -38,13 +38,13 @@ private boolean shouldExplosionDropItems(boolean original, Explosion explosion)
}

// Allow the explosion to drop items normally if it cannot be healed
if (!((ExplosionDuck) explosion).creeperhealing$shouldHeal()) {
if (!((ExplosionImplDuck) explosion).creeperhealing$shouldHeal()) {
ExplosionUtils.DROP_BLOCK_ITEMS.set(original);
ExplosionUtils.DROP_CONTAINER_INVENTORY_ITEMS.set(original);
return original;
}

World.ExplosionSourceType explosionSourceType = ((ExplosionDuck) explosion).creeperhealing$getExplosionSourceType();
World.ExplosionSourceType explosionSourceType = ((ExplosionImplDuck) explosion).creeperhealing$getExplosionSourceType();
boolean shouldDropItems = switch (explosionSourceType) {
case MOB -> {
if (!ConfigUtils.getSettingValue(ConfigSettings.DROP_ITEMS_ON_MOB_EXPLOSIONS.getSettingLocation(), BooleanSetting.class)) {
Expand Down
Loading