Continue mapping migration
This commit is contained in:
parent
99ade39404
commit
f03fd03bd0
499 changed files with 12567 additions and 12723 deletions
|
@ -3,32 +3,31 @@ package ru.betterend.client.gui;
|
|||
import java.util.Arrays;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.platform.Lighting;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.BufferUploader;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.font.TextFieldHelper;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.blockentity.SignRenderer.SignModel;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.network.chat.CommonComponents;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.ScreenTexts;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.render.BufferBuilder;
|
||||
import net.minecraft.client.render.BufferRenderer;
|
||||
import net.minecraft.client.render.DiffuseLighting;
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.Tessellator;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.VertexFormats;
|
||||
import net.minecraft.client.render.block.entity.SignBlockEntityRenderer.SignModel;
|
||||
import net.minecraft.client.util.SelectionManager;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
import ru.betterend.blocks.basis.EndSignBlock;
|
||||
import ru.betterend.blocks.entities.ESignBlockEntity;
|
||||
import ru.betterend.blocks.entities.render.EndSignBlockEntityRenderer;
|
||||
|
@ -39,39 +38,39 @@ public class BlockSignEditScreen extends Screen {
|
|||
private final ESignBlockEntity sign;
|
||||
private int ticksSinceOpened;
|
||||
private int currentRow;
|
||||
private SelectionManager selectionManager;
|
||||
private TextFieldHelper selectionManager;
|
||||
private final String[] text = (String[]) Util.make(new String[4], (strings) -> {
|
||||
Arrays.fill(strings, "");
|
||||
});
|
||||
|
||||
public BlockSignEditScreen(ESignBlockEntity sign) {
|
||||
super(new TranslatableText("sign.edit"));
|
||||
super(new TranslatableComponent("sign.edit"));
|
||||
this.sign = sign;
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
this.client.keyboard.setRepeatEvents(true);
|
||||
this.addButton(new ButtonWidget(this.width / 2 - 100, this.height / 4 + 120, 200, 20, ScreenTexts.DONE,
|
||||
this.minecraft.keyboardHandler.setSendRepeatsToGui(true);
|
||||
this.addButton(new Button(this.width / 2 - 100, this.height / 4 + 120, 200, 20, CommonComponents.GUI_DONE,
|
||||
(buttonWidget) -> {
|
||||
this.finishEditing();
|
||||
}));
|
||||
this.sign.setEditable(false);
|
||||
this.selectionManager = new SelectionManager(() -> {
|
||||
this.selectionManager = new TextFieldHelper(() -> {
|
||||
return this.text[this.currentRow];
|
||||
}, (string) -> {
|
||||
this.text[this.currentRow] = string;
|
||||
this.sign.setTextOnRow(this.currentRow, new LiteralText(string));
|
||||
}, SelectionManager.makeClipboardGetter(this.client), SelectionManager.makeClipboardSetter(this.client),
|
||||
this.sign.setMessage(this.currentRow, new TextComponent(string));
|
||||
}, TextFieldHelper.createClipboardGetter(this.minecraft), TextFieldHelper.createClipboardSetter(this.minecraft),
|
||||
(string) -> {
|
||||
return this.client.textRenderer.getWidth(string) <= 90;
|
||||
return this.minecraft.font.width(string) <= 90;
|
||||
});
|
||||
}
|
||||
|
||||
public void removed() {
|
||||
this.client.keyboard.setRepeatEvents(false);
|
||||
ClientPlayNetworkHandler clientPlayNetworkHandler = this.client.getNetworkHandler();
|
||||
this.minecraft.keyboardHandler.setSendRepeatsToGui(false);
|
||||
ClientPacketListener clientPlayNetworkHandler = this.minecraft.getConnection();
|
||||
if (clientPlayNetworkHandler != null) {
|
||||
clientPlayNetworkHandler.sendPacket(new UpdateSignC2SPacket(this.sign.getPos(), this.text[0], this.text[1],
|
||||
clientPlayNetworkHandler.send(new ServerboundSignUpdatePacket(this.sign.getBlockPos(), this.text[0], this.text[1],
|
||||
this.text[2], this.text[3]));
|
||||
}
|
||||
|
||||
|
@ -80,18 +79,18 @@ public class BlockSignEditScreen extends Screen {
|
|||
|
||||
public void tick() {
|
||||
++this.ticksSinceOpened;
|
||||
if (!this.sign.getType().supports(this.sign.getCachedState().getBlock())) {
|
||||
if (!this.sign.getType().isValid(this.sign.getBlockState().getBlock())) {
|
||||
this.finishEditing();
|
||||
}
|
||||
}
|
||||
|
||||
private void finishEditing() {
|
||||
this.sign.markDirty();
|
||||
this.client.openScreen((Screen) null);
|
||||
this.sign.setChanged();
|
||||
this.minecraft.setScreen((Screen) null);
|
||||
}
|
||||
|
||||
public boolean charTyped(char chr, int keyCode) {
|
||||
this.selectionManager.insert(chr);
|
||||
this.selectionManager.charTyped(chr);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -102,29 +101,29 @@ public class BlockSignEditScreen extends Screen {
|
|||
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||
if (keyCode == 265) {
|
||||
this.currentRow = this.currentRow - 1 & 3;
|
||||
this.selectionManager.moveCaretToEnd();
|
||||
this.selectionManager.setCursorToEnd();
|
||||
return true;
|
||||
} else if (keyCode != 264 && keyCode != 257 && keyCode != 335) {
|
||||
return this.selectionManager.handleSpecialKey(keyCode) ? true
|
||||
return this.selectionManager.keyPressed(keyCode) ? true
|
||||
: super.keyPressed(keyCode, scanCode, modifiers);
|
||||
} else {
|
||||
this.currentRow = this.currentRow + 1 & 3;
|
||||
this.selectionManager.moveCaretToEnd();
|
||||
this.selectionManager.setCursorToEnd();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
DiffuseLighting.disableGuiDepthLighting();
|
||||
public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
|
||||
Lighting.setupForFlatItems();
|
||||
this.renderBackground(matrices);
|
||||
DrawableHelper.drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 40, 16777215);
|
||||
matrices.push();
|
||||
GuiComponent.drawCenteredString(matrices, this.font, this.title, this.width / 2, 40, 16777215);
|
||||
matrices.pushPose();
|
||||
matrices.translate((double) (this.width / 2), 0.0D, 50.0D);
|
||||
|
||||
matrices.scale(93.75F, -93.75F, 93.75F);
|
||||
matrices.translate(0.0D, -1.3125D, 0.0D);
|
||||
BlockState blockState = this.sign.getCachedState();
|
||||
boolean bl = blockState.get(EndSignBlock.FLOOR);
|
||||
BlockState blockState = this.sign.getBlockState();
|
||||
boolean bl = blockState.getValue(EndSignBlock.FLOOR);
|
||||
|
||||
if (!bl) {
|
||||
matrices.translate(0.0D, -0.3125D, 0.0D);
|
||||
|
@ -132,25 +131,25 @@ public class BlockSignEditScreen extends Screen {
|
|||
|
||||
boolean bl2 = this.ticksSinceOpened / 6 % 2 == 0;
|
||||
|
||||
matrices.push();
|
||||
matrices.pushPose();
|
||||
matrices.scale(0.6666667F, -0.6666667F, -0.6666667F);
|
||||
VertexConsumerProvider.Immediate immediate = this.client.getBufferBuilders().getEntityVertexConsumers();
|
||||
MultiBufferSource.BufferSource immediate = this.minecraft.renderBuffers().bufferSource();
|
||||
VertexConsumer vertexConsumer = EndSignBlockEntityRenderer.getConsumer(immediate, blockState.getBlock());
|
||||
this.model.field.render(matrices, vertexConsumer, 15728880, OverlayTexture.DEFAULT_UV);
|
||||
this.model.sign.render(matrices, vertexConsumer, 15728880, OverlayTexture.NO_OVERLAY);
|
||||
|
||||
if (bl) {
|
||||
this.model.foot.render(matrices, vertexConsumer, 15728880, OverlayTexture.DEFAULT_UV);
|
||||
this.model.stick.render(matrices, vertexConsumer, 15728880, OverlayTexture.NO_OVERLAY);
|
||||
}
|
||||
|
||||
matrices.pop();
|
||||
matrices.popPose();
|
||||
|
||||
matrices.translate(0.0D, 0.3333333432674408D, 0.046666666865348816D);
|
||||
matrices.scale(0.010416667F, -0.010416667F, 0.010416667F);
|
||||
int i = this.sign.getTextColor().getSignColor();
|
||||
int j = this.selectionManager.getSelectionStart();
|
||||
int k = this.selectionManager.getSelectionEnd();
|
||||
int i = this.sign.getColor().getTextColor();
|
||||
int j = this.selectionManager.getCursorPos();
|
||||
int k = this.selectionManager.getSelectionPos();
|
||||
int l = this.currentRow * 10 - this.text.length * 5;
|
||||
Matrix4f matrix4f = matrices.peek().getModel();
|
||||
Matrix4f matrix4f = matrices.last().pose();
|
||||
|
||||
int m;
|
||||
String string2;
|
||||
|
@ -159,73 +158,73 @@ public class BlockSignEditScreen extends Screen {
|
|||
for (m = 0; m < this.text.length; ++m) {
|
||||
string2 = this.text[m];
|
||||
if (string2 != null) {
|
||||
if (this.textRenderer.isRightToLeft()) {
|
||||
string2 = this.textRenderer.mirror(string2);
|
||||
if (this.font.isBidirectional()) {
|
||||
string2 = this.font.bidirectionalShaping(string2);
|
||||
}
|
||||
|
||||
float n = (float) (-this.client.textRenderer.getWidth(string2) / 2);
|
||||
this.client.textRenderer.draw(string2, n, (float) (m * 10 - this.text.length * 5), i, false, matrix4f,
|
||||
float n = (float) (-this.minecraft.font.width(string2) / 2);
|
||||
this.minecraft.font.drawInBatch(string2, n, (float) (m * 10 - this.text.length * 5), i, false, matrix4f,
|
||||
immediate, false, 0, 15728880, false);
|
||||
if (m == this.currentRow && j >= 0 && bl2) {
|
||||
s = this.client.textRenderer
|
||||
.getWidth(string2.substring(0, Math.max(Math.min(j, string2.length()), 0)));
|
||||
t = s - this.client.textRenderer.getWidth(string2) / 2;
|
||||
s = this.minecraft.font
|
||||
.width(string2.substring(0, Math.max(Math.min(j, string2.length()), 0)));
|
||||
t = s - this.minecraft.font.width(string2) / 2;
|
||||
if (j >= string2.length()) {
|
||||
this.client.textRenderer.draw("_", (float) t, (float) l, i, false, matrix4f, immediate, false,
|
||||
this.minecraft.font.drawInBatch("_", (float) t, (float) l, i, false, matrix4f, immediate, false,
|
||||
0, 15728880, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
immediate.draw();
|
||||
immediate.endBatch();
|
||||
|
||||
for (m = 0; m < this.text.length; ++m) {
|
||||
string2 = this.text[m];
|
||||
if (string2 != null && m == this.currentRow && j >= 0) {
|
||||
int r = this.client.textRenderer
|
||||
.getWidth(string2.substring(0, Math.max(Math.min(j, string2.length()), 0)));
|
||||
s = r - this.client.textRenderer.getWidth(string2) / 2;
|
||||
int r = this.minecraft.font
|
||||
.width(string2.substring(0, Math.max(Math.min(j, string2.length()), 0)));
|
||||
s = r - this.minecraft.font.width(string2) / 2;
|
||||
if (bl2 && j < string2.length()) {
|
||||
int var31 = l - 1;
|
||||
int var10003 = s + 1;
|
||||
this.client.textRenderer.getClass();
|
||||
this.minecraft.font.getClass();
|
||||
fill(matrices, s, var31, var10003, l + 9, -16777216 | i);
|
||||
}
|
||||
|
||||
if (k != j) {
|
||||
t = Math.min(j, k);
|
||||
int u = Math.max(j, k);
|
||||
int v = this.client.textRenderer.getWidth(string2.substring(0, t))
|
||||
- this.client.textRenderer.getWidth(string2) / 2;
|
||||
int w = this.client.textRenderer.getWidth(string2.substring(0, u))
|
||||
- this.client.textRenderer.getWidth(string2) / 2;
|
||||
int v = this.minecraft.font.width(string2.substring(0, t))
|
||||
- this.minecraft.font.width(string2) / 2;
|
||||
int w = this.minecraft.font.width(string2.substring(0, u))
|
||||
- this.minecraft.font.width(string2) / 2;
|
||||
int x = Math.min(v, w);
|
||||
int y = Math.max(v, w);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder bufferBuilder = tessellator.getBuffer();
|
||||
Tesselator tessellator = Tesselator.getInstance();
|
||||
BufferBuilder bufferBuilder = tessellator.getBuilder();
|
||||
RenderSystem.disableTexture();
|
||||
RenderSystem.enableColorLogicOp();
|
||||
RenderSystem.logicOp(GlStateManager.LogicOp.OR_REVERSE);
|
||||
bufferBuilder.begin(7, VertexFormats.POSITION_COLOR);
|
||||
bufferBuilder.begin(7, DefaultVertexFormat.POSITION_COLOR);
|
||||
float var32 = (float) x;
|
||||
this.client.textRenderer.getClass();
|
||||
bufferBuilder.vertex(matrix4f, var32, (float) (l + 9), 0.0F).color(0, 0, 255, 255).next();
|
||||
this.minecraft.font.getClass();
|
||||
bufferBuilder.vertex(matrix4f, var32, (float) (l + 9), 0.0F).color(0, 0, 255, 255).endVertex();
|
||||
var32 = (float) y;
|
||||
this.client.textRenderer.getClass();
|
||||
bufferBuilder.vertex(matrix4f, var32, (float) (l + 9), 0.0F).color(0, 0, 255, 255).next();
|
||||
bufferBuilder.vertex(matrix4f, (float) y, (float) l, 0.0F).color(0, 0, 255, 255).next();
|
||||
bufferBuilder.vertex(matrix4f, (float) x, (float) l, 0.0F).color(0, 0, 255, 255).next();
|
||||
this.minecraft.font.getClass();
|
||||
bufferBuilder.vertex(matrix4f, var32, (float) (l + 9), 0.0F).color(0, 0, 255, 255).endVertex();
|
||||
bufferBuilder.vertex(matrix4f, (float) y, (float) l, 0.0F).color(0, 0, 255, 255).endVertex();
|
||||
bufferBuilder.vertex(matrix4f, (float) x, (float) l, 0.0F).color(0, 0, 255, 255).endVertex();
|
||||
bufferBuilder.end();
|
||||
BufferRenderer.draw(bufferBuilder);
|
||||
BufferUploader.end(bufferBuilder);
|
||||
RenderSystem.disableColorLogicOp();
|
||||
RenderSystem.enableTexture();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
matrices.pop();
|
||||
DiffuseLighting.enableGuiDepthLighting();
|
||||
matrices.popPose();
|
||||
Lighting.setupFor3DItems();
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,72 +5,71 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.recipebook.BlastFurnaceRecipeBookScreen;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.recipebook.BlastingRecipeBookComponent;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class EndStoneSmelterRecipeBookScreen extends BlastFurnaceRecipeBookScreen {
|
||||
public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent {
|
||||
private Iterator<Item> fuelIterator;
|
||||
private Set<Item> fuels;
|
||||
private Slot fuelSlot;
|
||||
private Item currentItem;
|
||||
private float frameTime;
|
||||
|
||||
|
||||
@Override
|
||||
protected Set<Item> getAllowedFuels() {
|
||||
protected Set<Item> getFuelItems() {
|
||||
return EndStoneSmelterBlockEntity.availableFuels().keySet();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void slotClicked(Slot slot) {
|
||||
super.slotClicked(slot);
|
||||
if (slot != null && slot.id < this.craftingScreenHandler.getCraftingSlotCount()) {
|
||||
if (slot != null && slot.index < this.menu.getSize()) {
|
||||
this.fuelSlot = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void showGhostRecipe(Recipe<?> recipe, List<Slot> slots) {
|
||||
this.ghostSlots.reset();
|
||||
ItemStack result = recipe.getOutput();
|
||||
this.ghostSlots.setRecipe(recipe);
|
||||
this.ghostSlots.addSlot(Ingredient.ofStacks(result), (slots.get(3)).x, (slots.get(3)).y);
|
||||
DefaultedList<Ingredient> inputs = recipe.getPreviewInputs();
|
||||
public void setupGhostRecipe(Recipe<?> recipe, List<Slot> slots) {
|
||||
this.ghostRecipe.clear();
|
||||
ItemStack result = recipe.getResultItem();
|
||||
this.ghostRecipe.setRecipe(recipe);
|
||||
this.ghostRecipe.addIngredient(Ingredient.of(result), (slots.get(3)).x, (slots.get(3)).y);
|
||||
NonNullList<Ingredient> inputs = recipe.getIngredients();
|
||||
Iterator<Ingredient> iterator = inputs.iterator();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for(int i = 0; i < 2; i++) {
|
||||
if (!iterator.hasNext()) {
|
||||
return;
|
||||
}
|
||||
Ingredient ingredient = iterator.next();
|
||||
if (!ingredient.isEmpty()) {
|
||||
Slot slot = slots.get(i);
|
||||
this.ghostSlots.addSlot(ingredient, slot.x, slot.y);
|
||||
this.ghostRecipe.addIngredient(ingredient, slot.x, slot.y);
|
||||
}
|
||||
}
|
||||
this.fuelSlot = slots.get(2);
|
||||
if (this.fuels == null) {
|
||||
this.fuels = this.getAllowedFuels();
|
||||
this.fuels = this.getFuelItems();
|
||||
}
|
||||
|
||||
this.fuelIterator = this.fuels.iterator();
|
||||
this.currentItem = null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawGhostSlots(MatrixStack matrices, int x, int y, boolean bl, float f) {
|
||||
this.ghostSlots.draw(matrices, client, x, y, bl, f);
|
||||
public void renderGhostRecipe(PoseStack matrices, int x, int y, boolean bl, float f) {
|
||||
this.ghostRecipe.render(matrices, minecraft, x, y, bl, f);
|
||||
if (fuelSlot != null) {
|
||||
if (!Screen.hasControlDown()) {
|
||||
this.frameTime += f;
|
||||
|
@ -78,21 +77,20 @@ public class EndStoneSmelterRecipeBookScreen extends BlastFurnaceRecipeBookScree
|
|||
|
||||
int slotX = this.fuelSlot.x + x;
|
||||
int slotY = this.fuelSlot.y + y;
|
||||
DrawableHelper.fill(matrices, slotX, slotY, slotX + 16, slotY + 16, 822018048);
|
||||
this.client.getItemRenderer().renderInGuiWithOverrides(client.player, this.getItem().getDefaultStack(),
|
||||
slotX, slotY);
|
||||
GuiComponent.fill(matrices, slotX, slotY, slotX + 16, slotY + 16, 822018048);
|
||||
this.minecraft.getItemRenderer().renderAndDecorateItem(minecraft.player, this.getFuel().getDefaultInstance(), slotX, slotY);
|
||||
RenderSystem.depthFunc(516);
|
||||
DrawableHelper.fill(matrices, slotX, slotY, slotX + 16, slotY + 16, 822083583);
|
||||
GuiComponent.fill(matrices, slotX, slotY, slotX + 16, slotY + 16, 822083583);
|
||||
RenderSystem.depthFunc(515);
|
||||
}
|
||||
}
|
||||
|
||||
private Item getItem() {
|
||||
private Item getFuel() {
|
||||
if (this.currentItem == null || this.frameTime > 30.0F) {
|
||||
this.frameTime = 0.0F;
|
||||
if (this.fuelIterator == null || !this.fuelIterator.hasNext()) {
|
||||
if (this.fuels == null) {
|
||||
this.fuels = this.getAllowedFuels();
|
||||
this.fuels = this.getFuelItems();
|
||||
}
|
||||
this.fuelIterator = this.fuels.iterator();
|
||||
}
|
||||
|
|
|
@ -1,72 +1,69 @@
|
|||
package ru.betterend.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||
import net.minecraft.client.gui.screen.recipebook.RecipeBookProvider;
|
||||
import net.minecraft.client.gui.screen.recipebook.RecipeBookWidget;
|
||||
import net.minecraft.client.gui.widget.TexturedButtonWidget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.world.entity.player.PlayerInventory;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import net.minecraft.screen.slot.SlotActionType;
|
||||
import net.minecraft.text.StringVisitable;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.client.gui.components.ImageButton;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent;
|
||||
import net.minecraft.client.gui.screens.recipebook.RecipeUpdateListener;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.inventory.ClickType;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
import ru.betterend.BetterEnd;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class EndStoneSmelterScreen extends HandledScreen<EndStoneSmelterScreenHandler> implements RecipeBookProvider {
|
||||
public class EndStoneSmelterScreen extends AbstractContainerScreen<EndStoneSmelterScreenHandler> implements RecipeUpdateListener {
|
||||
|
||||
private final static ResourceLocation RECIPE_BUTTON_TEXTURE = new ResourceLocation(
|
||||
"textures/gui/recipe_button.png");
|
||||
private final static ResourceLocation RECIPE_BUTTON_TEXTURE = new ResourceLocation("textures/gui/recipe_button.png");
|
||||
private final static ResourceLocation BACKGROUND_TEXTURE = BetterEnd.makeID("textures/gui/smelter_gui.png");
|
||||
|
||||
|
||||
public final EndStoneSmelterRecipeBookScreen recipeBook;
|
||||
private boolean narrow;
|
||||
|
||||
public EndStoneSmelterScreen(EndStoneSmelterScreenHandler handler, PlayerInventory inventory, Text title) {
|
||||
|
||||
public EndStoneSmelterScreen(EndStoneSmelterScreenHandler handler, Inventory inventory, Component title) {
|
||||
super(handler, inventory, title);
|
||||
this.recipeBook = new EndStoneSmelterRecipeBookScreen();
|
||||
}
|
||||
|
||||
|
||||
public void init() {
|
||||
super.init();
|
||||
this.narrow = this.width < 379;
|
||||
this.recipeBook.initialize(width, height, client, narrow, handler);
|
||||
this.x = this.recipeBook.findLeftEdge(narrow, width, backgroundWidth);
|
||||
this.addButton(new TexturedButtonWidget(x + 20, height / 2 - 49, 20, 18, 0, 0, 19, RECIPE_BUTTON_TEXTURE,
|
||||
(buttonWidget) -> {
|
||||
this.recipeBook.reset(narrow);
|
||||
this.recipeBook.toggleOpen();
|
||||
this.x = this.recipeBook.findLeftEdge(narrow, width, backgroundWidth);
|
||||
((TexturedButtonWidget) buttonWidget).setPos(this.x + 20, height / 2 - 49);
|
||||
}));
|
||||
this.titleX = (this.backgroundWidth - this.textRenderer.getWidth((StringVisitable) this.title)) / 2;
|
||||
this.recipeBook.init(width, height, minecraft, narrow, menu);
|
||||
this.leftPos = this.recipeBook.updateScreenPosition(narrow, width, imageWidth);
|
||||
this.addButton(new ImageButton(leftPos + 20, height / 2 - 49, 20, 18, 0, 0, 19, RECIPE_BUTTON_TEXTURE, (buttonWidget) -> {
|
||||
this.recipeBook.initVisuals(narrow);
|
||||
this.recipeBook.toggleVisibility();
|
||||
this.leftPos = this.recipeBook.updateScreenPosition(narrow, width, imageWidth);
|
||||
((ImageButton) buttonWidget).setPosition(this.leftPos + 20, height / 2 - 49);
|
||||
}));
|
||||
this.titleLabelX = (this.imageWidth - this.font.width((FormattedText)this.title)) / 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
this.recipeBook.update();
|
||||
this.recipeBook.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
|
||||
this.renderBackground(matrices);
|
||||
if (this.recipeBook.isOpen() && this.narrow) {
|
||||
this.drawBackground(matrices, delta, mouseX, mouseY);
|
||||
if (this.recipeBook.isVisible() && this.narrow) {
|
||||
this.renderBg(matrices, delta, mouseX, mouseY);
|
||||
this.recipeBook.render(matrices, mouseX, mouseY, delta);
|
||||
} else {
|
||||
this.recipeBook.render(matrices, mouseX, mouseY, delta);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
this.recipeBook.drawGhostSlots(matrices, x, y, true, delta);
|
||||
this.recipeBook.renderGhostRecipe(matrices, leftPos, topPos, true, delta);
|
||||
}
|
||||
|
||||
this.drawMouseoverTooltip(matrices, mouseX, mouseY);
|
||||
this.recipeBook.drawTooltip(matrices, x, y, mouseX, mouseY);
|
||||
this.renderTooltip(matrices, mouseX, mouseY);
|
||||
this.recipeBook.renderTooltip(matrices, leftPos, topPos, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -74,28 +71,25 @@ public class EndStoneSmelterScreen extends HandledScreen<EndStoneSmelterScreenHa
|
|||
if (this.recipeBook.mouseClicked(mouseX, mouseY, button)) {
|
||||
return true;
|
||||
} else {
|
||||
return this.narrow && this.recipeBook.isOpen() ? true : super.mouseClicked(mouseX, mouseY, button);
|
||||
return this.narrow && this.recipeBook.isVisible() ? true : super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMouseClick(Slot slot, int invSlot, int clickData, SlotActionType actionType) {
|
||||
super.onMouseClick(slot, invSlot, clickData, actionType);
|
||||
protected void slotClicked(Slot slot, int invSlot, int clickData, ClickType actionType) {
|
||||
super.slotClicked(slot, invSlot, clickData, actionType);
|
||||
this.recipeBook.slotClicked(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||
return this.recipeBook.keyPressed(keyCode, scanCode, modifiers) ? false
|
||||
: super.keyPressed(keyCode, scanCode, modifiers);
|
||||
return this.recipeBook.keyPressed(keyCode, scanCode, modifiers) ? false : super.keyPressed(keyCode, scanCode, modifiers);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isClickOutsideBounds(double mouseX, double mouseY, int left, int top, int button) {
|
||||
boolean isMouseOut = mouseX < left || mouseY < top || mouseX >= (left + backgroundWidth)
|
||||
|| mouseY >= (top + backgroundHeight);
|
||||
return this.recipeBook.isClickOutsideBounds(mouseX, mouseY, x, y, backgroundWidth, backgroundHeight, button)
|
||||
&& isMouseOut;
|
||||
protected boolean hasClickedOutside(double mouseX, double mouseY, int left, int top, int button) {
|
||||
boolean isMouseOut = mouseX < left || mouseY < top || mouseX >= (left + imageWidth) || mouseY >= (top + imageHeight);
|
||||
return this.recipeBook.hasClickedOutside(mouseX, mouseY, leftPos, topPos, imageWidth, imageHeight, button) && isMouseOut;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -104,32 +98,32 @@ public class EndStoneSmelterScreen extends HandledScreen<EndStoneSmelterScreenHa
|
|||
}
|
||||
|
||||
@Override
|
||||
public void refreshRecipeBook() {
|
||||
this.recipeBook.refresh();
|
||||
public void recipesUpdated() {
|
||||
this.recipeBook.recipesUpdated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeBookWidget getRecipeBookWidget() {
|
||||
public RecipeBookComponent getRecipeBookComponent() {
|
||||
return this.recipeBook;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBackground(MatrixStack matrices, float delta, int mouseX, int mouseY) {
|
||||
protected void renderBg(PoseStack matrices, float delta, int mouseX, int mouseY) {
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.client.getTextureManager().bindTexture(BACKGROUND_TEXTURE);
|
||||
this.drawTexture(matrices, x, y, 0, 0, backgroundWidth, backgroundHeight);
|
||||
this.minecraft.getTextureManager().bind(INVENTORY_LOCATION);
|
||||
this.blit(matrices, leftPos, topPos, 0, 0, imageWidth, imageHeight);
|
||||
int p;
|
||||
if (handler.isBurning()) {
|
||||
p = handler.getFuelProgress();
|
||||
this.drawTexture(matrices, x + 56, y + 36 + 12 - p, 176, 12 - p, 14, p + 1);
|
||||
if (menu.isBurning()) {
|
||||
p = menu.getFuelProgress();
|
||||
this.blit(matrices, leftPos + 56, topPos + 36 + 12 - p, 176, 12 - p, 14, p + 1);
|
||||
}
|
||||
p = handler.getSmeltProgress();
|
||||
this.drawTexture(matrices, x + 92, y + 34, 176, 14, p + 1, 16);
|
||||
p = menu.getSmeltProgress();
|
||||
this.blit(matrices, leftPos + 92, topPos + 34, 176, 14, p + 1, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removed() {
|
||||
this.recipeBook.close();
|
||||
this.recipeBook.removed();
|
||||
super.removed();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,20 +3,20 @@ package ru.betterend.client.gui;
|
|||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.inventory.SimpleInventory;
|
||||
import net.minecraft.world.entity.player.StackedContents;
|
||||
import net.minecraft.world.inventory.ContainerData;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.inventory.RecipeBookMenu;
|
||||
import net.minecraft.world.inventory.RecipeBookType;
|
||||
import net.minecraft.world.inventory.SimpleContainerData;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.inventory.StackedContentsCompatible;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.item.crafting.RecipeFinder;
|
||||
import net.minecraft.world.item.crafting.RecipeInputProvider;
|
||||
import net.minecraft.world.item.crafting.book.RecipeBookCategory;
|
||||
import net.minecraft.screen.AbstractRecipeScreenHandler;
|
||||
import net.minecraft.screen.ArrayPropertyDelegate;
|
||||
import net.minecraft.screen.PropertyDelegate;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import net.minecraft.world.level.Level;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.blocks.EndStoneSmelter;
|
||||
|
@ -25,151 +25,149 @@ import ru.betterend.client.gui.slot.SmelterFuelSlot;
|
|||
import ru.betterend.client.gui.slot.SmelterOutputSlot;
|
||||
import ru.betterend.recipe.builders.AlloyingRecipe;
|
||||
|
||||
public class EndStoneSmelterScreenHandler extends AbstractRecipeScreenHandler<Inventory> {
|
||||
public class EndStoneSmelterScreenHandler extends RecipeBookMenu<Container> {
|
||||
|
||||
public final static ScreenHandlerType<EndStoneSmelterScreenHandler> HANDLER_TYPE = ScreenHandlerRegistry
|
||||
.registerSimple(BetterEnd.makeID(EndStoneSmelter.ID), EndStoneSmelterScreenHandler::new);
|
||||
|
||||
private final Inventory inventory;
|
||||
private final PropertyDelegate propertyDelegate;
|
||||
public final static MenuType<EndStoneSmelterScreenHandler> HANDLER_TYPE = ScreenHandlerRegistry.registerSimple(
|
||||
BetterEnd.makeID(EndStoneSmelter.ID), EndStoneSmelterScreenHandler::new);
|
||||
|
||||
private final Container inventory;
|
||||
private final ContainerData propertyDelegate;
|
||||
protected final Level world;
|
||||
|
||||
public EndStoneSmelterScreenHandler(int syncId, PlayerInventory playerInventory) {
|
||||
this(syncId, playerInventory, new SimpleInventory(4), new ArrayPropertyDelegate(4));
|
||||
|
||||
public EndStoneSmelterScreenHandler(int syncId, Inventory playerInventory) {
|
||||
this(syncId, playerInventory, new SimpleContainer(4), new SimpleContainerData(4));
|
||||
}
|
||||
|
||||
public EndStoneSmelterScreenHandler(int syncId, PlayerInventory playerInventory, Inventory inventory,
|
||||
PropertyDelegate propertyDelegate) {
|
||||
|
||||
public EndStoneSmelterScreenHandler(int syncId, Inventory playerInventory, Container inventory, ContainerData propertyDelegate) {
|
||||
super(HANDLER_TYPE, syncId);
|
||||
this.inventory = inventory;
|
||||
this.propertyDelegate = propertyDelegate;
|
||||
this.world = playerInventory.player.world;
|
||||
|
||||
this.addProperties(propertyDelegate);
|
||||
this.world = playerInventory.player.level;
|
||||
|
||||
this.addDataSlots(propertyDelegate);
|
||||
this.addSlot(new Slot(inventory, 0, 45, 17));
|
||||
this.addSlot(new Slot(inventory, 1, 67, 17));
|
||||
this.addSlot(new SmelterFuelSlot(this, inventory, 2, 56, 53));
|
||||
this.addSlot(new SmelterOutputSlot(playerInventory.player, inventory, 3, 129, 35));
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
for(int i = 0; i < 3; ++i) {
|
||||
for(int j = 0; j < 9; ++j) {
|
||||
this.addSlot(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
for(int i = 0; i < 9; ++i) {
|
||||
this.addSlot(new Slot(playerInventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ScreenHandlerType<?> getType() {
|
||||
public MenuType<?> getType() {
|
||||
return HANDLER_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populateRecipeFinder(RecipeFinder finder) {
|
||||
if (inventory instanceof RecipeInputProvider) {
|
||||
((RecipeInputProvider) inventory).provideRecipeInputs(finder);
|
||||
public void fillCraftSlotsStackedContents(StackedContents finder) {
|
||||
if (inventory instanceof StackedContentsCompatible) {
|
||||
((StackedContentsCompatible) inventory).fillStackedContents(finder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearCraftingSlots() {
|
||||
this.inventory.clear();
|
||||
public void clearCraftingContent() {
|
||||
this.inventory.clearContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Recipe<? super Inventory> recipe) {
|
||||
public boolean recipeMatches(Recipe<? super Container> recipe) {
|
||||
return recipe.matches(this.inventory, this.world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCraftingResultSlotIndex() {
|
||||
public int getResultSlotIndex() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCraftingWidth() {
|
||||
public int getGridWidth() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCraftingHeight() {
|
||||
public int getGridHeight() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCraftingSlotCount() {
|
||||
public int getSize() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeBookCategory getCategory() {
|
||||
return RecipeBookCategory.BLAST_FURNACE;
|
||||
public RecipeBookType getRecipeBookType() {
|
||||
return RecipeBookType.BLAST_FURNACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUse(Player player) {
|
||||
return this.inventory.canPlayerUse(player);
|
||||
public boolean stillValid(Player player) {
|
||||
return this.inventory.stillValid(player);
|
||||
}
|
||||
|
||||
protected boolean isSmeltable(ItemStack itemStack) {
|
||||
return this.world.getRecipeManager()
|
||||
.getFirstMatch(AlloyingRecipe.TYPE, new SimpleInventory(itemStack), this.world).isPresent();
|
||||
return this.world.getRecipeManager().getRecipeFor(AlloyingRecipe.TYPE, new SimpleContainer(itemStack), this.world).isPresent();
|
||||
}
|
||||
|
||||
public boolean isFuel(ItemStack itemStack) {
|
||||
return EndStoneSmelterBlockEntity.canUseAsFuel(itemStack);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack transferSlot(Player player, int index) {
|
||||
public ItemStack quickMoveStack(Player player, int index) {
|
||||
ItemStack itemStack = ItemStack.EMPTY;
|
||||
Slot slot = this.slots.get(index);
|
||||
if (slot != null && slot.hasStack()) {
|
||||
ItemStack itemStack2 = slot.getStack();
|
||||
if (slot != null && slot.hasItem()) {
|
||||
ItemStack itemStack2 = slot.getItem();
|
||||
itemStack = itemStack2.copy();
|
||||
if (index == 3) {
|
||||
if (insertItem(itemStack2, 4, 40, true)) {
|
||||
if (moveItemStackTo(itemStack2, 4, 40, true)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
slot.onStackChanged(itemStack2, itemStack);
|
||||
slot.onQuickCraft(itemStack2, itemStack);
|
||||
} else if (index != 2 && index != 1 && index != 0) {
|
||||
if (isSmeltable(itemStack2)) {
|
||||
if (!insertItem(itemStack2, 0, 2, false)) {
|
||||
if (!moveItemStackTo(itemStack2, 0, 2, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (isFuel(itemStack2)) {
|
||||
if (!this.insertItem(itemStack2, 2, 3, false)) {
|
||||
if (!this.moveItemStackTo(itemStack2, 2, 3, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (index < 31) {
|
||||
if (!insertItem(itemStack2, 31, 40, false)) {
|
||||
if (!moveItemStackTo(itemStack2, 31, 40, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (index < 40 && !insertItem(itemStack2, 4, 31, false)) {
|
||||
} else if (index < 40 && !moveItemStackTo(itemStack2, 4, 31, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (!insertItem(itemStack2, 4, 40, false)) {
|
||||
} else if (!moveItemStackTo(itemStack2, 4, 40, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (itemStack2.isEmpty()) {
|
||||
slot.setStack(ItemStack.EMPTY);
|
||||
slot.set(ItemStack.EMPTY);
|
||||
} else {
|
||||
slot.markDirty();
|
||||
slot.setChanged();
|
||||
}
|
||||
|
||||
if (itemStack2.getCount() == itemStack.getCount()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
slot.onTakeItem(player, itemStack2);
|
||||
slot.onTake(player, itemStack2);
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public int getSmeltProgress() {
|
||||
int time = this.propertyDelegate.get(2);
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
package ru.betterend.client.gui.slot;
|
||||
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.inventory.FurnaceFuelSlot;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.screen.slot.FurnaceFuelSlot;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import ru.betterend.client.gui.EndStoneSmelterScreenHandler;
|
||||
|
||||
public class SmelterFuelSlot extends Slot {
|
||||
|
||||
private final EndStoneSmelterScreenHandler handler;
|
||||
|
||||
public SmelterFuelSlot(EndStoneSmelterScreenHandler handler, Inventory inventory, int index, int x, int y) {
|
||||
|
||||
public SmelterFuelSlot(EndStoneSmelterScreenHandler handler, Container inventory, int index, int x, int y) {
|
||||
super(inventory, index, x, y);
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
public boolean canInsert(ItemStack stack) {
|
||||
|
||||
public boolean mayPlace(ItemStack stack) {
|
||||
return this.handler.isFuel(stack) || FurnaceFuelSlot.isBucket(stack);
|
||||
}
|
||||
|
||||
public int getMaxItemCount(ItemStack stack) {
|
||||
return FurnaceFuelSlot.isBucket(stack) ? 1 : super.getMaxItemCount(stack);
|
||||
public int getMaxStackSize(ItemStack stack) {
|
||||
return FurnaceFuelSlot.isBucket(stack) ? 1 : super.getMaxStackSize(stack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package ru.betterend.client.gui.slot;
|
||||
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
||||
|
||||
public class SmelterOutputSlot extends Slot {
|
||||
|
@ -11,38 +11,38 @@ public class SmelterOutputSlot extends Slot {
|
|||
private Player player;
|
||||
private int amount;
|
||||
|
||||
public SmelterOutputSlot(Player player, Inventory inventory, int index, int x, int y) {
|
||||
public SmelterOutputSlot(Player player, Container inventory, int index, int x, int y) {
|
||||
super(inventory, index, x, y);
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public boolean canInsert(ItemStack stack) {
|
||||
public boolean mayPlace(ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemStack takeStack(int amount) {
|
||||
if (this.hasStack()) {
|
||||
this.amount += Math.min(amount, this.getStack().getCount());
|
||||
public ItemStack remove(int amount) {
|
||||
if (this.hasItem()) {
|
||||
this.amount += Math.min(amount, this.getItem().getCount());
|
||||
}
|
||||
|
||||
return super.takeStack(amount);
|
||||
return super.remove(amount);
|
||||
}
|
||||
|
||||
public ItemStack onTakeItem(Player player, ItemStack stack) {
|
||||
this.onCrafted(stack);
|
||||
super.onTakeItem(player, stack);
|
||||
public ItemStack onTake(Player player, ItemStack stack) {
|
||||
this.checkTakeAchievements(stack);
|
||||
super.onTake(player, stack);
|
||||
return stack;
|
||||
}
|
||||
|
||||
protected void onCrafted(ItemStack stack, int amount) {
|
||||
protected void onQuickCraft(ItemStack stack, int amount) {
|
||||
this.amount += amount;
|
||||
this.onCrafted(stack);
|
||||
this.checkTakeAchievements(stack);
|
||||
}
|
||||
|
||||
protected void onCrafted(ItemStack stack) {
|
||||
stack.onCraft(this.player.world, this.player, this.amount);
|
||||
if (!this.player.world.isClientSide && this.inventory instanceof EndStoneSmelterBlockEntity) {
|
||||
((EndStoneSmelterBlockEntity) this.inventory).dropExperience(player);
|
||||
protected void checkTakeAchievements(ItemStack stack) {
|
||||
stack.onCraftedBy(this.player.level, this.player, this.amount);
|
||||
if (!this.player.level.isClientSide && this.container instanceof EndStoneSmelterBlockEntity) {
|
||||
((EndStoneSmelterBlockEntity) this.container).dropExperience(player);
|
||||
}
|
||||
this.amount = 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue