Addressed multiple ToDo's

This commit is contained in:
Frank 2022-05-19 23:00:16 +02:00
parent ed6263b886
commit ce0afb4cc7
9 changed files with 76 additions and 215 deletions

View file

@ -1,7 +1,5 @@
package org.betterx.betterend.client.gui;
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;
@ -13,8 +11,6 @@ import net.minecraft.world.item.crafting.Recipe;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import org.betterx.betterend.blocks.entities.EndStoneSmelterBlockEntity;
import java.util.Iterator;
@ -23,11 +19,8 @@ import java.util.Set;
@Environment(EnvType.CLIENT)
public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent {
private Iterator<Item> fuelIterator;
private Set<Item> fuels;
private Ingredient fuels;
private Slot fuelSlot;
private Item currentItem;
private float frameTime;
@Override
protected Set<Item> getFuelItems() {
@ -49,6 +42,15 @@ public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent
this.ghostRecipe.setRecipe(recipe);
this.ghostRecipe.addIngredient(Ingredient.of(result), (slots.get(3)).x, (slots.get(3)).y);
NonNullList<Ingredient> inputs = recipe.getIngredients();
this.fuelSlot = slots.get(2);
if (fuelSlot.getItem().isEmpty()) {
if (this.fuels == null) {
this.fuels = Ingredient.of(this.getFuelItems().stream().map(ItemStack::new));
}
this.ghostRecipe.addIngredient(this.fuels, fuelSlot.x, fuelSlot.y);
}
Iterator<Ingredient> iterator = inputs.iterator();
for (int i = 0; i < 2; i++) {
if (!iterator.hasNext()) {
@ -60,51 +62,5 @@ public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent
this.ghostRecipe.addIngredient(ingredient, slot.x, slot.y);
}
}
this.fuelSlot = slots.get(2);
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);
if (fuelSlot != null) {
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);
//TODO: test k=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);
}
}
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.getFuelItems();
}
this.fuelIterator = this.fuels.iterator();
}
this.currentItem = this.fuelIterator.next();
}
return this.currentItem;
}
}

View file

@ -33,7 +33,6 @@ public class EndStoneSmelterScreen extends AbstractContainerScreen<EndStoneSmelt
public void init() {
super.init();
//TODO: test in 1.17
narrow = width < 379;
recipeBook.init(width, height, minecraft, narrow, menu);
leftPos = recipeBook.updateScreenPosition(width, imageWidth);
@ -129,10 +128,8 @@ public class EndStoneSmelterScreen extends AbstractContainerScreen<EndStoneSmelt
@Override
protected void renderBg(PoseStack matrices, float delta, int mouseX, int mouseY) {
if (minecraft == null) return;
//TODO: verify
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, BACKGROUND_TEXTURE);
//minecraft.getTextureManager().bind(BACKGROUND_TEXTURE);
blit(matrices, leftPos, topPos, 0, 0, imageWidth, imageHeight);
int progress;
if (menu.isBurning()) {

View file

@ -1,12 +1,9 @@
package org.betterx.betterend.integration.rei;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.network.chat.Component;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.vertex.PoseStack;
import it.unimi.dsi.fastutil.ints.IntList;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.client.gui.widgets.Widget;
@ -82,37 +79,6 @@ public class REIAlloyingCategory implements DisplayCategory<REIAlloyingDisplay>
return widgets;
}
//TODO: 1.18 REI find replacement
//@Override
public void renderRedSlots(PoseStack matrices,
List<Widget> widgets,
Rectangle bounds,
REIAlloyingDisplay display,
IntList redSlots) {
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 27);
matrices.pushPose();
matrices.translate(0, 0, 400);
if (redSlots.contains(0)) {
GuiComponent.fill(
matrices,
startPoint.x - 20,
startPoint.y + 1,
startPoint.x - 20 + 16,
startPoint.y + 1 + 16,
1090453504
);
GuiComponent.fill(
matrices,
startPoint.x + 1,
startPoint.y + 1,
startPoint.x + 1 + 16,
startPoint.y + 1 + 16,
1090453504
);
}
matrices.popPose();
}
@Override
public int getDisplayHeight() {
return 49;

View file

@ -43,7 +43,7 @@ public class REIAlloyingFuelCategory implements DisplayCategory<REIAlloyingFuelD
@Override
public @NotNull EntryStack getIcon() {
return EntryStacks.of(Items.COAL);
return EntryStacks.of(Items.LAVA_BUCKET);
}
@Override

View file

@ -1,7 +1,5 @@
package org.betterx.betterend.integration.rei;
import net.minecraft.nbt.CompoundTag;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.display.basic.BasicDisplay;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
@ -12,18 +10,10 @@ import java.util.List;
public class REIAlloyingFuelDisplay extends BasicDisplay {
private final int fuelTime;
public REIAlloyingFuelDisplay(List<EntryIngredient> fuel, CompoundTag tag) {
this(fuel, tag.getInt("fuelTime"));
}
public REIAlloyingFuelDisplay(List<EntryIngredient> fuel, int fuelTime) {
super(fuel, Collections.emptyList());
this.fuelTime = fuelTime;
}
//public REIAlloyingFuelDisplay(EntryStack fuel, int fuelTime) {
// this.fuel = fuel;
// this.fuelTime = fuelTime;
// }
@Override
public CategoryIdentifier<?> getCategoryIdentifier() {

View file

@ -1,6 +1,5 @@
package org.betterx.betterend.integration.rei;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack;
@ -8,8 +7,6 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.vertex.PoseStack;
import it.unimi.dsi.fastutil.ints.IntList;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.client.gui.widgets.Widget;
@ -86,40 +83,8 @@ public class REIAnvilCategory implements DisplayCategory<REIAnvilDisplay> {
return widgets;
}
//TODO: 1.18 REI, find replacement
//@Override
public void renderRedSlots(PoseStack matrices,
List<Widget> widgets,
Rectangle bounds,
REIAnvilDisplay display,
IntList redSlots) {
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 27);
matrices.pushPose();
matrices.translate(0, 0, 400);
if (redSlots.contains(0)) {
GuiComponent.fill(
matrices,
startPoint.x - 20,
startPoint.y + 3,
startPoint.x - 20 + 16,
startPoint.y + 3 + 16,
1090453504
);
GuiComponent.fill(
matrices,
startPoint.x + 1,
startPoint.y + 3,
startPoint.x + 1 + 16,
startPoint.y + 3 + 16,
1090453504
);
}
matrices.popPose();
}
@Override
public int getDisplayHeight() {
return 60;
}
}

View file

@ -6,11 +6,15 @@ import net.minecraft.world.item.crafting.BlastingRecipe;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.block.Blocks;
import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.fabricmc.fabric.impl.content.registry.FuelRegistryImpl;
import com.google.common.collect.Lists;
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
import me.shedaniel.rei.api.client.registry.category.CategoryRegistry;
import me.shedaniel.rei.api.client.registry.display.DisplayRegistry;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.util.EntryIngredients;
import me.shedaniel.rei.api.common.util.EntryStacks;
@ -23,6 +27,7 @@ import org.betterx.betterend.recipe.builders.AlloyingRecipe;
import org.betterx.betterend.recipe.builders.InfusionRecipe;
import org.betterx.betterend.registry.EndBlocks;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@ -54,13 +59,15 @@ public class REIPlugin implements REIClientPlugin {
registry.registerRecipeFiller(AnvilRecipe.class, AnvilRecipe.TYPE, REIAnvilDisplay::new);
registry.registerRecipeFiller(InfusionRecipe.class, InfusionRecipe.TYPE, REIInfusionDisplay::new);
//TODO: 1.18 REI fix this
// FuelRegistryImpl.INSTANCE.getFuelTimes().forEach((item, time) -> {
// if (time >= 2000) {
// final List<EntryIngredient> list = Collections.singletonList(EntryIngredients.of(item));
// registry.add(new REIAlloyingFuelDisplay(list, time));
// }
// });
//TODO: Migrate to 1.18/1.18.2
if (FuelRegistry.INSTANCE instanceof FuelRegistryImpl fabricImpl) {
fabricImpl.getFuelTimes().forEach((item, time) -> {
if (time >= 2000) {
final List<EntryIngredient> list = Collections.singletonList(EntryIngredients.of(item));
registry.add(new REIAlloyingFuelDisplay(list, time));
}
});
}
}
@Override

View file

@ -1,11 +1,9 @@
package org.betterx.betterend.registry;
import net.minecraft.core.Registry;
import net.minecraft.tags.TagKey;
import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LeavesBlock;
@ -132,18 +130,4 @@ public class EndTags {
addEndGround(b.getAltTopMaterial().getBlock());
addEndGround(b.getUnderMaterial().getBlock());
}
// TODO make getter for biome top blocks
public static void addTerrainTags(Registry<Biome> biomeRegistry) {
/*biomeRegistry.forEach((biome) -> {
if (biome.getBiomeCategory() == BiomeCategory.THEEND) {
SurfaceBuilderConfiguration config = biome.getGenerationSettings().getSurfaceBuilderConfig();
Block under = config.getUnderMaterial().getBlock();
Block surface = config.getTopMaterial().getBlock();
TagAPI.addTag(CommonBlockTags.GEN_END_STONES, under, surface);
TagAPI.addTag(CommonBlockTags.END_STONES, surface);
}
});
TagAPI.BLOCK_END_STONES.getValues().forEach(TagAPI::addEndGround);*/
}
}

View file

@ -2,13 +2,12 @@
"schemaVersion": 1,
"id": "betterend",
"version": "${version}",
"name": "Better End",
"description": "More content for The End dimension, including new biomes, plants, mobs, mechanics, terrain generation and more.\nMade by:\n- paulevs (code & art)\n- Bulldog83 (code & art)\n- Edos (building)\n- Yuki (art)\n- Seaward (art)\n- Firel (music)\n",
"authors": [
"Quiqueck (code)",
"paulevs (code & art)",
"Bulldog83 (code & art)",
"Frank (code)",
"Edos (building)",
"Yuki (art)",
"Seaward (art)",
@ -16,13 +15,11 @@
],
"contact": {
"homepage": "https://www.curseforge.com/minecraft/mc-mods/betterend",
"issues": "https://github.com/paulevsGitch/BetterEnd/issues",
"sources": "https://github.com/paulevsGitch/BetterEnd"
"issues": "https://github.com/quiqueck/BetterEnd/issues",
"sources": "https://github.com/quiqueck/BetterEnd"
},
"license": "MIT",
"icon": "assets/betterend/icon.png",
"environment": "*",
"entrypoints": {
"main": [
@ -35,13 +32,12 @@
"org.betterx.betterend.integration.rei.REIPlugin"
]
},
"accessWidener" : "betterend.accesswidener",
"accessWidener": "betterend.accesswidener",
"mixins": [
"betterend.mixins.common.json",
"betterend.mixins.client.json",
"betterend.mixins.shadow.json"
],
"depends": {
"fabricloader": ">=0.14.5",
"fabric": ">=0.52.4",