23w35a
This commit is contained in:
1 parent
82530dc2e8
commit
ed91bfe95d
6 files changed
+14
-14
No files matched your search
+1
-1
@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check https://fabricmc.net/develop/
|
# check https://fabricmc.net/develop/
|
||||||
minecraft_version=23w33a
|
minecraft_version=23w35a
|
||||||
loader_version=0.14.22
|
loader_version=0.14.22
|
||||||
jsr305_version=3.0.2
|
jsr305_version=3.0.2
|
||||||
fabric_version=0.87.1+1.20.2
|
fabric_version=0.87.1+1.20.2
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ package carpet.fakes;
|
|||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.DataSlot;
|
import net.minecraft.world.inventory.DataSlot;
|
||||||
import net.minecraft.world.item.crafting.Recipe;
|
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||||
|
|
||||||
public interface AbstractContainerMenuInterface
|
public interface AbstractContainerMenuInterface
|
||||||
{
|
{
|
||||||
DataSlot getDataSlot(int index);
|
DataSlot getDataSlot(int index);
|
||||||
boolean callButtonClickListener(int button, Player player);
|
boolean callButtonClickListener(int button, Player player);
|
||||||
boolean callSelectRecipeListener(ServerPlayer player, Recipe<?> recipe, boolean craftAll);
|
boolean callSelectRecipeListener(ServerPlayer player, RecipeHolder<?> recipe, boolean craftAll);
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@ package carpet.mixins;
|
|||||||
|
|
||||||
import carpet.fakes.AbstractContainerMenuInterface;
|
import carpet.fakes.AbstractContainerMenuInterface;
|
||||||
import carpet.script.value.ScreenValue;
|
import carpet.script.value.ScreenValue;
|
||||||
|
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
@@ -16,7 +17,6 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
|
|||||||
import net.minecraft.world.inventory.ClickType;
|
import net.minecraft.world.inventory.ClickType;
|
||||||
import net.minecraft.world.inventory.ContainerListener;
|
import net.minecraft.world.inventory.ContainerListener;
|
||||||
import net.minecraft.world.inventory.DataSlot;
|
import net.minecraft.world.inventory.DataSlot;
|
||||||
import net.minecraft.world.item.crafting.Recipe;
|
|
||||||
|
|
||||||
@Mixin(AbstractContainerMenu.class)
|
@Mixin(AbstractContainerMenu.class)
|
||||||
public abstract class AbstractContainerMenu_scarpetMixin implements AbstractContainerMenuInterface
|
public abstract class AbstractContainerMenu_scarpetMixin implements AbstractContainerMenuInterface
|
||||||
@@ -61,7 +61,7 @@ public abstract class AbstractContainerMenu_scarpetMixin implements AbstractCont
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean callSelectRecipeListener(ServerPlayer player, Recipe<?> recipe, boolean craftAll) {
|
public boolean callSelectRecipeListener(ServerPlayer player, RecipeHolder<?> recipe, boolean craftAll) {
|
||||||
for(ContainerListener screenHandlerListener : containerListeners) {
|
for(ContainerListener screenHandlerListener : containerListeners) {
|
||||||
if(screenHandlerListener instanceof ScreenValue.ScarpetScreenHandlerListener scarpetScreenHandlerListener) {
|
if(screenHandlerListener instanceof ScreenValue.ScarpetScreenHandlerListener scarpetScreenHandlerListener) {
|
||||||
if(scarpetScreenHandlerListener.onSelectRecipe(player, recipe, craftAll))
|
if(scarpetScreenHandlerListener.onSelectRecipe(player, recipe, craftAll))
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package carpet.mixins;
|
|||||||
import carpet.fakes.AbstractContainerMenuInterface;
|
import carpet.fakes.AbstractContainerMenuInterface;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.inventory.RecipeBookMenu;
|
import net.minecraft.world.inventory.RecipeBookMenu;
|
||||||
import net.minecraft.world.item.crafting.Recipe;
|
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
@@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
@Mixin(RecipeBookMenu.class)
|
@Mixin(RecipeBookMenu.class)
|
||||||
public class RecipeBookMenu_scarpetMixin {
|
public class RecipeBookMenu_scarpetMixin {
|
||||||
@Inject(method = "handlePlacement",at = @At("HEAD"), cancellable = true)
|
@Inject(method = "handlePlacement",at = @At("HEAD"), cancellable = true)
|
||||||
private void selectRecipeCallback(boolean craftAll, Recipe<?> recipe, ServerPlayer player, CallbackInfo ci) {
|
private void selectRecipeCallback(boolean craftAll, RecipeHolder<?> recipe, ServerPlayer player, CallbackInfo ci) {
|
||||||
if(((AbstractContainerMenuInterface) this).callSelectRecipeListener(player,recipe,craftAll))
|
if(((AbstractContainerMenuInterface) this).callSelectRecipeListener(player,recipe,craftAll))
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ import java.util.function.Supplier;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.advancements.Advancement;
|
import net.minecraft.advancements.AdvancementHolder;
|
||||||
import net.minecraft.advancements.critereon.MinMaxBounds;
|
import net.minecraft.advancements.critereon.MinMaxBounds;
|
||||||
import net.minecraft.commands.CommandBuildContext;
|
import net.minecraft.commands.CommandBuildContext;
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
@@ -205,10 +205,10 @@ public abstract class CommandArgument
|
|||||||
// resource / identifier section
|
// resource / identifier section
|
||||||
|
|
||||||
new VanillaUnconfigurableArgument("recipe", ResourceLocationArgument::id,
|
new VanillaUnconfigurableArgument("recipe", ResourceLocationArgument::id,
|
||||||
(c, p) -> ValueConversions.of(ResourceLocationArgument.getRecipe(c, p).getId()), SuggestionProviders.ALL_RECIPES
|
(c, p) -> ValueConversions.of(ResourceLocationArgument.getRecipe(c, p).id()), SuggestionProviders.ALL_RECIPES
|
||||||
),
|
),
|
||||||
new VanillaUnconfigurableArgument("advancement", ResourceLocationArgument::id,
|
new VanillaUnconfigurableArgument("advancement", ResourceLocationArgument::id,
|
||||||
(c, p) -> ValueConversions.of(ResourceLocationArgument.getAdvancement(c, p).getId()), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().getAdvancements().getAllAdvancements().stream().map(Advancement::getId), builder)
|
(c, p) -> ValueConversions.of(ResourceLocationArgument.getAdvancement(c, p).id()), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().getAdvancements().getAllAdvancements().stream().map(AdvancementHolder::id), builder)
|
||||||
),
|
),
|
||||||
new VanillaUnconfigurableArgument("lootcondition", ResourceLocationArgument::id,
|
new VanillaUnconfigurableArgument("lootcondition", ResourceLocationArgument::id,
|
||||||
(c, p) -> ValueConversions.of(c.getSource().registryAccess().registryOrThrow(Registries.LOOT_CONDITION_TYPE).getKey(ResourceLocationArgument.getPredicate(c, p).getType())), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().getLootData().getKeys(LootDataType.PREDICATE), builder)
|
(c, p) -> ValueConversions.of(c.getSource().registryAccess().registryOrThrow(Registries.LOOT_CONDITION_TYPE).getKey(ResourceLocationArgument.getPredicate(c, p).getType())), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().getLootData().getKeys(LootDataType.PREDICATE), builder)
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ import net.minecraft.world.inventory.SmithingMenu;
|
|||||||
import net.minecraft.world.inventory.SmokerMenu;
|
import net.minecraft.world.inventory.SmokerMenu;
|
||||||
import net.minecraft.world.inventory.StonecutterMenu;
|
import net.minecraft.world.inventory.StonecutterMenu;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.crafting.Recipe;
|
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@@ -252,10 +252,10 @@ public class ScreenValue extends Value
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onSelectRecipe(ServerPlayer player, Recipe<?> recipe, boolean craftAll)
|
public boolean onSelectRecipe(ServerPlayer player, RecipeHolder<?> recipe, boolean craftAll)
|
||||||
{
|
{
|
||||||
Map<Value, Value> data = new HashMap<>();
|
Map<Value, Value> data = new HashMap<>();
|
||||||
data.put(StringValue.of("recipe"), StringValue.of(recipe.getId().toString()));
|
data.put(StringValue.of("recipe"), ValueConversions.of(recipe.id()));
|
||||||
data.put(StringValue.of("craft_all"), BooleanValue.of(craftAll));
|
data.put(StringValue.of("craft_all"), BooleanValue.of(craftAll));
|
||||||
return ScreenValue.this.callListener(player, "select_recipe", data);
|
return ScreenValue.this.callListener(player, "select_recipe", data);
|
||||||
}
|
}
|
||||||
@@ -398,7 +398,7 @@ public class ScreenValue extends Value
|
|||||||
|
|
||||||
void onClose(ServerPlayer player);
|
void onClose(ServerPlayer player);
|
||||||
|
|
||||||
boolean onSelectRecipe(ServerPlayer player, Recipe<?> recipe, boolean craftAll);
|
boolean onSelectRecipe(ServerPlayer player, RecipeHolder<?> recipe, boolean craftAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ScreenHandlerInventory implements Container
|
public static class ScreenHandlerInventory implements Container
|
||||||
|
|||||||
Reference in new issue
Block a user