- Removed Redstone and Lava Bucket requirement in stalinium press.
- Fixed Stalinium Press Logic - Made Stalinium Press work faster when more players are nearby. - Fixed JEI recipe.
This commit is contained in:
@@ -76,6 +76,6 @@ public class StaliniumPressBlock extends BaseEntityBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return createTickerHelper(blockEntityType, net.krituximon.stalinium.block.entity.ModBlockEntities.STALINIUM_PRESS_BE.get(),
|
return createTickerHelper(blockEntityType, net.krituximon.stalinium.block.entity.ModBlockEntities.STALINIUM_PRESS_BE.get(),
|
||||||
(level1, blockPos, blockState, blockEntity) -> blockEntity.tick(level1, blockPos, blockState));
|
(level1, blockPos, blockState, blockEntity) -> blockEntity.tick(level1, blockPos, blockState, blockEntity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+46
-94
@@ -2,9 +2,6 @@ package net.krituximon.stalinium.block.entity;
|
|||||||
|
|
||||||
import net.krituximon.stalinium.event.ComradeHandler;
|
import net.krituximon.stalinium.event.ComradeHandler;
|
||||||
import net.krituximon.stalinium.item.ModItems;
|
import net.krituximon.stalinium.item.ModItems;
|
||||||
import net.krituximon.stalinium.recipe.StaliniumPressRecipe;
|
|
||||||
import net.krituximon.stalinium.recipe.StaliniumPressRecipeInput;
|
|
||||||
import net.krituximon.stalinium.recipe.ModRecipes;
|
|
||||||
import net.krituximon.stalinium.screen.custom.StaliniumPressMenu;
|
import net.krituximon.stalinium.screen.custom.StaliniumPressMenu;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.HolderLookup;
|
import net.minecraft.core.HolderLookup;
|
||||||
@@ -20,8 +17,6 @@ import net.minecraft.world.entity.player.Player;
|
|||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.ContainerData;
|
import net.minecraft.world.inventory.ContainerData;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
|
||||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
@@ -32,97 +27,78 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class StaliniumPressBlockEntity extends BlockEntity implements MenuProvider {
|
public class StaliniumPressBlockEntity extends BlockEntity implements MenuProvider {
|
||||||
public static final int INPUT_SLOT = 0;
|
public static final int INPUT_SLOT = 0;
|
||||||
public static final int REDSTONE_FUEL_SLOT = 1;
|
public static final int OUTPUT_SLOT = 1;
|
||||||
public static final int LAVA_FUEL_SLOT = 2;
|
|
||||||
public static final int OUTPUT_SLOT = 3;
|
|
||||||
|
|
||||||
private int progress = 0;
|
private int progress = 0;
|
||||||
private int maxProgress = 600; // base
|
private int maxProgress = 600;
|
||||||
|
|
||||||
public final ItemStackHandler itemHandler = new ItemStackHandler(4) {
|
public final ItemStackHandler itemHandler = new ItemStackHandler(2) {
|
||||||
@Override
|
@Override
|
||||||
protected void onContentsChanged(int slot) {
|
protected void onContentsChanged(int slot) {
|
||||||
setChanged();
|
setChanged();
|
||||||
if (!level.isClientSide()) {
|
if (!level.isClientSide) {
|
||||||
level.sendBlockUpdated(worldPosition, getBlockState(), getBlockState(), 3);
|
level.sendBlockUpdated(worldPosition, getBlockState(), getBlockState(), 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected final ContainerData data = new ContainerData() {
|
protected final ContainerData data = new ContainerData() {
|
||||||
@Override
|
@Override public int get(int index) { return index == 0 ? progress : (index == 1 ? maxProgress : 0); }
|
||||||
public int get(int index) {
|
@Override public void set(int index,int v){ if(index==0) progress=v; if(index==1) maxProgress=v; }
|
||||||
return index == 0 ? progress : (index == 1 ? maxProgress : 0);
|
@Override public int getCount() { return 2; }
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void set(int index, int value) {
|
|
||||||
if (index == 0) progress = value;
|
|
||||||
if (index == 1) maxProgress = value;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public int getCount() {
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public StaliniumPressBlockEntity(BlockPos pos, BlockState state) {
|
public StaliniumPressBlockEntity(BlockPos pos, BlockState state) {
|
||||||
super(ModBlockEntities.STALINIUM_PRESS_BE.get(), pos, state);
|
super(ModBlockEntities.STALINIUM_PRESS_BE.get(), pos, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public Component getDisplayName() {
|
||||||
public Component getDisplayName() {
|
|
||||||
return Component.translatable("block.stalinium.stalinium_press");
|
return Component.translatable("block.stalinium.stalinium_press");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public AbstractContainerMenu createMenu(int id, net.minecraft.world.entity.player.Inventory inv, Player player) {
|
public AbstractContainerMenu createMenu(int id,
|
||||||
|
net.minecraft.world.entity.player.Inventory inv,
|
||||||
|
Player p) {
|
||||||
return new StaliniumPressMenu(id, inv, this, data);
|
return new StaliniumPressMenu(id, inv, this, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider regs) {
|
||||||
tag.put("inventory", itemHandler.serializeNBT(registries));
|
tag.put("inventory", itemHandler.serializeNBT(regs));
|
||||||
tag.putInt("progress", progress);
|
tag.putInt("progress", progress);
|
||||||
tag.putInt("maxProgress", maxProgress);
|
tag.putInt("maxProgress", maxProgress);
|
||||||
super.saveAdditional(tag, registries);
|
super.saveAdditional(tag, regs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider regs) {
|
||||||
super.loadAdditional(tag, registries);
|
super.loadAdditional(tag, regs);
|
||||||
itemHandler.deserializeNBT(registries, tag.getCompound("inventory"));
|
itemHandler.deserializeNBT(regs, tag.getCompound("inventory"));
|
||||||
progress = tag.getInt("progress");
|
progress = tag.getInt("progress");
|
||||||
maxProgress = tag.getInt("maxProgress");
|
maxProgress = tag.getInt("maxProgress");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Packet<ClientGamePacketListener> getUpdatePacket() {
|
public Packet<ClientGamePacketListener> getUpdatePacket() {
|
||||||
return ClientboundBlockEntityDataPacket.create(this);
|
return ClientboundBlockEntityDataPacket.create(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getUpdateTag(HolderLookup.Provider registries) {
|
public CompoundTag getUpdateTag(HolderLookup.Provider regs) {
|
||||||
return saveWithoutMetadata(registries);
|
return saveWithoutMetadata(regs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void tick(Level level, BlockPos pos, BlockState state, StaliniumPressBlockEntity be) {
|
public static void tick(Level level, BlockPos pos, BlockState state, StaliniumPressBlockEntity be) {
|
||||||
if (be.hasRecipe()) {
|
if (be.hasRecipe()) {
|
||||||
// count nearby party‐members within 10 blocks
|
int bonus = 0;
|
||||||
AABB box = new AABB(pos).inflate(10);
|
AABB search = new AABB(pos).inflate(10);
|
||||||
int nearbyComrades = 0;
|
for (Player p : level.getEntitiesOfClass(Player.class, search, _ignore->true)) {
|
||||||
for (Player p : level.getEntitiesOfClass(Player.class, box, _ignored -> true)) {
|
if (ComradeHandler.findPartyOf(p.getUUID()).isPresent()) bonus++;
|
||||||
if (ComradeHandler.findPartyOf(p.getUUID()).isPresent()) {
|
|
||||||
nearbyComrades++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// base + bonus per comrade
|
|
||||||
int speed = 1 + nearbyComrades;
|
|
||||||
for (int i = 0; i < speed; i++) {
|
|
||||||
be.progress++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
be.progress += 1 + bonus;
|
||||||
be.setChanged(level, pos, state);
|
be.setChanged(level, pos, state);
|
||||||
|
|
||||||
if (be.progress >= be.maxProgress) {
|
if (be.progress >= be.maxProgress) {
|
||||||
be.craftItem();
|
be.craftItem();
|
||||||
be.resetProgress();
|
be.resetProgress();
|
||||||
@@ -131,59 +107,35 @@ public class StaliniumPressBlockEntity extends BlockEntity implements MenuProvid
|
|||||||
be.resetProgress();
|
be.resetProgress();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasRecipe() {
|
private boolean hasRecipe() {
|
||||||
// require ≥9 nuggets
|
|
||||||
ItemStack in = itemHandler.getStackInSlot(INPUT_SLOT);
|
ItemStack in = itemHandler.getStackInSlot(INPUT_SLOT);
|
||||||
if (in.getItem() != ModItems.STALINIUM_NUGGET.get() || in.getCount() < 9) {
|
return in.getItem() == ModItems.STALINIUM_NUGGET.get() && in.getCount() >= 9
|
||||||
return false;
|
&& canInsertItemIntoOutputSlot(ModItems.STALINIUM_INGOT.get().getDefaultInstance());
|
||||||
}
|
|
||||||
Optional<RecipeHolder<StaliniumPressRecipe>> o = getCurrentRecipe();
|
|
||||||
if (o.isEmpty()) return false;
|
|
||||||
ItemStack out = o.get().value().output();
|
|
||||||
return canInsertItemIntoOutputSlot(out) &&
|
|
||||||
canInsertAmountIntoOutputSlot(out.getCount());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<RecipeHolder<StaliniumPressRecipe>> getCurrentRecipe() {
|
|
||||||
return level.getRecipeManager()
|
|
||||||
.getRecipeFor(ModRecipes.STALINIUM_PRESS_TYPE.get(),
|
|
||||||
new StaliniumPressRecipeInput(
|
|
||||||
itemHandler.getStackInSlot(REDSTONE_FUEL_SLOT),
|
|
||||||
itemHandler.getStackInSlot(INPUT_SLOT),
|
|
||||||
itemHandler.getStackInSlot(LAVA_FUEL_SLOT)
|
|
||||||
),
|
|
||||||
level);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void craftItem() {
|
private void craftItem() {
|
||||||
Optional<RecipeHolder<StaliniumPressRecipe>> o = getCurrentRecipe();
|
|
||||||
if (o.isEmpty()) return;
|
|
||||||
itemHandler.extractItem(INPUT_SLOT, 9, false);
|
itemHandler.extractItem(INPUT_SLOT, 9, false);
|
||||||
itemHandler.extractItem(REDSTONE_FUEL_SLOT, 1, false);
|
ItemStack out = itemHandler.getStackInSlot(OUTPUT_SLOT);
|
||||||
itemHandler.extractItem(LAVA_FUEL_SLOT, 1, false);
|
if (out.isEmpty()) {
|
||||||
itemHandler.setStackInSlot(LAVA_FUEL_SLOT, new ItemStack(Items.BUCKET));
|
itemHandler.setStackInSlot(OUTPUT_SLOT, new ItemStack(ModItems.STALINIUM_INGOT.get()));
|
||||||
ItemStack out = o.get().value().output();
|
} else {
|
||||||
ItemStack current = itemHandler.getStackInSlot(OUTPUT_SLOT);
|
out.grow(1);
|
||||||
itemHandler.setStackInSlot(
|
}
|
||||||
OUTPUT_SLOT,
|
|
||||||
new ItemStack(out.getItem(), current.getCount() + 1)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetProgress() {
|
private void resetProgress() {
|
||||||
this.progress = 0;
|
this.progress = 0;
|
||||||
this.maxProgress = 600;
|
this.maxProgress = 600;
|
||||||
}
|
}
|
||||||
|
private boolean canInsertItemIntoOutputSlot(ItemStack output) {
|
||||||
private boolean canInsertItemIntoOutputSlot(ItemStack out) {
|
ItemStack cur = itemHandler.getStackInSlot(OUTPUT_SLOT);
|
||||||
ItemStack current = itemHandler.getStackInSlot(OUTPUT_SLOT);
|
return cur.isEmpty() || cur.getItem() == output.getItem();
|
||||||
return current.isEmpty() || current.getItem() == out.getItem();
|
|
||||||
}
|
}
|
||||||
|
public void drops() {
|
||||||
private boolean canInsertAmountIntoOutputSlot(int count) {
|
SimpleContainer inv = new SimpleContainer(itemHandler.getSlots());
|
||||||
ItemStack current = itemHandler.getStackInSlot(OUTPUT_SLOT);
|
for (int i = 0; i < itemHandler.getSlots(); i++) {
|
||||||
int max = current.isEmpty() ? 64 : current.getMaxStackSize();
|
inv.setItem(i, itemHandler.getStackInSlot(i));
|
||||||
return max >= current.getCount() + count;
|
}
|
||||||
|
Containers.dropContents(level, worldPosition, inv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,21 +35,20 @@ public class JEIStaliniumPlugin implements IModPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void registerRecipes(IRecipeRegistration registration) {
|
public void registerRecipes(IRecipeRegistration registration) {
|
||||||
RecipeManager recipeManager = Minecraft.getInstance().level.getRecipeManager();
|
RecipeManager recipeManager = Minecraft.getInstance().level.getRecipeManager();
|
||||||
|
|
||||||
List<StaliniumPressRecipe> staliniumPressRecipes = recipeManager
|
List<StaliniumPressRecipe> staliniumPressRecipes = recipeManager
|
||||||
.getAllRecipesFor(ModRecipes.STALINIUM_PRESS_TYPE.get()).stream().map(RecipeHolder::value).toList();
|
.getAllRecipesFor(ModRecipes.STALINIUM_PRESS_TYPE.get()).stream().map(RecipeHolder::value).toList();
|
||||||
registration.addRecipes(StaliniumPressRecipeCategory.STALINIUM_PRESS_RECIPE_RECIPE_TYPE, staliniumPressRecipes);
|
registration.addRecipes(StaliniumPressRecipeCategory.TYPE, staliniumPressRecipes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerGuiHandlers(IGuiHandlerRegistration registration) {
|
public void registerGuiHandlers(IGuiHandlerRegistration registration) {
|
||||||
registration.addRecipeClickArea(StaliniumPressScreen.class, 74, 30, 22, 20,
|
registration.addRecipeClickArea(StaliniumPressScreen.class, 74, 30, 22, 20,
|
||||||
StaliniumPressRecipeCategory.STALINIUM_PRESS_RECIPE_RECIPE_TYPE);
|
StaliniumPressRecipeCategory.TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
|
public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
|
||||||
registration.addRecipeCatalyst(new ItemStack(ModBlocks.STALINIUM_PRESS.get().asItem()),
|
registration.addRecipeCatalyst(new ItemStack(ModBlocks.STALINIUM_PRESS.get().asItem()),
|
||||||
StaliniumPressRecipeCategory.STALINIUM_PRESS_RECIPE_RECIPE_TYPE);
|
StaliniumPressRecipeCategory.TYPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package net.krituximon.stalinium.compat;
|
|||||||
|
|
||||||
import mezz.jei.api.constants.VanillaTypes;
|
import mezz.jei.api.constants.VanillaTypes;
|
||||||
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
|
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
|
||||||
|
import mezz.jei.api.gui.builder.IRecipeSlotBuilder;
|
||||||
import mezz.jei.api.gui.drawable.IDrawable;
|
import mezz.jei.api.gui.drawable.IDrawable;
|
||||||
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
|
|
||||||
import mezz.jei.api.helpers.IGuiHelper;
|
import mezz.jei.api.helpers.IGuiHelper;
|
||||||
import mezz.jei.api.recipe.IFocusGroup;
|
import mezz.jei.api.recipe.IFocusGroup;
|
||||||
import mezz.jei.api.recipe.RecipeIngredientRole;
|
import mezz.jei.api.recipe.RecipeIngredientRole;
|
||||||
@@ -12,43 +12,40 @@ import mezz.jei.api.recipe.category.IRecipeCategory;
|
|||||||
import net.krituximon.stalinium.Stalinium;
|
import net.krituximon.stalinium.Stalinium;
|
||||||
import net.krituximon.stalinium.block.ModBlocks;
|
import net.krituximon.stalinium.block.ModBlocks;
|
||||||
import net.krituximon.stalinium.recipe.StaliniumPressRecipe;
|
import net.krituximon.stalinium.recipe.StaliniumPressRecipe;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.crafting.Ingredient;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class StaliniumPressRecipeCategory implements IRecipeCategory<StaliniumPressRecipe> {
|
public class StaliniumPressRecipeCategory implements IRecipeCategory<StaliniumPressRecipe> {
|
||||||
|
|
||||||
public static final ResourceLocation UID = ResourceLocation.fromNamespaceAndPath(Stalinium.MODID, "stalinium_chamber");
|
public static final ResourceLocation UID = ResourceLocation.fromNamespaceAndPath(Stalinium.MODID, "stalinium_press");
|
||||||
public static final ResourceLocation TEXTURE =
|
public static final ResourceLocation TEXTURE =
|
||||||
ResourceLocation.fromNamespaceAndPath(Stalinium.MODID, "textures/gui/stalinium_press_gui.png");
|
ResourceLocation.fromNamespaceAndPath(Stalinium.MODID, "textures/gui/stalinium_press_gui.png");
|
||||||
|
|
||||||
public static final RecipeType<StaliniumPressRecipe> STALINIUM_PRESS_RECIPE_RECIPE_TYPE =
|
public static final RecipeType<StaliniumPressRecipe> TYPE =
|
||||||
new RecipeType<>(UID, StaliniumPressRecipe.class);
|
new RecipeType<>(UID, StaliniumPressRecipe.class);
|
||||||
|
|
||||||
private final IDrawable background;
|
private final IDrawable background;
|
||||||
private final IDrawable icon;
|
private final IDrawable icon;
|
||||||
|
private static final int INPUT_X = 54;
|
||||||
/* --------------------------------------------------------------------- */
|
private static final int INPUT_Y = 34;
|
||||||
/* GUI layout constants */
|
|
||||||
/* --------------------------------------------------------------------- */
|
|
||||||
private static final int[][] INPUT_SLOT_POSITIONS = {
|
|
||||||
{54, 34},
|
|
||||||
{54, 14},
|
|
||||||
{54, 54}
|
|
||||||
};
|
|
||||||
private static final int OUTPUT_X = 104;
|
private static final int OUTPUT_X = 104;
|
||||||
private static final int OUTPUT_Y = 34;
|
private static final int OUTPUT_Y = 34;
|
||||||
|
|
||||||
public StaliniumPressRecipeCategory(IGuiHelper helper) {
|
public StaliniumPressRecipeCategory(IGuiHelper helper) {
|
||||||
this.background = helper.createDrawable(TEXTURE, 0, 0, 176, 85);
|
this.background = helper.createDrawable(TEXTURE, 0, 0, 176, 85);
|
||||||
this.icon = helper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(ModBlocks.STALINIUM_PRESS));
|
this.icon = helper.createDrawableIngredient(
|
||||||
|
VanillaTypes.ITEM_STACK,
|
||||||
|
new ItemStack(ModBlocks.STALINIUM_PRESS)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RecipeType<StaliniumPressRecipe> getRecipeType() {
|
public RecipeType<StaliniumPressRecipe> getRecipeType() {
|
||||||
return STALINIUM_PRESS_RECIPE_RECIPE_TYPE;
|
return TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -57,7 +54,8 @@ public class StaliniumPressRecipeCategory implements IRecipeCategory<StaliniumPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable IDrawable getIcon() {
|
@Nullable
|
||||||
|
public IDrawable getIcon() {
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,28 +68,23 @@ public class StaliniumPressRecipeCategory implements IRecipeCategory<StaliniumPr
|
|||||||
public void setRecipe(IRecipeLayoutBuilder builder,
|
public void setRecipe(IRecipeLayoutBuilder builder,
|
||||||
StaliniumPressRecipe recipe,
|
StaliniumPressRecipe recipe,
|
||||||
IFocusGroup focuses) {
|
IFocusGroup focuses) {
|
||||||
var ingredients = recipe.getIngredients();
|
IRecipeSlotBuilder inputslot = builder
|
||||||
builder
|
.addSlot(RecipeIngredientRole.INPUT, INPUT_X, INPUT_Y);
|
||||||
.addSlot(RecipeIngredientRole.INPUT,
|
|
||||||
INPUT_SLOT_POSITIONS[0][0],
|
Ingredient nuggetIng = recipe.getIngredients().get(1);
|
||||||
INPUT_SLOT_POSITIONS[0][1])
|
for (ItemStack stack : nuggetIng.getItems()) {
|
||||||
.addIngredients(ingredients.get(1));
|
ItemStack copy = stack.copy();
|
||||||
builder
|
copy.setCount(9);
|
||||||
.addSlot(RecipeIngredientRole.INPUT,
|
inputslot.addItemStack(copy);
|
||||||
INPUT_SLOT_POSITIONS[1][0],
|
}
|
||||||
INPUT_SLOT_POSITIONS[1][1])
|
|
||||||
.addIngredients(ingredients.get(0));
|
|
||||||
builder
|
|
||||||
.addSlot(RecipeIngredientRole.INPUT,
|
|
||||||
INPUT_SLOT_POSITIONS[2][0],
|
|
||||||
INPUT_SLOT_POSITIONS[2][1])
|
|
||||||
.addIngredients(ingredients.get(2));
|
|
||||||
var output = recipe.getResultItem(
|
|
||||||
net.minecraft.client.Minecraft.getInstance()
|
|
||||||
.level
|
|
||||||
.registryAccess());
|
|
||||||
builder
|
builder
|
||||||
.addSlot(RecipeIngredientRole.OUTPUT, OUTPUT_X, OUTPUT_Y)
|
.addSlot(RecipeIngredientRole.OUTPUT, OUTPUT_X, OUTPUT_Y)
|
||||||
.addItemStack(output);
|
.addItemStack(
|
||||||
|
recipe.getResultItem(
|
||||||
|
Minecraft.getInstance()
|
||||||
|
.level
|
||||||
|
.registryAccess()
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,11 @@ import net.krituximon.stalinium.block.ModBlocks;
|
|||||||
import net.krituximon.stalinium.block.entity.StaliniumPressBlockEntity;
|
import net.krituximon.stalinium.block.entity.StaliniumPressBlockEntity;
|
||||||
import net.krituximon.stalinium.screen.ModMenuTypes;
|
import net.krituximon.stalinium.screen.ModMenuTypes;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.*;
|
import net.minecraft.world.inventory.*;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
import net.neoforged.neoforge.items.SlotItemHandler;
|
import net.neoforged.neoforge.items.SlotItemHandler;
|
||||||
|
|
||||||
import static net.krituximon.stalinium.block.entity.StaliniumPressBlockEntity.*;
|
import static net.krituximon.stalinium.block.entity.StaliniumPressBlockEntity.*;
|
||||||
@@ -29,16 +27,8 @@ public class StaliniumPressMenu extends AbstractContainerMenu {
|
|||||||
this.blockEntity = be;
|
this.blockEntity = be;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.level = inv.player.level();
|
this.level = inv.player.level();
|
||||||
|
|
||||||
// INPUT
|
|
||||||
this.addSlot(new SlotItemHandler(be.itemHandler, INPUT_SLOT, 54, 34));
|
this.addSlot(new SlotItemHandler(be.itemHandler, INPUT_SLOT, 54, 34));
|
||||||
// REDSTONE FUEL
|
|
||||||
this.addSlot(new SlotItemHandler(be.itemHandler, REDSTONE_FUEL_SLOT,54, 14));
|
|
||||||
// LAVA FUEL
|
|
||||||
this.addSlot(new SlotItemHandler(be.itemHandler, LAVA_FUEL_SLOT, 54, 54));
|
|
||||||
// OUTPUT
|
|
||||||
this.addSlot(new SlotItemHandler(be.itemHandler, OUTPUT_SLOT, 104, 34));
|
this.addSlot(new SlotItemHandler(be.itemHandler, OUTPUT_SLOT, 104, 34));
|
||||||
|
|
||||||
addPlayerInventory(inv);
|
addPlayerInventory(inv);
|
||||||
addPlayerHotbar(inv);
|
addPlayerHotbar(inv);
|
||||||
addDataSlots(data);
|
addDataSlots(data);
|
||||||
@@ -55,14 +45,6 @@ public class StaliniumPressMenu extends AbstractContainerMenu {
|
|||||||
|
|
||||||
return maxProgress != 0 && progress != 0 ? progress * arrowPixelSize / maxProgress : 0;
|
return maxProgress != 0 && progress != 0 ? progress * arrowPixelSize / maxProgress : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// CREDIT GOES TO: diesieben07 | https://github.com/diesieben07/SevenCommons
|
|
||||||
// must assign a slot number to each of the slots used by the GUI.
|
|
||||||
// For this container, we can see both the tile inventory's slots as well as the player inventory slots and the hotbar.
|
|
||||||
// Each time we add a Slot to the container, it automatically increases the slotIndex, which means
|
|
||||||
// 0 - 8 = hotbar slots (which will map to the InventoryPlayer slot numbers 0 - 8)
|
|
||||||
// 9 - 35 = player inventory slots (which map to the InventoryPlayer slot numbers 9 - 35)
|
|
||||||
// 36 - 44 = TileInventory slots, which map to our TileEntity slot numbers 0 - 8)
|
|
||||||
private static final int HOTBAR_SLOT_COUNT = 9;
|
private static final int HOTBAR_SLOT_COUNT = 9;
|
||||||
private static final int PLAYER_INVENTORY_ROW_COUNT = 3;
|
private static final int PLAYER_INVENTORY_ROW_COUNT = 3;
|
||||||
private static final int PLAYER_INVENTORY_COLUMN_COUNT = 9;
|
private static final int PLAYER_INVENTORY_COLUMN_COUNT = 9;
|
||||||
@@ -70,9 +52,9 @@ public class StaliniumPressMenu extends AbstractContainerMenu {
|
|||||||
private static final int VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_SLOT_COUNT;
|
private static final int VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_SLOT_COUNT;
|
||||||
private static final int VANILLA_FIRST_SLOT_INDEX = 0;
|
private static final int VANILLA_FIRST_SLOT_INDEX = 0;
|
||||||
private static final int TE_INVENTORY_FIRST_SLOT_INDEX = VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT;
|
private static final int TE_INVENTORY_FIRST_SLOT_INDEX = VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT;
|
||||||
|
|
||||||
// THIS YOU HAVE TO DEFINE!
|
|
||||||
private static final int TE_INVENTORY_SLOT_COUNT = 2; // must be the number of slots you have!
|
private static final int TE_INVENTORY_SLOT_COUNT = 2; // must be the number of slots you have!
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack quickMoveStack(Player playerIn, int pIndex) {
|
public ItemStack quickMoveStack(Player playerIn, int pIndex) {
|
||||||
Slot sourceSlot = slots.get(pIndex);
|
Slot sourceSlot = slots.get(pIndex);
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 2.5 KiB |
Reference in New Issue
Block a user