Removed color provider
This commit is contained in:
parent
2c8862a37b
commit
4040597a6d
475 changed files with 5411 additions and 7521 deletions
|
@ -26,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);
|
||||
|
@ -39,7 +39,7 @@ public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent
|
|||
this.fuelSlot = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setupGhostRecipe(Recipe<?> recipe, List<Slot> slots) {
|
||||
this.ghostRecipe.clear();
|
||||
|
@ -62,11 +62,11 @@ public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent
|
|||
if (this.fuels == null) {
|
||||
this.fuels = this.getFuelItems();
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
@ -74,7 +74,7 @@ public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent
|
|||
if (!Screen.hasControlDown()) {
|
||||
this.frameTime += f;
|
||||
}
|
||||
|
||||
|
||||
int slotX = this.fuelSlot.x + x;
|
||||
int slotY = this.fuelSlot.y + y;
|
||||
GuiComponent.fill(matrices, slotX, slotY, slotX + 16, slotY + 16, 822018048);
|
||||
|
@ -85,7 +85,7 @@ public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent
|
|||
RenderSystem.depthFunc(515);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Item getFuel() {
|
||||
if (this.currentItem == null || this.frameTime > 30.0F) {
|
||||
this.frameTime = 0.0F;
|
||||
|
|
|
@ -17,18 +17,18 @@ import ru.betterend.BetterEnd;
|
|||
|
||||
@Environment(EnvType.CLIENT)
|
||||
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 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
|
||||
|
@ -43,13 +43,13 @@ public class EndStoneSmelterScreen extends AbstractContainerScreen<EndStoneSmelt
|
|||
}));
|
||||
titleLabelX = (imageWidth - font.width(title)) / 2;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void containerTick() {
|
||||
super.containerTick();
|
||||
recipeBook.tick();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
|
||||
renderBackground(matrices);
|
||||
|
@ -65,7 +65,7 @@ public class EndStoneSmelterScreen extends AbstractContainerScreen<EndStoneSmelt
|
|||
renderTooltip(matrices, mouseX, mouseY);
|
||||
recipeBook.renderTooltip(matrices, leftPos, topPos, mouseX, mouseY);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (this.recipeBook.mouseClicked(mouseX, mouseY, button)) {
|
||||
|
@ -75,39 +75,39 @@ public class EndStoneSmelterScreen extends AbstractContainerScreen<EndStoneSmelt
|
|||
return narrow && recipeBook.isVisible() || super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
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 !recipeBook.keyPressed(keyCode, scanCode, modifiers) && super.keyPressed(keyCode, scanCode, modifiers);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
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
|
||||
public boolean charTyped(char chr, int keyCode) {
|
||||
return recipeBook.charTyped(chr, keyCode) || super.charTyped(chr, keyCode);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void recipesUpdated() {
|
||||
recipeBook.recipesUpdated();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public RecipeBookComponent getRecipeBookComponent() {
|
||||
return recipeBook;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void renderBg(PoseStack matrices, float delta, int mouseX, int mouseY) {
|
||||
if (minecraft == null) return;
|
||||
|
@ -124,7 +124,7 @@ public class EndStoneSmelterScreen extends AbstractContainerScreen<EndStoneSmelt
|
|||
progress = menu.getSmeltProgress();
|
||||
blit(matrices, leftPos + 92, topPos + 34, 176, 14, progress + 1, 16);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removed() {
|
||||
recipeBook.removed();
|
||||
|
|
|
@ -26,30 +26,29 @@ import ru.betterend.client.gui.slot.SmelterOutputSlot;
|
|||
import ru.betterend.recipe.builders.AlloyingRecipe;
|
||||
|
||||
public class EndStoneSmelterScreenHandler extends RecipeBookMenu<Container> {
|
||||
|
||||
public final static MenuType<EndStoneSmelterScreenHandler> HANDLER_TYPE = ScreenHandlerRegistry.registerSimple(
|
||||
BetterEnd.makeID(EndStoneSmelter.ID), EndStoneSmelterScreenHandler::new);
|
||||
|
||||
|
||||
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) {
|
||||
addSlot(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
|
@ -59,77 +58,77 @@ public class EndStoneSmelterScreenHandler extends RecipeBookMenu<Container> {
|
|||
addSlot(new Slot(playerInventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MenuType<?> getType() {
|
||||
return HANDLER_TYPE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void fillCraftSlotsStackedContents(StackedContents finder) {
|
||||
if (inventory instanceof StackedContentsCompatible) {
|
||||
((StackedContentsCompatible) inventory).fillStackedContents(finder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void clearCraftingContent() {
|
||||
inventory.clearContent();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean recipeMatches(Recipe<? super Container> recipe) {
|
||||
return recipe.matches(inventory, world);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getResultSlotIndex() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getGridWidth() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getGridHeight() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public RecipeBookType getRecipeBookType() {
|
||||
return RecipeBookType.BLAST_FURNACE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean shouldMoveToInventory(int i) {
|
||||
return i != this.getResultSlotIndex();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
return inventory.stillValid(player);
|
||||
}
|
||||
|
||||
|
||||
protected boolean isSmeltable(ItemStack itemStack) {
|
||||
return world.getRecipeManager().getRecipeFor(AlloyingRecipe.TYPE, new SimpleContainer(itemStack), world).isPresent();
|
||||
}
|
||||
|
||||
|
||||
public boolean isFuel(ItemStack itemStack) {
|
||||
return EndStoneSmelterBlockEntity.canUseAsFuel(itemStack);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player player, int index) {
|
||||
Slot slot = slots.get(index);
|
||||
if (slot == null || !slot.hasItem()) return ItemStack.EMPTY;
|
||||
|
||||
|
||||
ItemStack slotStack = slot.getItem();
|
||||
ItemStack itemStack = slotStack.copy();
|
||||
if (index == 3) {
|
||||
|
@ -161,30 +160,30 @@ public class EndStoneSmelterScreenHandler extends RecipeBookMenu<Container> {
|
|||
else if (!moveItemStackTo(slotStack, 4, 40, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
|
||||
if (slotStack.isEmpty()) {
|
||||
slot.set(ItemStack.EMPTY);
|
||||
}
|
||||
else {
|
||||
slot.setChanged();
|
||||
}
|
||||
|
||||
|
||||
if (slotStack.getCount() == itemStack.getCount()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
|
||||
slot.onTake(player, slotStack);
|
||||
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public int getSmeltProgress() {
|
||||
int time = propertyDelegate.get(2);
|
||||
int timeTotal = propertyDelegate.get(3);
|
||||
return timeTotal != 0 && time != 0 ? time * 24 / timeTotal : 0;
|
||||
}
|
||||
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public int getFuelProgress() {
|
||||
int fuelTime = propertyDelegate.get(1);
|
||||
|
@ -193,7 +192,7 @@ public class EndStoneSmelterScreenHandler extends RecipeBookMenu<Container> {
|
|||
}
|
||||
return propertyDelegate.get(0) * 13 / fuelTime;
|
||||
}
|
||||
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public boolean isBurning() {
|
||||
return propertyDelegate.get(0) > 0;
|
||||
|
|
|
@ -7,18 +7,18 @@ import net.minecraft.world.item.ItemStack;
|
|||
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);
|
||||
}
|
||||
|
||||
|
||||
public int getMaxStackSize(ItemStack stack) {
|
||||
return FurnaceFuelSlot.isBucket(stack) ? 1 : super.getMaxStackSize(stack);
|
||||
}
|
||||
|
|
|
@ -7,37 +7,37 @@ import net.minecraft.world.item.ItemStack;
|
|||
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
||||
|
||||
public class SmelterOutputSlot extends Slot {
|
||||
|
||||
|
||||
private Player player;
|
||||
private int amount;
|
||||
|
||||
|
||||
public SmelterOutputSlot(Player player, Container inventory, int index, int x, int y) {
|
||||
super(inventory, index, x, y);
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
|
||||
public boolean mayPlace(ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public ItemStack remove(int amount) {
|
||||
if (this.hasItem()) {
|
||||
this.amount += Math.min(amount, this.getItem().getCount());
|
||||
}
|
||||
|
||||
|
||||
return super.remove(amount);
|
||||
}
|
||||
|
||||
|
||||
public void onTake(Player player, ItemStack stack) {
|
||||
this.checkTakeAchievements(stack);
|
||||
super.onTake(player, stack);
|
||||
}
|
||||
|
||||
|
||||
protected void onQuickCraft(ItemStack stack, int amount) {
|
||||
this.amount += amount;
|
||||
this.checkTakeAchievements(stack);
|
||||
}
|
||||
|
||||
|
||||
protected void checkTakeAchievements(ItemStack stack) {
|
||||
stack.onCraftedBy(this.player.level, this.player, this.amount);
|
||||
if (!this.player.level.isClientSide && this.container instanceof EndStoneSmelterBlockEntity) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue