Code style changes, entities fixes
This commit is contained in:
parent
9d604b2d25
commit
44962e18b6
377 changed files with 5038 additions and 4914 deletions
|
@ -1,12 +1,7 @@
|
|||
package ru.betterend.client.gui;
|
||||
|
||||
import java.util.Iterator;
|
||||
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.GuiComponent;
|
||||
|
@ -20,6 +15,10 @@ import net.minecraft.world.item.crafting.Ingredient;
|
|||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent {
|
||||
private Iterator<Item> fuelIterator;
|
||||
|
@ -27,12 +26,12 @@ public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent
|
|||
private Slot fuelSlot;
|
||||
private Item currentItem;
|
||||
private float frameTime;
|
||||
|
||||
|
||||
@Override
|
||||
protected Set<Item> getFuelItems() {
|
||||
return EndStoneSmelterBlockEntity.availableFuels().keySet();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void slotClicked(Slot slot) {
|
||||
super.slotClicked(slot);
|
||||
|
@ -40,7 +39,7 @@ public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent
|
|||
this.fuelSlot = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setupGhostRecipe(Recipe<?> recipe, List<Slot> slots) {
|
||||
this.ghostRecipe.clear();
|
||||
|
@ -49,7 +48,7 @@ public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent
|
|||
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;
|
||||
}
|
||||
|
@ -67,7 +66,7 @@ public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent
|
|||
this.fuelIterator = this.fuels.iterator();
|
||||
this.currentItem = null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void renderGhostRecipe(PoseStack matrices, int x, int y, boolean bl, float f) {
|
||||
this.ghostRecipe.render(matrices, minecraft, x, y, bl, f);
|
||||
|
@ -80,7 +79,7 @@ public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent
|
|||
int slotY = this.fuelSlot.y + y;
|
||||
GuiComponent.fill(matrices, slotX, slotY, slotX + 16, slotY + 16, 822018048);
|
||||
//TODO: test k=0
|
||||
this.minecraft.getItemRenderer().renderAndDecorateItem(minecraft.player, this.getFuel().getDefaultInstance(), slotX, slotY,0);
|
||||
this.minecraft.getItemRenderer().renderAndDecorateItem(minecraft.player, this.getFuel().getDefaultInstance(), slotX, slotY, 0);
|
||||
RenderSystem.depthFunc(516);
|
||||
GuiComponent.fill(matrices, slotX, slotY, slotX + 16, slotY + 16, 822083583);
|
||||
RenderSystem.depthFunc(515);
|
||||
|
|
|
@ -2,7 +2,6 @@ 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.components.ImageButton;
|
||||
|
@ -21,15 +20,15 @@ public class EndStoneSmelterScreen extends AbstractContainerScreen<EndStoneSmelt
|
|||
|
||||
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, Inventory inventory, Component title) {
|
||||
super(handler, inventory, title);
|
||||
recipeBook = new EndStoneSmelterRecipeBookScreen();
|
||||
}
|
||||
|
||||
|
||||
public void init() {
|
||||
super.init();
|
||||
//TODO: test in 1.17
|
||||
|
@ -39,7 +38,7 @@ public class EndStoneSmelterScreen extends AbstractContainerScreen<EndStoneSmelt
|
|||
addRenderableWidget(new ImageButton(leftPos + 20, height / 2 - 49, 20, 18, 0, 0, 19, RECIPE_BUTTON_TEXTURE, (buttonWidget) -> {
|
||||
recipeBook.initVisuals();
|
||||
recipeBook.toggleVisibility();
|
||||
leftPos = recipeBook.updateScreenPosition( width, imageWidth);
|
||||
leftPos = recipeBook.updateScreenPosition(width, imageWidth);
|
||||
((ImageButton) buttonWidget).setPosition(leftPos + 20, height / 2 - 49);
|
||||
}));
|
||||
titleLabelX = (imageWidth - font.width(title)) / 2;
|
||||
|
@ -57,7 +56,8 @@ public class EndStoneSmelterScreen extends AbstractContainerScreen<EndStoneSmelt
|
|||
if (recipeBook.isVisible() && narrow) {
|
||||
renderBg(matrices, delta, mouseX, mouseY);
|
||||
recipeBook.render(matrices, mouseX, mouseY, delta);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
recipeBook.render(matrices, mouseX, mouseY, delta);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
recipeBook.renderGhostRecipe(matrices, leftPos, topPos, true, delta);
|
||||
|
@ -70,7 +70,8 @@ public class EndStoneSmelterScreen extends AbstractContainerScreen<EndStoneSmelt
|
|||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (this.recipeBook.mouseClicked(mouseX, mouseY, button)) {
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return narrow && recipeBook.isVisible() || super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,37 +29,37 @@ public class EndStoneSmelterScreenHandler extends RecipeBookMenu<Container> {
|
|||
|
||||
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, Inventory playerInventory) {
|
||||
this(syncId, playerInventory, new SimpleContainer(4), new SimpleContainerData(4));
|
||||
}
|
||||
|
||||
|
||||
public EndStoneSmelterScreenHandler(int syncId, Inventory playerInventory, Container inventory, ContainerData propertyDelegate) {
|
||||
super(HANDLER_TYPE, syncId);
|
||||
this.inventory = inventory;
|
||||
this.propertyDelegate = propertyDelegate;
|
||||
this.world = playerInventory.player.level;
|
||||
|
||||
|
||||
addDataSlots(propertyDelegate);
|
||||
addSlot(new Slot(inventory, 0, 45, 17));
|
||||
addSlot(new Slot(inventory, 1, 67, 17));
|
||||
addSlot(new SmelterFuelSlot(this, inventory, 2, 56, 53));
|
||||
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) {
|
||||
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) {
|
||||
addSlot(new Slot(playerInventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MenuType<?> getType() {
|
||||
return HANDLER_TYPE;
|
||||
|
@ -124,7 +124,7 @@ public class EndStoneSmelterScreenHandler extends RecipeBookMenu<Container> {
|
|||
public boolean isFuel(ItemStack itemStack) {
|
||||
return EndStoneSmelterBlockEntity.canUseAsFuel(itemStack);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player player, int index) {
|
||||
Slot slot = slots.get(index);
|
||||
|
@ -137,29 +137,35 @@ public class EndStoneSmelterScreenHandler extends RecipeBookMenu<Container> {
|
|||
return ItemStack.EMPTY;
|
||||
}
|
||||
slot.onQuickCraft(slotStack, itemStack);
|
||||
} else if (index != 2 && index != 1 && index != 0) {
|
||||
}
|
||||
else if (index != 2 && index != 1 && index != 0) {
|
||||
if (isSmeltable(slotStack)) {
|
||||
if (!moveItemStackTo(slotStack, 0, 2, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (isFuel(slotStack)) {
|
||||
}
|
||||
else if (isFuel(slotStack)) {
|
||||
if (!moveItemStackTo(slotStack, 2, 3, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (index < 31) {
|
||||
}
|
||||
else if (index < 31) {
|
||||
if (!moveItemStackTo(slotStack, 31, 40, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (index < 40 && !moveItemStackTo(slotStack, 4, 31, false)) {
|
||||
}
|
||||
else if (index < 40 && !moveItemStackTo(slotStack, 4, 31, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (!moveItemStackTo(slotStack, 4, 40, false)) {
|
||||
}
|
||||
else if (!moveItemStackTo(slotStack, 4, 40, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (slotStack.isEmpty()) {
|
||||
slot.set(ItemStack.EMPTY);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
slot.setChanged();
|
||||
}
|
||||
|
||||
|
@ -171,7 +177,7 @@ public class EndStoneSmelterScreenHandler extends RecipeBookMenu<Container> {
|
|||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public int getSmeltProgress() {
|
||||
int time = propertyDelegate.get(2);
|
||||
|
|
|
@ -9,12 +9,12 @@ import ru.betterend.client.gui.EndStoneSmelterScreenHandler;
|
|||
public class SmelterFuelSlot extends Slot {
|
||||
|
||||
private final EndStoneSmelterScreenHandler handler;
|
||||
|
||||
|
||||
public SmelterFuelSlot(EndStoneSmelterScreenHandler handler, Container inventory, int index, int x, int y) {
|
||||
super(inventory, index, x, y);
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
|
||||
public boolean mayPlace(ItemStack stack) {
|
||||
return this.handler.isFuel(stack) || FurnaceFuelSlot.isBucket(stack);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue