Continue mapping migration
This commit is contained in:
parent
99ade39404
commit
f03fd03bd0
499 changed files with 12567 additions and 12723 deletions
|
@ -2,7 +2,7 @@ package ru.betterend.client;
|
|||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.core.Registry;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
|
@ -24,15 +24,15 @@ public class BetterEndClient implements ClientModInitializer {
|
|||
EndEntitiesRenders.register();
|
||||
EndModelProviders.register();
|
||||
ClientOptions.init();
|
||||
|
||||
|
||||
if (BetterEnd.isDevEnvironment()) {
|
||||
TranslationHelper.printMissingNames();
|
||||
}
|
||||
}
|
||||
|
||||
private void registerRenderLayers() {
|
||||
RenderLayer cutout = RenderLayer.getCutout();
|
||||
RenderLayer translucent = RenderLayer.getTranslucent();
|
||||
RenderType cutout = RenderType.cutout();
|
||||
RenderType translucent = RenderType.translucent();
|
||||
Registry.BLOCK.forEach(block -> {
|
||||
if (block instanceof IRenderTypeable) {
|
||||
ERenderLayer layer = ((IRenderTypeable) block).getRenderLayer();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -1,75 +1,62 @@
|
|||
package ru.betterend.client.render;
|
||||
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Matrix3f;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.math.Matrix3f;
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
|
||||
public class BeamRenderer {
|
||||
private static final ResourceLocation BEAM_TEXTURE = new ResourceLocation("textures/entity/end_gateway_beam.png");
|
||||
|
||||
public static void renderLightBeam(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int age,
|
||||
float tick, int minY, int maxY, float[] colors, float alpha, float beamIn, float beamOut) {
|
||||
|
||||
public static void renderLightBeam(PoseStack matrices, MultiBufferSource vertexConsumers, int age, float tick, int minY, int maxY, float[] colors, float alpha, float beamIn, float beamOut) {
|
||||
float red = colors[0];
|
||||
float green = colors[1];
|
||||
float blue = colors[2];
|
||||
|
||||
|
||||
int maxBY = minY + maxY;
|
||||
float delta = maxY < 0 ? tick : -tick;
|
||||
float fractDelta = Mth.fractionalPart(delta * 0.2F - (float) Mth.floor(delta * 0.1F));
|
||||
float fractDelta = Mth.frac(delta * 0.2F - (float) Mth.floor(delta * 0.1F));
|
||||
float xIn = -beamIn;
|
||||
float minV = Mth.clamp(fractDelta - 1.0F, 0.0F, 1.0F);
|
||||
float maxV = (float) maxY * (0.5F / beamIn) + minV;
|
||||
float rotation = (age + tick) / 25.0F + 6.0F;
|
||||
|
||||
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderLayer.getBeaconBeam(BEAM_TEXTURE, true));
|
||||
|
||||
matrices.push();
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion(-rotation));
|
||||
renderBeam(matrices, vertexConsumer, red, green, blue, alpha, minY, maxBY, beamIn, 0.0F, 0.0F, beamIn, 0.0F,
|
||||
xIn, xIn, 0.0F, 0.0F, 1.0F, minV, maxV);
|
||||
|
||||
|
||||
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderType.beaconBeam(BEAM_TEXTURE, true));
|
||||
|
||||
matrices.pushPose();
|
||||
matrices.mulPose(Vector3f.YP.rotation(-rotation));
|
||||
renderBeam(matrices, vertexConsumer, red, green, blue, alpha, minY, maxBY, beamIn, 0.0F, 0.0F, beamIn, 0.0F, xIn, xIn, 0.0F, 0.0F, 1.0F, minV, maxV);
|
||||
|
||||
float xOut = -beamOut;
|
||||
maxV = (float) maxY + minV;
|
||||
renderBeam(matrices, vertexConsumer, red, green, blue, alpha, minY, maxBY, xOut, xOut, beamOut, xOut, xOut,
|
||||
beamOut, beamOut, beamOut, 0.0F, 1.0F, minV, maxV);
|
||||
matrices.pop();
|
||||
renderBeam(matrices, vertexConsumer, red, green, blue, alpha, minY, maxBY, xOut, xOut, beamOut, xOut, xOut, beamOut, beamOut, beamOut, 0.0F, 1.0F, minV, maxV);
|
||||
matrices.popPose();
|
||||
}
|
||||
|
||||
private static void renderBeam(MatrixStack matrices, VertexConsumer vertexConsumer, float red, float green,
|
||||
float blue, float alpha, int minY, int maxY, float x1, float d1, float x2, float d2, float x3, float d3,
|
||||
float x4, float d4, float minU, float maxU, float minV, float maxV) {
|
||||
MatrixStack.Entry entry = matrices.peek();
|
||||
Matrix4f matrix4f = entry.getModel();
|
||||
Matrix3f matrix3f = entry.getNormal();
|
||||
renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxY, minY, x1, d1, x2, d2, minU, maxU,
|
||||
minV, maxV);
|
||||
renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxY, minY, x4, d4, x3, d3, minU, maxU,
|
||||
minV, maxV);
|
||||
renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxY, minY, x2, d2, x4, d4, minU, maxU,
|
||||
minV, maxV);
|
||||
renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxY, minY, x3, d3, x1, d1, minU, maxU,
|
||||
minV, maxV);
|
||||
private static void renderBeam(PoseStack matrices, VertexConsumer vertexConsumer, float red, float green, float blue, float alpha, int minY, int maxY, float x1, float d1, float x2, float d2, float x3, float d3, float x4, float d4, float minU, float maxU, float minV, float maxV) {
|
||||
PoseStack.Pose entry = matrices.last();
|
||||
Matrix4f matrix4f = entry.pose();
|
||||
Matrix3f matrix3f = entry.normal();
|
||||
renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxY, minY, x1, d1, x2, d2, minU, maxU, minV, maxV);
|
||||
renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxY, minY, x4, d4, x3, d3, minU, maxU, minV, maxV);
|
||||
renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxY, minY, x2, d2, x4, d4, minU, maxU, minV, maxV);
|
||||
renderBeam(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxY, minY, x3, d3, x1, d1, minU, maxU, minV, maxV);
|
||||
}
|
||||
|
||||
private static void renderBeam(Matrix4f matrix4f, Matrix3f matrix3f, VertexConsumer vertexConsumer, float red,
|
||||
float green, float blue, float alpha, int minY, int maxY, float minX, float minD, float maxX, float maxD,
|
||||
float minU, float maxU, float minV, float maxV) {
|
||||
private static void renderBeam(Matrix4f matrix4f, Matrix3f matrix3f, VertexConsumer vertexConsumer, float red, float green, float blue, float alpha, int minY, int maxY, float minX, float minD, float maxX, float maxD, float minU, float maxU, float minV, float maxV) {
|
||||
addVertex(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxX, minY, maxD, maxU, minV);
|
||||
addVertex(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, maxX, maxY, maxD, maxU, maxV);
|
||||
addVertex(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, minX, maxY, minD, minU, maxV);
|
||||
addVertex(matrix4f, matrix3f, vertexConsumer, red, green, blue, alpha, minX, minY, minD, minU, minV);
|
||||
}
|
||||
|
||||
private static void addVertex(Matrix4f matrix4f, Matrix3f matrix3f, VertexConsumer vertexConsumer, float red,
|
||||
float green, float blue, float alpha, float x, float y, float d, float u, float v) {
|
||||
vertexConsumer.vertex(matrix4f, x, y, d).color(red, green, blue, alpha).texture(u, v)
|
||||
.overlay(OverlayTexture.DEFAULT_UV).light(15728880).normal(matrix3f, 0.0F, 1.0F, 0.0F).next();
|
||||
private static void addVertex(Matrix4f matrix4f, Matrix3f matrix3f, VertexConsumer vertexConsumer, float red, float green, float blue, float alpha, float x, float y, float d, float u, float v) {
|
||||
vertexConsumer.vertex(matrix4f, x, y, d).color(red, green, blue, alpha).uv(u, v).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(15728880).normal(matrix3f, 0.0F, 1.0F, 0.0F).endVertex();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,104 +1,94 @@
|
|||
package ru.betterend.client.render;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Matrix3f;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Quaternion;
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.math.Matrix3f;
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
import net.minecraft.util.math.Quaternion;
|
||||
|
||||
public class EndCrystalRenderer {
|
||||
private static final ResourceLocation CRYSTAL_TEXTURE = new ResourceLocation(
|
||||
"textures/entity/end_crystal/end_crystal.png");
|
||||
private static final ResourceLocation CRYSTAL_BEAM_TEXTURE = new ResourceLocation(
|
||||
"textures/entity/end_crystal/end_crystal_beam.png");
|
||||
private static final RenderLayer CRYSTAL_BEAM_LAYER;
|
||||
private static final RenderLayer END_CRYSTAL;
|
||||
private static final ResourceLocation CRYSTAL_TEXTURE = new ResourceLocation("textures/entity/end_crystal/end_crystal.png");
|
||||
private static final ResourceLocation CRYSTAL_BEAM_TEXTURE = new ResourceLocation("textures/entity/end_crystal/end_crystal_beam.png");
|
||||
private static final RenderType CRYSTAL_BEAM_LAYER;
|
||||
private static final RenderType END_CRYSTAL;
|
||||
private static final ModelPart CORE;
|
||||
private static final ModelPart FRAME;
|
||||
private static final int AGE_CYCLE = 240;
|
||||
private static final float SINE_45_DEGREES;
|
||||
|
||||
public static void render(int age, int maxAge, float tickDelta, MatrixStack matrices,
|
||||
VertexConsumerProvider vertexConsumerProvider, int light) {
|
||||
|
||||
public static void render(int age, int maxAge, float tickDelta, PoseStack matrices, MultiBufferSource vertexConsumerProvider, int light) {
|
||||
float k = (float) AGE_CYCLE / maxAge;
|
||||
float rotation = (age * k + tickDelta) * 3.0F;
|
||||
VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(END_CRYSTAL);
|
||||
matrices.push();
|
||||
matrices.pushPose();
|
||||
matrices.scale(0.8F, 0.8F, 0.8F);
|
||||
matrices.translate(0.0D, -0.5D, 0.0D);
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(rotation));
|
||||
matrices.mulPose(Vector3f.YP.rotationDegrees(rotation));
|
||||
matrices.translate(0.0D, 0.8F, 0.0D);
|
||||
matrices.multiply(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
|
||||
FRAME.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV);
|
||||
matrices.mulPose(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
|
||||
FRAME.render(matrices, vertexConsumer, light, OverlayTexture.NO_OVERLAY);
|
||||
matrices.scale(0.875F, 0.875F, 0.875F);
|
||||
matrices.multiply(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(rotation));
|
||||
FRAME.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV);
|
||||
matrices.mulPose(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
|
||||
matrices.mulPose(Vector3f.YP.rotationDegrees(rotation));
|
||||
FRAME.render(matrices, vertexConsumer, light, OverlayTexture.NO_OVERLAY);
|
||||
matrices.scale(0.875F, 0.875F, 0.875F);
|
||||
matrices.multiply(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(rotation));
|
||||
CORE.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV);
|
||||
matrices.pop();
|
||||
matrices.mulPose(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
|
||||
matrices.mulPose(Vector3f.YP.rotationDegrees(rotation));
|
||||
CORE.render(matrices, vertexConsumer, light, OverlayTexture.NO_OVERLAY);
|
||||
matrices.popPose();
|
||||
}
|
||||
|
||||
public static void renderBeam(BlockPos start, BlockPos end, float tickDelta, int age, MatrixStack matrices,
|
||||
VertexConsumerProvider vertexConsumers, int light) {
|
||||
|
||||
public static void renderBeam(BlockPos start, BlockPos end, float tickDelta, int age, PoseStack matrices, MultiBufferSource vertexConsumers, int light) {
|
||||
float dx = start.getX() - end.getX() + 1.0F;
|
||||
float dy = start.getY() - end.getY() + 1.0F;
|
||||
float dz = start.getZ() - end.getZ() + 1.0F;
|
||||
float f = Mth.sqrt(dx * dx + dz * dz);
|
||||
float g = Mth.sqrt(dx * dx + dy * dy + dz * dz);
|
||||
matrices.push();
|
||||
matrices.pushPose();
|
||||
matrices.translate(0.0D, 2.0D, 0.0D);
|
||||
matrices.multiply(
|
||||
Vector3f.POSITIVE_Y.getRadialQuaternion((float) (-Math.atan2((double) dz, (double) dx)) - 1.5707964F));
|
||||
matrices.multiply(
|
||||
Vector3f.POSITIVE_X.getRadialQuaternion((float) (-Math.atan2((double) f, (double) dy)) - 1.5707964F));
|
||||
matrices.mulPose(Vector3f.YP.rotation((float)(-Math.atan2((double) dz, (double) dx)) - 1.5707964F));
|
||||
matrices.mulPose(Vector3f.XP.rotation((float)(-Math.atan2((double) f, (double) dy)) - 1.5707964F));
|
||||
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(CRYSTAL_BEAM_LAYER);
|
||||
float h = 0.0F - ((float) age + tickDelta) * 0.01F;
|
||||
float i = Mth.sqrt(dx * dx + dy * dy + dz * dz) / 32.0F - ((float) age + tickDelta) * 0.01F;
|
||||
float k = 0.0F;
|
||||
float l = 0.75F;
|
||||
float m = 0.0F;
|
||||
MatrixStack.Entry entry = matrices.peek();
|
||||
Matrix4f matrix4f = entry.getModel();
|
||||
Matrix3f matrix3f = entry.getNormal();
|
||||
PoseStack.Pose entry = matrices.last();
|
||||
Matrix4f matrix4f = entry.pose();
|
||||
Matrix3f matrix3f = entry.normal();
|
||||
|
||||
for (int n = 1; n <= 8; ++n) {
|
||||
float o = Mth.sin((float) n * 6.2831855F / 8.0F) * 0.75F;
|
||||
float p = Mth.cos((float) n * 6.2831855F / 8.0F) * 0.75F;
|
||||
float q = (float) n / 8.0F;
|
||||
vertexConsumer.vertex(matrix4f, k * 0.2F, l * 0.2F, 0.0F).color(0, 0, 0, 255).texture(m, h)
|
||||
.overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
|
||||
vertexConsumer.vertex(matrix4f, k, l, g).color(255, 255, 255, 255).texture(m, i)
|
||||
.overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
|
||||
vertexConsumer.vertex(matrix4f, o, p, g).color(255, 255, 255, 255).texture(q, i)
|
||||
.overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
|
||||
vertexConsumer.vertex(matrix4f, o * 0.2F, p * 0.2F, 0.0F).color(0, 0, 0, 255).texture(q, h)
|
||||
.overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).next();
|
||||
k = o;
|
||||
l = p;
|
||||
m = q;
|
||||
for(int n = 1; n <= 8; ++n) {
|
||||
float o = Mth.sin((float) n * 6.2831855F / 8.0F) * 0.75F;
|
||||
float p = Mth.cos((float) n * 6.2831855F / 8.0F) * 0.75F;
|
||||
float q = (float) n / 8.0F;
|
||||
vertexConsumer.vertex(matrix4f, k * 0.2F, l * 0.2F, 0.0F).color(0, 0, 0, 255).uv(m, h).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).endVertex();
|
||||
vertexConsumer.vertex(matrix4f, k, l, g).color(255, 255, 255, 255).uv(m, i).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).endVertex();
|
||||
vertexConsumer.vertex(matrix4f, o, p, g).color(255, 255, 255, 255).uv(q, i).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).endVertex();
|
||||
vertexConsumer.vertex(matrix4f, o * 0.2F, p * 0.2F, 0.0F).color(0, 0, 0, 255).uv(q, h).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(matrix3f, 0.0F, -1.0F, 0.0F).endVertex();
|
||||
k = o;
|
||||
l = p;
|
||||
m = q;
|
||||
}
|
||||
|
||||
matrices.pop();
|
||||
matrices.popPose();
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
END_CRYSTAL = RenderLayer.getEntityCutoutNoCull(CRYSTAL_TEXTURE);
|
||||
CRYSTAL_BEAM_LAYER = RenderLayer.getEntitySmoothCutout(CRYSTAL_BEAM_TEXTURE);
|
||||
END_CRYSTAL = RenderType.entityCutoutNoCull(CRYSTAL_TEXTURE);
|
||||
CRYSTAL_BEAM_LAYER = RenderType.entitySmoothCutout(CRYSTAL_BEAM_TEXTURE);
|
||||
SINE_45_DEGREES = (float) Math.sin(0.7853981633974483D);
|
||||
FRAME = new ModelPart(64, 32, 0, 0);
|
||||
FRAME.addCuboid(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F);
|
||||
FRAME.addBox(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F);
|
||||
CORE = new ModelPart(64, 32, 32, 0);
|
||||
CORE.addCuboid(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F);
|
||||
CORE.addBox(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,72 +1,69 @@
|
|||
package ru.betterend.client.render;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.util.Mth;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.blocks.AuroraCrystalBlock;
|
||||
import ru.betterend.util.ColorUtil;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class EternalCrystalRenderer {
|
||||
private static final RenderLayer RENDER_LAYER;
|
||||
private static final RenderType RENDER_LAYER;
|
||||
private static final ModelPart[] SHARDS;
|
||||
private static final ModelPart CORE;
|
||||
|
||||
public static void render(int age, float tickDelta, MatrixStack matrices,
|
||||
VertexConsumerProvider vertexConsumerProvider, int light) {
|
||||
|
||||
public static void render(int age, float tickDelta, PoseStack matrices, MultiBufferSource vertexConsumerProvider, int light) {
|
||||
VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(RENDER_LAYER);
|
||||
float[] colors = colors(age);
|
||||
float rotation = (age + tickDelta) / 25.0F + 6.0F;
|
||||
matrices.push();
|
||||
matrices.pushPose();
|
||||
matrices.scale(0.6F, 0.6F, 0.6F);
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion(rotation));
|
||||
CORE.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, colors[0], colors[1], colors[2],
|
||||
colors[3]);
|
||||
|
||||
matrices.mulPose(Vector3f.YP.rotation(rotation));
|
||||
CORE.render(matrices, vertexConsumer, light, OverlayTexture.NO_OVERLAY, colors[0], colors[1], colors[2], colors[3]);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
matrices.push();
|
||||
matrices.pushPose();
|
||||
float offset = Mth.sin(rotation * 2 + i) * 0.15F;
|
||||
matrices.translate(0, offset, 0);
|
||||
SHARDS[i].render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, colors[0], colors[1],
|
||||
colors[2], colors[3]);
|
||||
matrices.pop();
|
||||
SHARDS[i].render(matrices, vertexConsumer, light, OverlayTexture.NO_OVERLAY, colors[0], colors[1], colors[2], colors[3]);
|
||||
matrices.popPose();
|
||||
}
|
||||
|
||||
matrices.pop();
|
||||
|
||||
matrices.popPose();
|
||||
}
|
||||
|
||||
|
||||
public static float[] colors(int age) {
|
||||
double delta = age * 0.01;
|
||||
int index = MHelper.floor(delta);
|
||||
int index2 = (index + 1) & 3;
|
||||
delta -= index;
|
||||
index &= 3;
|
||||
|
||||
|
||||
Vec3i color1 = AuroraCrystalBlock.COLORS[index];
|
||||
Vec3i color2 = AuroraCrystalBlock.COLORS[index2];
|
||||
|
||||
|
||||
int r = MHelper.floor(Mth.lerp(delta, color1.getX(), color2.getX()));
|
||||
int g = MHelper.floor(Mth.lerp(delta, color1.getY(), color2.getY()));
|
||||
int b = MHelper.floor(Mth.lerp(delta, color1.getZ(), color2.getZ()));
|
||||
|
||||
|
||||
return ColorUtil.toFloatArray(MHelper.color(r, g, b));
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
RENDER_LAYER = RenderLayer.getBeaconBeam(BetterEnd.makeID("textures/entity/eternal_crystal.png"), true);
|
||||
RENDER_LAYER = RenderType.beaconBeam(BetterEnd.makeID("textures/entity/eternal_crystal.png"), true);
|
||||
SHARDS = new ModelPart[4];
|
||||
SHARDS[0] = new ModelPart(16, 16, 2, 4).addCuboid(-5.0F, 1.0F, -3.0F, 2.0F, 8.0F, 2.0F);
|
||||
SHARDS[1] = new ModelPart(16, 16, 2, 4).addCuboid(3.0F, -1.0F, -1.0F, 2.0F, 8.0F, 2.0F);
|
||||
SHARDS[2] = new ModelPart(16, 16, 2, 4).addCuboid(-1.0F, 0.0F, -5.0F, 2.0F, 4.0F, 2.0F);
|
||||
SHARDS[3] = new ModelPart(16, 16, 2, 4).addCuboid(0.0F, 3.0F, 4.0F, 2.0F, 6.0F, 2.0F);
|
||||
SHARDS[0] = new ModelPart(16, 16, 2, 4).addBox(-5.0F, 1.0F, -3.0F, 2.0F, 8.0F, 2.0F);
|
||||
SHARDS[1] = new ModelPart(16, 16, 2, 4).addBox(3.0F, -1.0F, -1.0F, 2.0F, 8.0F, 2.0F);
|
||||
SHARDS[2] = new ModelPart(16, 16, 2, 4).addBox(-1.0F, 0.0F, -5.0F, 2.0F, 4.0F, 2.0F);
|
||||
SHARDS[3] = new ModelPart(16, 16, 2, 4).addBox(0.0F, 3.0F, 4.0F, 2.0F, 6.0F, 2.0F);
|
||||
CORE = new ModelPart(16, 16, 0, 0);
|
||||
CORE.addCuboid(-2.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F);
|
||||
CORE.addBox(-2.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue