mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-25 14:14:32 +01:00
1.20.1 -> 1.20.2 (merge fixes)
This commit is contained in:
parent
ad1784b417
commit
eb4c70de2f
4 changed files with 18 additions and 33 deletions
|
@ -138,7 +138,7 @@ public class EarthPonyGrowAbility implements Ability<Pos> {
|
||||||
return player.asWorld().getRecipeManager()
|
return player.asWorld().getRecipeManager()
|
||||||
.getAllMatches(URecipes.GROWING, new TransformCropsRecipe.PlacementArea(player, pos), player.asWorld())
|
.getAllMatches(URecipes.GROWING, new TransformCropsRecipe.PlacementArea(player, pos), player.asWorld())
|
||||||
.stream()
|
.stream()
|
||||||
.map(recipe -> recipe.checkPattern(player.asWorld(), pos))
|
.map(recipe -> recipe.value().checkPattern(player.asWorld(), pos))
|
||||||
.filter(result -> result.matchedLocations().size() + 1 >= TransformCropsRecipe.MINIMUM_INPUT)
|
.filter(result -> result.matchedLocations().size() + 1 >= TransformCropsRecipe.MINIMUM_INPUT)
|
||||||
.filter(result -> {
|
.filter(result -> {
|
||||||
boolean transform = result.shoudTransform(player.asWorld().random);
|
boolean transform = result.shoudTransform(player.asWorld().random);
|
||||||
|
|
|
@ -112,10 +112,10 @@ public class Main implements EmiPlugin {
|
||||||
registry.addWorkstation(GROWING_CATEGORY, GROWING_STATION);
|
registry.addWorkstation(GROWING_CATEGORY, GROWING_STATION);
|
||||||
registry.getRecipeManager().listAllOfType(URecipes.GROWING).forEach(recipe -> {
|
registry.getRecipeManager().listAllOfType(URecipes.GROWING).forEach(recipe -> {
|
||||||
registry.addRecipe(new EmiWorldInteractionRecipe(EmiWorldInteractionRecipe.builder()
|
registry.addRecipe(new EmiWorldInteractionRecipe(EmiWorldInteractionRecipe.builder()
|
||||||
.id(recipe.getId())
|
.id(recipe.id())
|
||||||
.leftInput(EmiStack.of(recipe.getTargetAsItem()))
|
.leftInput(EmiStack.of(recipe.value().getTargetAsItem()))
|
||||||
.rightInput(EmiStack.of(recipe.getCatalyst(), TransformCropsRecipe.MINIMUM_INPUT), true)
|
.rightInput(EmiStack.of(recipe.value().getCatalyst(), TransformCropsRecipe.MINIMUM_INPUT), true)
|
||||||
.output(EmiStack.of(recipe.getOutput()))) {
|
.output(EmiStack.of(recipe.value().getOutput()))) {
|
||||||
@Override
|
@Override
|
||||||
public EmiRecipeCategory getCategory() {
|
public EmiRecipeCategory getCategory() {
|
||||||
return GROWING_CATEGORY;
|
return GROWING_CATEGORY;
|
||||||
|
|
|
@ -3,12 +3,9 @@ package com.minelittlepony.unicopia.item;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.minelittlepony.unicopia.block.state.StateUtil;
|
import com.minelittlepony.unicopia.block.state.StateUtil;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
import com.mojang.datafixers.util.Pair;
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import com.mojang.serialization.JsonOps;
|
|
||||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -22,7 +19,6 @@ import net.minecraft.recipe.RecipeSerializer;
|
||||||
import net.minecraft.recipe.RecipeType;
|
import net.minecraft.recipe.RecipeType;
|
||||||
import net.minecraft.registry.DynamicRegistryManager;
|
import net.minecraft.registry.DynamicRegistryManager;
|
||||||
import net.minecraft.registry.Registries;
|
import net.minecraft.registry.Registries;
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.math.random.Random;
|
import net.minecraft.util.math.random.Random;
|
||||||
|
@ -35,14 +31,11 @@ public class TransformCropsRecipe implements Recipe<TransformCropsRecipe.Placeme
|
||||||
public static final int AREA = (SIDE_LENGTH * SIDE_LENGTH) - 1;
|
public static final int AREA = (SIDE_LENGTH * SIDE_LENGTH) - 1;
|
||||||
public static final int MINIMUM_INPUT = 9;
|
public static final int MINIMUM_INPUT = 9;
|
||||||
|
|
||||||
private final Identifier id;
|
|
||||||
|
|
||||||
private final Block target;
|
private final Block target;
|
||||||
private final BlockState catalyst;
|
private final BlockState catalyst;
|
||||||
private final BlockState output;
|
private final BlockState output;
|
||||||
|
|
||||||
public TransformCropsRecipe(Identifier id, Block target, BlockState catalyst, BlockState output) {
|
public TransformCropsRecipe(Block target, BlockState catalyst, BlockState output) {
|
||||||
this.id = id;
|
|
||||||
this.output = output;
|
this.output = output;
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.catalyst = catalyst;
|
this.catalyst = catalyst;
|
||||||
|
@ -60,11 +53,6 @@ public class TransformCropsRecipe implements Recipe<TransformCropsRecipe.Placeme
|
||||||
return output.getBlock().getPickStack(EmptyBlockView.INSTANCE, BlockPos.ORIGIN, output);
|
return output.getBlock().getPickStack(EmptyBlockView.INSTANCE, BlockPos.ORIGIN, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Identifier getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RecipeSerializer<?> getSerializer() {
|
public RecipeSerializer<?> getSerializer() {
|
||||||
return URecipes.TRANSFORM_CROP_SERIALIZER;
|
return URecipes.TRANSFORM_CROP_SERIALIZER;
|
||||||
|
@ -82,11 +70,11 @@ public class TransformCropsRecipe implements Recipe<TransformCropsRecipe.Placeme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack craft(PlacementArea inventory, DynamicRegistryManager manager) {
|
public ItemStack craft(PlacementArea inventory, DynamicRegistryManager manager) {
|
||||||
return getOutput(manager);
|
return getResult(manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getOutput(DynamicRegistryManager manager) {
|
public ItemStack getResult(DynamicRegistryManager manager) {
|
||||||
return output.getBlock().asItem().getDefaultStack();
|
return output.getBlock().asItem().getDefaultStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,22 +103,20 @@ public class TransformCropsRecipe implements Recipe<TransformCropsRecipe.Placeme
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Serializer implements RecipeSerializer<TransformCropsRecipe> {
|
public static class Serializer implements RecipeSerializer<TransformCropsRecipe> {
|
||||||
record Intermediate(Block target, BlockState fuel, BlockState output) {}
|
private static final Codec<TransformCropsRecipe> CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
||||||
private static final Codec<Intermediate> CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
Registries.BLOCK.getCodec().fieldOf("target").forGetter(recipe -> recipe.target),
|
||||||
Registries.BLOCK.getCodec().fieldOf("target").forGetter(Intermediate::target),
|
BlockState.CODEC.fieldOf("consume").forGetter(recipe -> recipe.catalyst),
|
||||||
BlockState.CODEC.fieldOf("consume").forGetter(Intermediate::fuel),
|
BlockState.CODEC.fieldOf("output").forGetter(recipe -> recipe.output)
|
||||||
BlockState.CODEC.fieldOf("output").forGetter(Intermediate::output)
|
).apply(instance, TransformCropsRecipe::new));
|
||||||
).apply(instance, Intermediate::new));
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TransformCropsRecipe read(Identifier id, JsonObject json) {
|
public Codec<TransformCropsRecipe> codec() {
|
||||||
Intermediate content = CODEC.decode(JsonOps.INSTANCE, json).result().map(Pair::getFirst).get();
|
return CODEC;
|
||||||
return new TransformCropsRecipe(id, content.target(), content.fuel(), content.output());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TransformCropsRecipe read(Identifier id, PacketByteBuf buffer) {
|
public TransformCropsRecipe read(PacketByteBuf buffer) {
|
||||||
return new TransformCropsRecipe(id,
|
return new TransformCropsRecipe(
|
||||||
buffer.readRegistryValue(Registries.BLOCK),
|
buffer.readRegistryValue(Registries.BLOCK),
|
||||||
Block.getStateFromRawId(buffer.readInt()),
|
Block.getStateFromRawId(buffer.readInt()),
|
||||||
Block.getStateFromRawId(buffer.readInt())
|
Block.getStateFromRawId(buffer.readInt())
|
||||||
|
|
|
@ -3,13 +3,12 @@ package com.minelittlepony.unicopia.network;
|
||||||
import com.minelittlepony.unicopia.server.world.ZapAppleStageStore;
|
import com.minelittlepony.unicopia.server.world.ZapAppleStageStore;
|
||||||
import com.sollace.fabwork.api.packets.Packet;
|
import com.sollace.fabwork.api.packets.Packet;
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.network.PacketByteBuf;
|
import net.minecraft.network.PacketByteBuf;
|
||||||
|
|
||||||
public record MsgZapAppleStage (
|
public record MsgZapAppleStage (
|
||||||
ZapAppleStageStore.Stage stage,
|
ZapAppleStageStore.Stage stage,
|
||||||
long delta
|
long delta
|
||||||
) implements Packet<PlayerEntity> {
|
) implements Packet {
|
||||||
|
|
||||||
public MsgZapAppleStage(PacketByteBuf buffer) {
|
public MsgZapAppleStage(PacketByteBuf buffer) {
|
||||||
this(buffer.readEnumConstant(ZapAppleStageStore.Stage.class), buffer.readLong());
|
this(buffer.readEnumConstant(ZapAppleStageStore.Stage.class), buffer.readLong());
|
||||||
|
|
Loading…
Reference in a new issue