-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from BrokenK3yboard/1.21/dev
1.21 port fixes
- Loading branch information
Showing
25 changed files
with
159 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
neoforge=21.0.98-beta | ||
neoforge=21.0.146 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 14 additions & 35 deletions
49
src/main/java/org/violetmoon/zeta/config/FlagLootCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,34 @@ | ||
package org.violetmoon.zeta.config; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import com.google.gson.JsonDeserializationContext; | ||
import com.google.gson.JsonObject; | ||
import com.google.gson.JsonSerializationContext; | ||
|
||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.MapCodec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import net.minecraft.world.level.storage.loot.LootContext; | ||
import net.minecraft.world.level.storage.loot.Serializer; | ||
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; | ||
import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.violetmoon.zeta.mod.ZetaMod; | ||
|
||
import static org.violetmoon.zeta.config.ConfigFlagManager.FLAG_CONDITION_TYPE; | ||
|
||
/** | ||
* @author WireSegal | ||
* Created at 1:23 PM on 8/24/19. | ||
*/ | ||
public record FlagLootCondition(ConfigFlagManager manager, String flag, LootItemConditionType selfType) implements LootItemCondition { | ||
public record FlagLootCondition(String flag) implements LootItemCondition { | ||
|
||
public static MapCodec<FlagLootCondition> CODEC = RecordCodecBuilder.mapCodec( | ||
inst -> inst.group(Codec.STRING.fieldOf("flag").forGetter(FlagLootCondition::flag) | ||
).apply(inst, FlagLootCondition::new)); | ||
|
||
@Override | ||
public boolean test(LootContext lootContext) { | ||
return manager.getFlag(flag); | ||
return ZetaMod.ZETA.configManager.getConfigFlagManager().getFlag(flag); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public LootItemConditionType getType() { | ||
return selfType; | ||
return FLAG_CONDITION_TYPE; | ||
} | ||
|
||
public static final class FlagSerializer implements Serializer<FlagLootCondition> { | ||
private final ConfigFlagManager manager; | ||
public final LootItemConditionType selfType; | ||
|
||
public FlagSerializer(ConfigFlagManager manager) { | ||
this.manager = manager; | ||
|
||
//The LootItemCondition stuff has a circular dependency :/ | ||
this.selfType = new LootItemConditionType(this); | ||
} | ||
|
||
@Override | ||
public void serialize(@NotNull JsonObject json, @NotNull FlagLootCondition value, @NotNull JsonSerializationContext context) { | ||
json.addProperty("flag", value.flag); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public FlagLootCondition deserialize(@NotNull JsonObject json, @NotNull JsonDeserializationContext context) { | ||
String flag = json.getAsJsonPrimitive("flag").getAsString(); | ||
return new FlagLootCondition(manager, flag, selfType); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/org/violetmoon/zeta/mixin/mixins/InvokerSpawnPlacements.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.violetmoon.zeta.mixin.mixins; | ||
|
||
import net.minecraft.world.entity.EntityType; | ||
import net.minecraft.world.entity.Mob; | ||
import net.minecraft.world.entity.SpawnPlacementType; | ||
import net.minecraft.world.entity.SpawnPlacements; | ||
import net.minecraft.world.level.levelgen.Heightmap; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Invoker; | ||
|
||
@Mixin(SpawnPlacements.class) | ||
public interface InvokerSpawnPlacements { | ||
|
||
@Invoker("register") | ||
static <T extends Mob> void zeta$register(EntityType<T> entity, SpawnPlacementType type, Heightmap.Types heightMap, SpawnPlacements.SpawnPredicate<T> predicate) { | ||
throw new RuntimeException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.