mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-30 16:28:00 +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()
|
||||
.getAllMatches(URecipes.GROWING, new TransformCropsRecipe.PlacementArea(player, pos), player.asWorld())
|
||||
.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 -> {
|
||||
boolean transform = result.shoudTransform(player.asWorld().random);
|
||||
|
|
|
@ -112,10 +112,10 @@ public class Main implements EmiPlugin {
|
|||
registry.addWorkstation(GROWING_CATEGORY, GROWING_STATION);
|
||||
registry.getRecipeManager().listAllOfType(URecipes.GROWING).forEach(recipe -> {
|
||||
registry.addRecipe(new EmiWorldInteractionRecipe(EmiWorldInteractionRecipe.builder()
|
||||
.id(recipe.getId())
|
||||
.leftInput(EmiStack.of(recipe.getTargetAsItem()))
|
||||
.rightInput(EmiStack.of(recipe.getCatalyst(), TransformCropsRecipe.MINIMUM_INPUT), true)
|
||||
.output(EmiStack.of(recipe.getOutput()))) {
|
||||
.id(recipe.id())
|
||||
.leftInput(EmiStack.of(recipe.value().getTargetAsItem()))
|
||||
.rightInput(EmiStack.of(recipe.value().getCatalyst(), TransformCropsRecipe.MINIMUM_INPUT), true)
|
||||
.output(EmiStack.of(recipe.value().getOutput()))) {
|
||||
@Override
|
||||
public EmiRecipeCategory getCategory() {
|
||||
return GROWING_CATEGORY;
|
||||
|
|
|
@ -3,12 +3,9 @@ package com.minelittlepony.unicopia.item;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.minelittlepony.unicopia.block.state.StateUtil;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -22,7 +19,6 @@ import net.minecraft.recipe.RecipeSerializer;
|
|||
import net.minecraft.recipe.RecipeType;
|
||||
import net.minecraft.registry.DynamicRegistryManager;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
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 MINIMUM_INPUT = 9;
|
||||
|
||||
private final Identifier id;
|
||||
|
||||
private final Block target;
|
||||
private final BlockState catalyst;
|
||||
private final BlockState output;
|
||||
|
||||
public TransformCropsRecipe(Identifier id, Block target, BlockState catalyst, BlockState output) {
|
||||
this.id = id;
|
||||
public TransformCropsRecipe(Block target, BlockState catalyst, BlockState output) {
|
||||
this.output = output;
|
||||
this.target = target;
|
||||
this.catalyst = catalyst;
|
||||
|
@ -60,11 +53,6 @@ public class TransformCropsRecipe implements Recipe<TransformCropsRecipe.Placeme
|
|||
return output.getBlock().getPickStack(EmptyBlockView.INSTANCE, BlockPos.ORIGIN, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return URecipes.TRANSFORM_CROP_SERIALIZER;
|
||||
|
@ -82,11 +70,11 @@ public class TransformCropsRecipe implements Recipe<TransformCropsRecipe.Placeme
|
|||
|
||||
@Override
|
||||
public ItemStack craft(PlacementArea inventory, DynamicRegistryManager manager) {
|
||||
return getOutput(manager);
|
||||
return getResult(manager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOutput(DynamicRegistryManager manager) {
|
||||
public ItemStack getResult(DynamicRegistryManager manager) {
|
||||
return output.getBlock().asItem().getDefaultStack();
|
||||
}
|
||||
|
||||
|
@ -115,22 +103,20 @@ public class TransformCropsRecipe implements Recipe<TransformCropsRecipe.Placeme
|
|||
}
|
||||
|
||||
public static class Serializer implements RecipeSerializer<TransformCropsRecipe> {
|
||||
record Intermediate(Block target, BlockState fuel, BlockState output) {}
|
||||
private static final Codec<Intermediate> CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
||||
Registries.BLOCK.getCodec().fieldOf("target").forGetter(Intermediate::target),
|
||||
BlockState.CODEC.fieldOf("consume").forGetter(Intermediate::fuel),
|
||||
BlockState.CODEC.fieldOf("output").forGetter(Intermediate::output)
|
||||
).apply(instance, Intermediate::new));
|
||||
private static final Codec<TransformCropsRecipe> CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
||||
Registries.BLOCK.getCodec().fieldOf("target").forGetter(recipe -> recipe.target),
|
||||
BlockState.CODEC.fieldOf("consume").forGetter(recipe -> recipe.catalyst),
|
||||
BlockState.CODEC.fieldOf("output").forGetter(recipe -> recipe.output)
|
||||
).apply(instance, TransformCropsRecipe::new));
|
||||
|
||||
@Override
|
||||
public TransformCropsRecipe read(Identifier id, JsonObject json) {
|
||||
Intermediate content = CODEC.decode(JsonOps.INSTANCE, json).result().map(Pair::getFirst).get();
|
||||
return new TransformCropsRecipe(id, content.target(), content.fuel(), content.output());
|
||||
public Codec<TransformCropsRecipe> codec() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransformCropsRecipe read(Identifier id, PacketByteBuf buffer) {
|
||||
return new TransformCropsRecipe(id,
|
||||
public TransformCropsRecipe read(PacketByteBuf buffer) {
|
||||
return new TransformCropsRecipe(
|
||||
buffer.readRegistryValue(Registries.BLOCK),
|
||||
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.sollace.fabwork.api.packets.Packet;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
|
||||
public record MsgZapAppleStage (
|
||||
ZapAppleStageStore.Stage stage,
|
||||
long delta
|
||||
) implements Packet<PlayerEntity> {
|
||||
) implements Packet {
|
||||
|
||||
public MsgZapAppleStage(PacketByteBuf buffer) {
|
||||
this(buffer.readEnumConstant(ZapAppleStageStore.Stage.class), buffer.readLong());
|
||||
|
|
Loading…
Reference in a new issue