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; 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.client.gui.screens.recipebook.BlastingRecipeBookComponent;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.world.inventory.Slot; 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.EnvType;
import net.fabricmc.api.Environment; 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 org.betterx.betterend.blocks.entities.EndStoneSmelterBlockEntity;
import java.util.Iterator; import java.util.Iterator;
@ -23,11 +19,8 @@ import java.util.Set;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent { public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent {
private Iterator<Item> fuelIterator; private Ingredient fuels;
private Set<Item> fuels;
private Slot fuelSlot; private Slot fuelSlot;
private Item currentItem;
private float frameTime;
@Override @Override
protected Set<Item> getFuelItems() { protected Set<Item> getFuelItems() {
@ -49,6 +42,15 @@ public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent
this.ghostRecipe.setRecipe(recipe); this.ghostRecipe.setRecipe(recipe);
this.ghostRecipe.addIngredient(Ingredient.of(result), (slots.get(3)).x, (slots.get(3)).y); this.ghostRecipe.addIngredient(Ingredient.of(result), (slots.get(3)).x, (slots.get(3)).y);
NonNullList<Ingredient> inputs = recipe.getIngredients(); 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(); Iterator<Ingredient> iterator = inputs.iterator();
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
if (!iterator.hasNext()) { if (!iterator.hasNext()) {
@ -60,51 +62,5 @@ public class EndStoneSmelterRecipeBookScreen extends BlastingRecipeBookComponent
this.ghostRecipe.addIngredient(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.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() { public void init() {
super.init(); super.init();
//TODO: test in 1.17
narrow = width < 379; narrow = width < 379;
recipeBook.init(width, height, minecraft, narrow, menu); recipeBook.init(width, height, minecraft, narrow, menu);
leftPos = recipeBook.updateScreenPosition(width, imageWidth); leftPos = recipeBook.updateScreenPosition(width, imageWidth);
@ -129,10 +128,8 @@ public class EndStoneSmelterScreen extends AbstractContainerScreen<EndStoneSmelt
@Override @Override
protected void renderBg(PoseStack matrices, float delta, int mouseX, int mouseY) { protected void renderBg(PoseStack matrices, float delta, int mouseX, int mouseY) {
if (minecraft == null) return; if (minecraft == null) return;
//TODO: verify
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, BACKGROUND_TEXTURE); RenderSystem.setShaderTexture(0, BACKGROUND_TEXTURE);
//minecraft.getTextureManager().bind(BACKGROUND_TEXTURE);
blit(matrices, leftPos, topPos, 0, 0, imageWidth, imageHeight); blit(matrices, leftPos, topPos, 0, 0, imageWidth, imageHeight);
int progress; int progress;
if (menu.isBurning()) { if (menu.isBurning()) {

View file

@ -1,12 +1,9 @@
package org.betterx.betterend.integration.rei; package org.betterx.betterend.integration.rei;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import com.google.common.collect.Lists; 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.Point;
import me.shedaniel.math.Rectangle; import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.client.gui.widgets.Widget; import me.shedaniel.rei.api.client.gui.widgets.Widget;
@ -82,37 +79,6 @@ public class REIAlloyingCategory implements DisplayCategory<REIAlloyingDisplay>
return widgets; 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 @Override
public int getDisplayHeight() { public int getDisplayHeight() {
return 49; return 49;

View file

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

View file

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

View file

@ -1,6 +1,5 @@
package org.betterx.betterend.integration.rei; package org.betterx.betterend.integration.rei;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack; 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 net.minecraft.world.level.block.Blocks;
import com.google.common.collect.Lists; 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.Point;
import me.shedaniel.math.Rectangle; import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.client.gui.widgets.Widget; import me.shedaniel.rei.api.client.gui.widgets.Widget;
@ -86,40 +83,8 @@ public class REIAnvilCategory implements DisplayCategory<REIAnvilDisplay> {
return widgets; 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 @Override
public int getDisplayHeight() { public int getDisplayHeight() {
return 60; 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.item.crafting.RecipeType;
import net.minecraft.world.level.block.Blocks; 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 com.google.common.collect.Lists;
import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; import me.shedaniel.rei.api.client.registry.category.CategoryRegistry;
import me.shedaniel.rei.api.client.registry.display.DisplayRegistry; import me.shedaniel.rei.api.client.registry.display.DisplayRegistry;
import me.shedaniel.rei.api.common.category.CategoryIdentifier; 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.entry.EntryStack;
import me.shedaniel.rei.api.common.util.EntryIngredients; import me.shedaniel.rei.api.common.util.EntryIngredients;
import me.shedaniel.rei.api.common.util.EntryStacks; 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.recipe.builders.InfusionRecipe;
import org.betterx.betterend.registry.EndBlocks; import org.betterx.betterend.registry.EndBlocks;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -54,13 +59,15 @@ public class REIPlugin implements REIClientPlugin {
registry.registerRecipeFiller(AnvilRecipe.class, AnvilRecipe.TYPE, REIAnvilDisplay::new); registry.registerRecipeFiller(AnvilRecipe.class, AnvilRecipe.TYPE, REIAnvilDisplay::new);
registry.registerRecipeFiller(InfusionRecipe.class, InfusionRecipe.TYPE, REIInfusionDisplay::new); registry.registerRecipeFiller(InfusionRecipe.class, InfusionRecipe.TYPE, REIInfusionDisplay::new);
//TODO: 1.18 REI fix this //TODO: Migrate to 1.18/1.18.2
// FuelRegistryImpl.INSTANCE.getFuelTimes().forEach((item, time) -> { if (FuelRegistry.INSTANCE instanceof FuelRegistryImpl fabricImpl) {
// if (time >= 2000) { fabricImpl.getFuelTimes().forEach((item, time) -> {
// final List<EntryIngredient> list = Collections.singletonList(EntryIngredients.of(item)); if (time >= 2000) {
// registry.add(new REIAlloyingFuelDisplay(list, time)); final List<EntryIngredient> list = Collections.singletonList(EntryIngredients.of(item));
// } registry.add(new REIAlloyingFuelDisplay(list, time));
// }); }
});
}
} }
@Override @Override

View file

@ -1,11 +1,9 @@
package org.betterx.betterend.registry; package org.betterx.betterend.registry;
import net.minecraft.core.Registry;
import net.minecraft.tags.TagKey; import net.minecraft.tags.TagKey;
import net.minecraft.world.food.FoodProperties; import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items; 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.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LeavesBlock; import net.minecraft.world.level.block.LeavesBlock;
@ -132,18 +130,4 @@ public class EndTags {
addEndGround(b.getAltTopMaterial().getBlock()); addEndGround(b.getAltTopMaterial().getBlock());
addEndGround(b.getUnderMaterial().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, "schemaVersion": 1,
"id": "betterend", "id": "betterend",
"version": "${version}", "version": "${version}",
"name": "Better End", "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", "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": [ "authors": [
"Quiqueck (code)",
"paulevs (code & art)", "paulevs (code & art)",
"Bulldog83 (code & art)", "Bulldog83 (code & art)",
"Frank (code)",
"Edos (building)", "Edos (building)",
"Yuki (art)", "Yuki (art)",
"Seaward (art)", "Seaward (art)",
@ -16,13 +15,11 @@
], ],
"contact": { "contact": {
"homepage": "https://www.curseforge.com/minecraft/mc-mods/betterend", "homepage": "https://www.curseforge.com/minecraft/mc-mods/betterend",
"issues": "https://github.com/paulevsGitch/BetterEnd/issues", "issues": "https://github.com/quiqueck/BetterEnd/issues",
"sources": "https://github.com/paulevsGitch/BetterEnd" "sources": "https://github.com/quiqueck/BetterEnd"
}, },
"license": "MIT", "license": "MIT",
"icon": "assets/betterend/icon.png", "icon": "assets/betterend/icon.png",
"environment": "*", "environment": "*",
"entrypoints": { "entrypoints": {
"main": [ "main": [
@ -35,13 +32,12 @@
"org.betterx.betterend.integration.rei.REIPlugin" "org.betterx.betterend.integration.rei.REIPlugin"
] ]
}, },
"accessWidener" : "betterend.accesswidener", "accessWidener": "betterend.accesswidener",
"mixins": [ "mixins": [
"betterend.mixins.common.json", "betterend.mixins.common.json",
"betterend.mixins.client.json", "betterend.mixins.client.json",
"betterend.mixins.shadow.json" "betterend.mixins.shadow.json"
], ],
"depends": { "depends": {
"fabricloader": ">=0.14.5", "fabricloader": ">=0.14.5",
"fabric": ">=0.52.4", "fabric": ">=0.52.4",