Fix recipe issues, not grabbing all code properly for the circle colours, and fix #478 (VillagerIngredient's weren't adding their type to the buffer, fixed by moving the type-adding code into BrainsweepeeIngredient.)

This commit is contained in:
Talia-12 2023-06-15 15:26:15 +10:00
parent 4e4d34a315
commit 541a0b365a
7 changed files with 13 additions and 10 deletions

View file

@ -95,7 +95,7 @@ public record BrainsweepRecipe(
@Override
public void toNetwork(FriendlyByteBuf buf, BrainsweepRecipe recipe) {
recipe.blockIn.write(buf);
recipe.entityIn.write(buf);
recipe.entityIn.wrapWrite(buf);
buf.writeVarInt(recipe.mediaCost);
buf.writeVarInt(Block.getId(recipe.result));
}
@ -103,10 +103,10 @@ public record BrainsweepRecipe(
@Override
public @NotNull BrainsweepRecipe fromNetwork(ResourceLocation recipeID, FriendlyByteBuf buf) {
var blockIn = StateIngredientHelper.read(buf);
var villagerIn = BrainsweepeeIngredient.read(buf);
var brainsweepeeIn = BrainsweepeeIngredient.read(buf);
var cost = buf.readVarInt();
var result = Block.stateById(buf.readVarInt());
return new BrainsweepRecipe(recipeID, blockIn, villagerIn, cost, result);
return new BrainsweepRecipe(recipeID, blockIn, brainsweepeeIn, cost, result);
}
}
}

View file

@ -29,6 +29,11 @@ public abstract class BrainsweepeeIngredient {
public abstract JsonObject serialize();
public void wrapWrite(FriendlyByteBuf buf) {
buf.writeEnum(this.ingrType());
this.write(buf);
}
public abstract void write(FriendlyByteBuf buf);
/**
@ -44,8 +49,8 @@ public abstract class BrainsweepeeIngredient {
public abstract String getSomeKindOfReasonableIDForEmi();
public static BrainsweepeeIngredient read(FriendlyByteBuf buf) {
var type = buf.readVarInt();
return switch (Type.values()[type]) {
var type = buf.readEnum(Type.class);
return switch (type) {
case VILLAGER -> VillagerIngredient.read(buf);
case ENTITY_TYPE -> EntityTypeIngredient.read(buf);
case ENTITY_TAG -> EntityTagIngredient.read(buf);

View file

@ -89,8 +89,6 @@ public class EntityTagIngredient extends BrainsweepeeIngredient {
@Override
public void write(FriendlyByteBuf buf) {
buf.writeVarInt(Type.ENTITY_TAG.ordinal());
buf.writeResourceLocation(this.entityTypeTag.location());
}

View file

@ -56,8 +56,6 @@ public class EntityTypeIngredient extends BrainsweepeeIngredient {
@Override
public void write(FriendlyByteBuf buf) {
buf.writeVarInt(Type.ENTITY_TYPE.ordinal());
buf.writeVarInt(Registry.ENTITY_TYPE.getId(this.entityType));
}

View file

@ -306,7 +306,7 @@ public class HexplatRecipes extends PaucalRecipeProvider {
.unlockedBy("has_item", hasItem(HexTags.Items.EDIFIED_LOGS)).save(recipes);
for (var log : EDIFIED_LOGS) {
ShapedRecipeBuilder.shaped(HexBlocks.EDIFIED_WOOD, 3)
ShapedRecipeBuilder.shaped(log, 3)
.define('W', log)
.pattern("WW")
.pattern("WW")

View file

@ -5,3 +5,4 @@ accessible field net/minecraft/client/renderer/RenderType$CompositeState textur
accessible class net/minecraft/client/renderer/RenderStateShard$EmptyTextureStateShard
accessible class net/minecraft/world/item/crafting/Ingredient$Value
accessible method net/minecraft/world/item/crafting/Ingredient <init> (Ljava/util/stream/Stream;)V
accessible method net/minecraft/world/item/context/UseOnContext <init> (Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/phys/BlockHitResult;)V

View file

@ -11,3 +11,4 @@ accessible class net/minecraft/client/renderer/RenderType$CompositeRenderType
accessible class net/minecraft/client/renderer/RenderType$CompositeState
accessible field net/minecraft/client/renderer/RenderType$CompositeState textureState Lnet/minecraft/client/renderer/RenderStateShard$EmptyTextureStateShard;
accessible class net/minecraft/client/renderer/RenderStateShard$EmptyTextureStateShard
accessible method net/minecraft/world/item/context/UseOnContext <init> (Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/phys/BlockHitResult;)V