Use modern java features where we can, optimise imports.

This commit is contained in:
modmuss50 2021-05-29 20:32:05 +01:00
parent 52e4767247
commit 31e7b357dc
135 changed files with 342 additions and 794 deletions

View file

@ -33,9 +33,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.world.World; import net.minecraft.world.World;
import reborncore.common.util.ItemUtils;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import reborncore.common.util.ItemUtils;
public class InventoryUtils { public class InventoryUtils {
@ -67,8 +66,7 @@ public class InventoryUtils {
public static ItemStack insertItem(ItemStack input, Inventory inventory, Direction direction) { public static ItemStack insertItem(ItemStack input, Inventory inventory, Direction direction) {
ItemStack stack = input.copy(); ItemStack stack = input.copy();
if (inventory instanceof SidedInventory) { if (inventory instanceof SidedInventory sidedInventory) {
SidedInventory sidedInventory = (SidedInventory) inventory;
for (int slot : sidedInventory.getAvailableSlots(direction)) { for (int slot : sidedInventory.getAvailableSlots(direction)) {
if (sidedInventory.canInsert(slot, stack, direction)) { if (sidedInventory.canInsert(slot, stack, direction)) {
stack = insertIntoInv(sidedInventory, slot, stack); stack = insertIntoInv(sidedInventory, slot, stack);

View file

@ -35,9 +35,9 @@ import net.minecraft.client.render.entity.feature.FeatureRendererContext;
import net.minecraft.client.render.entity.model.EntityModel; import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.render.entity.model.PlayerEntityModel; import net.minecraft.client.render.entity.model.PlayerEntityModel;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.Vec3f;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3f;
import reborncore.common.RebornCoreConfig; import reborncore.common.RebornCoreConfig;
import reborncore.common.util.CalenderUtils; import reborncore.common.util.CalenderUtils;

View file

@ -32,7 +32,6 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.Framebuffer; import net.minecraft.client.gl.Framebuffer;
import net.minecraft.client.gl.SimpleFramebuffer; import net.minecraft.client.gl.SimpleFramebuffer;
import net.minecraft.client.render.DiffuseLighting; import net.minecraft.client.render.DiffuseLighting;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.OverlayTexture; import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.item.ItemRenderer; import net.minecraft.client.render.item.ItemRenderer;
@ -46,7 +45,6 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.math.Matrix4f; import net.minecraft.util.math.Matrix4f;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.lwjgl.opengl.GL11;
import java.io.File; import java.io.File;

View file

@ -24,13 +24,10 @@
package reborncore.client; package reborncore.client;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler; import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler;
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry; import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.Drawable;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.render.*; import net.minecraft.client.render.*;
import net.minecraft.client.texture.Sprite; import net.minecraft.client.texture.Sprite;
import net.minecraft.client.texture.SpriteAtlasTexture; import net.minecraft.client.texture.SpriteAtlasTexture;

View file

@ -27,9 +27,7 @@ package reborncore.client;
import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback; import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider; import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.item.TooltipContext; import net.minecraft.client.item.TooltipContext;
import net.minecraft.client.resource.language.I18n; import net.minecraft.client.resource.language.I18n;

View file

@ -46,6 +46,7 @@ import net.minecraft.text.LiteralText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
import net.minecraft.util.Util; import net.minecraft.util.Util;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import reborncore.api.blockentity.IUpgradeable; import reborncore.api.blockentity.IUpgradeable;
import reborncore.client.gui.builder.slot.FluidConfigGui; import reborncore.client.gui.builder.slot.FluidConfigGui;
@ -56,8 +57,6 @@ import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.client.screen.builder.BuiltScreenHandler; import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.slot.PlayerInventorySlot; import reborncore.client.screen.builder.slot.PlayerInventorySlot;
import reborncore.common.blockentity.MachineBaseBlockEntity; import reborncore.common.blockentity.MachineBaseBlockEntity;
import org.jetbrains.annotations.Nullable;
import reborncore.mixin.client.AccessorScreen; import reborncore.mixin.client.AccessorScreen;
import java.util.ArrayList; import java.util.ArrayList;
@ -212,8 +211,7 @@ public class GuiBase<T extends ScreenHandler> extends HandledScreen<T> {
if (drawPlayerSlots) { if (drawPlayerSlots) {
builder.drawPlayerSlots(matrixStack, this, x + backgroundWidth / 2, y + 93, true); builder.drawPlayerSlots(matrixStack, this, x + backgroundWidth / 2, y + 93, true);
} }
if (tryAddUpgrades() && be instanceof IUpgradeable) { if (tryAddUpgrades() && be instanceof IUpgradeable upgradeable) {
IUpgradeable upgradeable = (IUpgradeable) be;
if (upgradeable.canBeUpgraded()) { if (upgradeable.canBeUpgraded()) {
builder.drawUpgrades(matrixStack, this, x - 24, y + 6); builder.drawUpgrades(matrixStack, this, x - 24, y + 6);
upgrades = true; upgrades = true;

View file

@ -26,7 +26,6 @@ package reborncore.client.gui.builder;
import net.minecraft.client.render.item.ItemRenderer; import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.network.Packet;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
import reborncore.client.RenderUtil; import reborncore.client.RenderUtil;

View file

@ -27,13 +27,13 @@ package reborncore.client.gui.builder.slot;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import org.jetbrains.annotations.Nullable;
import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.builder.slot.elements.ConfigFluidElement; import reborncore.client.gui.builder.slot.elements.ConfigFluidElement;
import reborncore.client.gui.builder.slot.elements.ElementBase; import reborncore.client.gui.builder.slot.elements.ElementBase;
import reborncore.client.gui.builder.slot.elements.SlotType; import reborncore.client.gui.builder.slot.elements.SlotType;
import reborncore.common.blockentity.MachineBaseBlockEntity; import reborncore.common.blockentity.MachineBaseBlockEntity;
import org.jetbrains.annotations.Nullable;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -131,15 +131,13 @@ public class FluidConfigGui {
@Nullable @Nullable
private static MachineBaseBlockEntity getMachine() { private static MachineBaseBlockEntity getMachine() {
if (!(MinecraftClient.getInstance().currentScreen instanceof GuiBase)) { if (!(MinecraftClient.getInstance().currentScreen instanceof GuiBase<?> base)) {
return null; return null;
} }
GuiBase<?> base = (GuiBase<?>) MinecraftClient.getInstance().currentScreen; if (base.be instanceof MachineBaseBlockEntity machineBase) {
if (!(base.be instanceof MachineBaseBlockEntity)) { return machineBase;
return null;
} }
MachineBaseBlockEntity machineBase = (MachineBaseBlockEntity) base.be; return null;
return machineBase;
} }
} }

View file

@ -31,6 +31,7 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.Slot;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.util.Util; import net.minecraft.util.Util;
import org.jetbrains.annotations.Nullable;
import reborncore.client.gui.GuiUtil; import reborncore.client.gui.GuiUtil;
import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.builder.slot.elements.ConfigSlotElement; import reborncore.client.gui.builder.slot.elements.ConfigSlotElement;
@ -43,7 +44,6 @@ import reborncore.common.network.ServerBoundPackets;
import reborncore.common.util.Color; import reborncore.common.util.Color;
import reborncore.mixin.common.AccessorSlot; import reborncore.mixin.common.AccessorSlot;
import org.jetbrains.annotations.Nullable;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -129,15 +129,13 @@ public class SlotConfigGui {
@Nullable @Nullable
private static MachineBaseBlockEntity getMachine() { private static MachineBaseBlockEntity getMachine() {
if (!(MinecraftClient.getInstance().currentScreen instanceof GuiBase)) { if (!(MinecraftClient.getInstance().currentScreen instanceof GuiBase<?> base)) {
return null; return null;
} }
GuiBase<?> base = (GuiBase<?>) MinecraftClient.getInstance().currentScreen; if (base.be instanceof MachineBaseBlockEntity machineBase) {
if (!(base.be instanceof MachineBaseBlockEntity)) { return machineBase;
return null;
} }
MachineBaseBlockEntity machineBase = (MachineBaseBlockEntity) base.be; return null;
return machineBase;
} }
public static boolean mouseClicked(GuiBase<?> guiBase, double mouseX, double mouseY, int mouseButton) { public static boolean mouseClicked(GuiBase<?> guiBase, double mouseX, double mouseY, int mouseButton) {

View file

@ -29,13 +29,13 @@ public class ButtonElement extends ElementBase {
private final Sprite.Button buttonSprite; private final Sprite.Button buttonSprite;
public ButtonElement(int x, int y, Sprite.Button buttonSprite) { public ButtonElement(int x, int y, Sprite.Button buttonSprite) {
super(x, y, buttonSprite.getNormal()); super(x, y, buttonSprite.normal());
this.buttonSprite = buttonSprite; this.buttonSprite = buttonSprite;
this.addUpdateAction((gui, element) -> { this.addUpdateAction((gui, element) -> {
if (isHovering) { if (isHovering) {
element.container.setSprite(0, buttonSprite.getHovered()); element.container.setSprite(0, buttonSprite.hovered());
} else { } else {
element.container.setSprite(0, buttonSprite.getNormal()); element.container.setSprite(0, buttonSprite.normal());
} }
}); });
} }

View file

@ -41,7 +41,7 @@ public class CheckBoxElement extends ElementBase {
private final Sprite.CheckBox checkBoxSprite; private final Sprite.CheckBox checkBoxSprite;
public CheckBoxElement(Text label, int labelColor, int x, int y, String type, int slotID, Sprite.CheckBox checkBoxSprite, MachineBaseBlockEntity machineBase, Predicate<CheckBoxElement> ticked) { public CheckBoxElement(Text label, int labelColor, int x, int y, String type, int slotID, Sprite.CheckBox checkBoxSprite, MachineBaseBlockEntity machineBase, Predicate<CheckBoxElement> ticked) {
super(x, y, checkBoxSprite.getNormal()); super(x, y, checkBoxSprite.normal());
this.checkBoxSprite = checkBoxSprite; this.checkBoxSprite = checkBoxSprite;
this.type = type; this.type = type;
this.slotID = slotID; this.slotID = slotID;
@ -50,15 +50,15 @@ public class CheckBoxElement extends ElementBase {
this.labelColor = labelColor; this.labelColor = labelColor;
this.ticked = ticked; this.ticked = ticked;
if (ticked.test(this)) { if (ticked.test(this)) {
container.setSprite(0, checkBoxSprite.getTicked()); container.setSprite(0, checkBoxSprite.ticked());
} else { } else {
container.setSprite(0, checkBoxSprite.getNormal()); container.setSprite(0, checkBoxSprite.normal());
} }
this.addPressAction((element, gui, provider, mouseX, mouseY) -> { this.addPressAction((element, gui, provider, mouseX, mouseY) -> {
if (ticked.test(this)) { if (ticked.test(this)) {
element.container.setSprite(0, checkBoxSprite.getTicked()); element.container.setSprite(0, checkBoxSprite.ticked());
} else { } else {
element.container.setSprite(0, checkBoxSprite.getNormal()); element.container.setSprite(0, checkBoxSprite.normal());
} }
return true; return true;
}); });
@ -67,12 +67,12 @@ public class CheckBoxElement extends ElementBase {
@Override @Override
public void draw(MatrixStack matrixStack, GuiBase<?> gui) { public void draw(MatrixStack matrixStack, GuiBase<?> gui) {
// super.draw(gui); // super.draw(gui);
ISprite sprite = checkBoxSprite.getNormal(); ISprite sprite = checkBoxSprite.normal();
if (ticked.test(this)) { if (ticked.test(this)) {
sprite = checkBoxSprite.getTicked(); sprite = checkBoxSprite.ticked();
} }
drawSprite(matrixStack, gui, sprite, x, y); drawSprite(matrixStack, gui, sprite, x, y);
drawText(matrixStack, gui, label, x + checkBoxSprite.getNormal().width + 5, ((y + getHeight(gui.getMachine()) / 2) - (gui.getTextRenderer().fontHeight / 2)), labelColor); drawText(matrixStack, gui, label, x + checkBoxSprite.normal().width + 5, ((y + getHeight(gui.getMachine()) / 2) - (gui.getTextRenderer().fontHeight / 2)), labelColor);
} }
} }

View file

@ -87,8 +87,7 @@ public class ConfigSlotElement extends ElementBase {
return true; return true;
})); }));
if (gui.getMachine() instanceof SlotConfiguration.SlotFilter) { if (gui.getMachine() instanceof SlotConfiguration.SlotFilter slotFilter) {
SlotConfiguration.SlotFilter slotFilter = (SlotConfiguration.SlotFilter) gui.getMachine();
if (Arrays.stream(slotFilter.getInputSlots()).anyMatch(value -> value == slotId)) { if (Arrays.stream(slotFilter.getInputSlots()).anyMatch(value -> value == slotId)) {
elements.add(new CheckBoxElement(new TranslatableText("reborncore.gui.slotconfig.filter_input"), 0xFFFFFFFF, x - 26, y + 72, "filter", slotId, Sprite.LIGHT_CHECK_BOX, gui.getMachine(), elements.add(new CheckBoxElement(new TranslatableText("reborncore.gui.slotconfig.filter_input"), 0xFFFFFFFF, x - 26, y + 72, "filter", slotId, Sprite.LIGHT_CHECK_BOX, gui.getMachine(),
checkBoxElement -> checkBoxElement.machineBase.getSlotConfiguration().getSlotDetails(checkBoxElement.slotID).filter()).addPressAction((element, gui13, provider, mouseX, mouseY) -> { checkBoxElement -> checkBoxElement.machineBase.getSlotConfiguration().getSlotDetails(checkBoxElement.slotID).filter()).addPressAction((element, gui13, provider, mouseX, mouseY) -> {

View file

@ -35,7 +35,6 @@ import net.minecraft.client.render.block.BlockRenderManager;
import net.minecraft.client.render.model.BakedModel; import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.texture.SpriteAtlasTexture; import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.network.Packet;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Quaternion; import net.minecraft.util.math.Quaternion;
@ -153,24 +152,12 @@ public class FluidConfigPopupElement extends ElementBase {
return; return;
} }
FluidConfiguration.FluidConfig fluidConfig = fluidConfiguration.getSideDetail(side); FluidConfiguration.FluidConfig fluidConfig = fluidConfiguration.getSideDetail(side);
Color color; Color color = switch (fluidConfig.getIoConfig()) {
switch (fluidConfig.getIoConfig()) { case NONE -> new Color(0, 0, 0, 0);
case NONE: case INPUT -> new Color(0, 0, 255, 128);
color = new Color(0, 0, 0, 0); case OUTPUT -> new Color(255, 69, 0, 128);
break; case ALL -> new Color(52, 255, 30, 128);
case INPUT: };
color = new Color(0, 0, 255, 128);
break;
case OUTPUT:
color = new Color(255, 69, 0, 128);
break;
case ALL:
color = new Color(52, 255, 30, 128);
break;
default:
color = new Color(0, 0, 0, 0);
break;
}
RenderSystem.setShaderColor(1, 1, 1, 1); RenderSystem.setShaderColor(1, 1, 1, 1);
GuiUtil.drawGradientRect(matrices, sx, sy, 18, 18, color.getColor(), color.getColor()); GuiUtil.drawGradientRect(matrices, sx, sy, 18, 18, color.getColor(), color.getColor());
RenderSystem.setShaderColor(1, 1, 1, 1); RenderSystem.setShaderColor(1, 1, 1, 1);

View file

@ -35,7 +35,6 @@ import net.minecraft.client.render.block.BlockRenderManager;
import net.minecraft.client.render.model.BakedModel; import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.texture.SpriteAtlasTexture; import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.network.Packet;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Quaternion; import net.minecraft.util.math.Quaternion;
@ -159,18 +158,11 @@ public class SlotConfigPopupElement extends ElementBase {
return; return;
} }
SlotConfiguration.SlotConfig slotConfig = slotConfigHolder.getSideDetail(side); SlotConfiguration.SlotConfig slotConfig = slotConfigHolder.getSideDetail(side);
Color color; Color color = switch (slotConfig.getSlotIO().getIoConfig()) {
switch (slotConfig.getSlotIO().getIoConfig()) { case INPUT -> new Color(0, 0, 255, 128);
case INPUT: case OUTPUT -> new Color(255, 69, 0, 128);
color = new Color(0, 0, 255, 128); default -> new Color(0, 0, 0, 0);
break; };
case OUTPUT:
color = new Color(255, 69, 0, 128);
break;
default:
color = new Color(0, 0, 0, 0);
break;
}
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
GuiUtil.drawGradientRect(matrices, sx, sy, 18, 18, color.getColor(), color.getColor()); GuiUtil.drawGradientRect(matrices, sx, sy, 18, 18, color.getColor(), color.getColor());
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);

View file

@ -107,63 +107,16 @@ public class Sprite implements ISprite {
return this; return this;
} }
public static class Button { public record Button(Sprite normal,
private final Sprite normal; Sprite hovered) {
private final Sprite hovered;
public Button(Sprite normal, Sprite hovered) {
this.normal = normal;
this.hovered = hovered;
}
public Sprite getNormal() {
return normal;
}
public Sprite getHovered() {
return hovered;
}
} }
public static class ToggleButton { public record ToggleButton(Sprite normal,
private final Sprite normal; Sprite hovered,
private final Sprite hovered; Sprite pressed) {
private final Sprite pressed;
public ToggleButton(Sprite normal, Sprite hovered, Sprite pressed) {
this.normal = normal;
this.hovered = hovered;
this.pressed = pressed;
}
public Sprite getNormal() {
return normal;
}
public Sprite getHovered() {
return hovered;
}
public Sprite getPressed() {
return pressed;
}
} }
public static class CheckBox { public record CheckBox(Sprite normal,
private final Sprite normal; Sprite ticked) {
private final Sprite ticked;
public CheckBox(Sprite normal, Sprite ticked) {
this.normal = normal;
this.ticked = ticked;
}
public Sprite getNormal() {
return normal;
}
public Sprite getTicked() {
return ticked;
}
} }
} }

View file

@ -414,7 +414,7 @@ public class GuiBuilder {
} }
private class TipsListWidget extends EntryListWidget<TipsListWidget.TipsListEntry> { private static class TipsListWidget extends EntryListWidget<TipsListWidget.TipsListEntry> {
public TipsListWidget(GuiBase<?> gui, int width, int height, int top, int bottom, int entryHeight, List<Text> tips) { public TipsListWidget(GuiBase<?> gui, int width, int height, int top, int bottom, int entryHeight, List<Text> tips) {
super(gui.getMinecraft(), width, height, top, bottom, entryHeight); super(gui.getMinecraft(), width, height, top, bottom, entryHeight);

View file

@ -28,11 +28,12 @@ import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
public class SlotFilteredVoid extends BaseSlot { public class SlotFilteredVoid extends BaseSlot {
private final List<ItemStack> filter = new ArrayList<ItemStack>(); private final List<ItemStack> filter = new ArrayList<>();
public SlotFilteredVoid(Inventory itemHandler, int id, int x, int y) { public SlotFilteredVoid(Inventory itemHandler, int id, int x, int y) {
super(itemHandler, id, x, y); super(itemHandler, id, x, y);
@ -40,9 +41,7 @@ public class SlotFilteredVoid extends BaseSlot {
public SlotFilteredVoid(Inventory itemHandler, int id, int x, int y, ItemStack[] filterList) { public SlotFilteredVoid(Inventory itemHandler, int id, int x, int y, ItemStack[] filterList) {
super(itemHandler, id, x, y); super(itemHandler, id, x, y);
for (ItemStack itemStack : filterList) { this.filter.addAll(Arrays.asList(filterList));
this.filter.add(itemStack);
}
} }
@Override @Override

View file

@ -24,13 +24,10 @@
package reborncore.client.multiblock; package reborncore.client.multiblock;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BlockEntityRenderer; import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory; import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.BlockPos;
import reborncore.common.blockentity.MachineBaseBlockEntity; import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.blockentity.MultiblockWriter; import reborncore.common.blockentity.MultiblockWriter;

View file

@ -170,8 +170,7 @@ public class BlockEntityScreenHandlerBuilder {
} }
public BlockEntityScreenHandlerBuilder syncEnergyValue() { public BlockEntityScreenHandlerBuilder syncEnergyValue() {
if (this.blockEntity instanceof PowerAcceptorBlockEntity) { if (this.blockEntity instanceof PowerAcceptorBlockEntity powerAcceptor) {
PowerAcceptorBlockEntity powerAcceptor = ((PowerAcceptorBlockEntity) this.blockEntity);
return this.sync(powerAcceptor::getEnergy, powerAcceptor::setEnergy) return this.sync(powerAcceptor::getEnergy, powerAcceptor::setEnergy)
.sync(powerAcceptor::getExtraPowerStorage, powerAcceptor::setExtraPowerStorage) .sync(powerAcceptor::getExtraPowerStorage, powerAcceptor::setExtraPowerStorage)
@ -183,8 +182,7 @@ public class BlockEntityScreenHandlerBuilder {
} }
public BlockEntityScreenHandlerBuilder syncCrafterValue() { public BlockEntityScreenHandlerBuilder syncCrafterValue() {
if (this.blockEntity instanceof IRecipeCrafterProvider) { if (this.blockEntity instanceof IRecipeCrafterProvider recipeCrafter) {
IRecipeCrafterProvider recipeCrafter = ((IRecipeCrafterProvider) this.blockEntity);
return this return this
.sync(() -> recipeCrafter.getRecipeCrafter().currentTickTime, (time) -> recipeCrafter.getRecipeCrafter().currentTickTime = time) .sync(() -> recipeCrafter.getRecipeCrafter().currentTickTime, (time) -> recipeCrafter.getRecipeCrafter().currentTickTime = time)
.sync(() -> recipeCrafter.getRecipeCrafter().currentNeededTicks, (ticks) -> recipeCrafter.getRecipeCrafter().currentNeededTicks = ticks); .sync(() -> recipeCrafter.getRecipeCrafter().currentNeededTicks, (ticks) -> recipeCrafter.getRecipeCrafter().currentNeededTicks = ticks);

View file

@ -49,7 +49,9 @@ import reborncore.mixin.ifaces.ServerPlayerEntityScreenHandler;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.*; import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.function.Supplier;
public class BuiltScreenHandler extends ScreenHandler { public class BuiltScreenHandler extends ScreenHandler {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogManager.getLogger();

View file

@ -30,7 +30,6 @@ import net.fabricmc.api.Environment;
import net.minecraft.client.texture.SpriteAtlasTexture; import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.inventory.Inventory; import net.minecraft.inventory.Inventory;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class SpriteSlot extends FilteredSlot { public class SpriteSlot extends FilteredSlot {

View file

@ -39,10 +39,9 @@ public class UpgradeSlot extends BaseSlot {
@Override @Override
public boolean canInsert(final ItemStack stack) { public boolean canInsert(final ItemStack stack) {
if (!(stack.getItem() instanceof IUpgrade)) { if (!(stack.getItem() instanceof IUpgrade upgrade)) {
return false; return false;
} }
IUpgrade upgrade = (IUpgrade) stack.getItem();
IUpgradeable upgradeable = null; IUpgradeable upgradeable = null;
RebornInventory inv = (RebornInventory) inventory; RebornInventory inv = (RebornInventory) inventory;
BlockEntity blockEntity = inv.getBlockEntity(); BlockEntity blockEntity = inv.getBlockEntity();

View file

@ -27,7 +27,6 @@ package reborncore.common;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider; import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlastFurnaceBlockEntity;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker; import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;

View file

@ -34,12 +34,12 @@ import com.mojang.brigadier.suggestion.SuggestionProvider;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback; import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.command.CommandSource;
import net.minecraft.command.argument.EntityArgumentType; import net.minecraft.command.argument.EntityArgumentType;
import net.minecraft.command.argument.ItemStackArgumentType; import net.minecraft.command.argument.ItemStackArgumentType;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.CommandManager;
import net.minecraft.command.CommandSource;
import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerChunkManager; import net.minecraft.server.world.ServerChunkManager;

View file

@ -28,11 +28,11 @@ import net.minecraft.block.entity.BlockEntity;
import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import org.jetbrains.annotations.NotNull;
import reborncore.common.fluid.FluidUtil; import reborncore.common.fluid.FluidUtil;
import reborncore.common.util.NBTSerializable; import reborncore.common.util.NBTSerializable;
import reborncore.common.util.Tank; import reborncore.common.util.Tank;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;

View file

@ -27,8 +27,8 @@ package reborncore.common.blockentity;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventory; import net.minecraft.inventory.Inventory;
@ -36,16 +36,15 @@ import net.minecraft.inventory.SidedInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.Formatting; import net.minecraft.util.Formatting;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import reborncore.api.IListInfoProvider; import reborncore.api.IListInfoProvider;
import reborncore.api.blockentity.IUpgrade; import reborncore.api.blockentity.IUpgrade;
import reborncore.api.blockentity.IUpgradeable; import reborncore.api.blockentity.IUpgradeable;
@ -60,8 +59,6 @@ import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.util.RebornInventory; import reborncore.common.util.RebornInventory;
import reborncore.common.util.Tank; import reborncore.common.util.Tank;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
@ -210,8 +207,7 @@ public class MachineBaseBlockEntity extends BlockEntity implements BlockEntityTi
} }
public Optional<RebornInventory<?>> getOptionalInventory() { public Optional<RebornInventory<?>> getOptionalInventory() {
if (this instanceof InventoryProvider) { if (this instanceof InventoryProvider inventory) {
InventoryProvider inventory = (InventoryProvider) this;
if (inventory.getInventory() == null) { if (inventory.getInventory() == null) {
return Optional.empty(); return Optional.empty();
} }
@ -221,8 +217,7 @@ public class MachineBaseBlockEntity extends BlockEntity implements BlockEntityTi
} }
protected Optional<RecipeCrafter> getOptionalCrafter() { protected Optional<RecipeCrafter> getOptionalCrafter() {
if (this instanceof IRecipeCrafterProvider) { if (this instanceof IRecipeCrafterProvider crafterProvider) {
IRecipeCrafterProvider crafterProvider = (IRecipeCrafterProvider) this;
if (crafterProvider.getRecipeCrafter() == null) { if (crafterProvider.getRecipeCrafter() == null) {
return Optional.empty(); return Optional.empty();
} }

View file

@ -26,12 +26,14 @@ package reborncore.common.blockentity;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.FluidBlock; import net.minecraft.block.FluidBlock;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.*; import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.RenderLayers;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.BlockRenderManager; import net.minecraft.client.render.block.BlockRenderManager;
import net.minecraft.client.render.model.json.ModelTransformation; import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
@ -195,12 +197,7 @@ public interface MultiblockWriter {
/** /**
* A writer which prints the hologram to {@link System#out} * A writer which prints the hologram to {@link System#out}
*/ */
class DebugWriter implements MultiblockWriter { record DebugWriter(MultiblockWriter writer) implements MultiblockWriter {
private final MultiblockWriter writer;
public DebugWriter(MultiblockWriter writer) {
this.writer = writer;
}
@Override @Override
public MultiblockWriter add(int x, int y, int z, BiPredicate<BlockView, BlockPos> predicate, BlockState state) { public MultiblockWriter add(int x, int y, int z, BiPredicate<BlockView, BlockPos> predicate, BlockState state) {
@ -246,21 +243,9 @@ public interface MultiblockWriter {
* Renders a hologram * Renders a hologram
*/ */
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
class HologramRenderer implements MultiblockWriter { record HologramRenderer(BlockRenderView view, MatrixStack matrix, VertexConsumerProvider vertexConsumerProvider, float scale) implements MultiblockWriter {
private static final BlockPos OUT_OF_WORLD_POS = new BlockPos(0, 260, 0); // Bad hack; disables lighting private static final BlockPos OUT_OF_WORLD_POS = new BlockPos(0, 260, 0); // Bad hack; disables lighting
private final BlockRenderView view;
private final MatrixStack matrix;
private final VertexConsumerProvider vertexConsumerProvider;
private final float scale;
public HologramRenderer(BlockRenderView view, MatrixStack matrix, VertexConsumerProvider vertexConsumerProvider, float scale) {
this.view = view;
this.matrix = matrix;
this.vertexConsumerProvider = vertexConsumerProvider;
this.scale = scale;
}
@Override @Override
public MultiblockWriter add(int x, int y, int z, BiPredicate<BlockView, BlockPos> predicate, BlockState state) { public MultiblockWriter add(int x, int y, int z, BiPredicate<BlockView, BlockPos> predicate, BlockState state) {
final BlockRenderManager blockRenderManager = MinecraftClient.getInstance().getBlockRenderManager(); final BlockRenderManager blockRenderManager = MinecraftClient.getInstance().getBlockRenderManager();

View file

@ -31,12 +31,12 @@ import net.minecraft.nbt.NbtCompound;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.NotNull;
import reborncore.api.recipe.IRecipeCrafterProvider; import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.client.screen.builder.Syncable; import reborncore.client.screen.builder.Syncable;
import reborncore.common.util.BooleanFunction; import reborncore.common.util.BooleanFunction;
import reborncore.common.util.NBTSerializable; import reborncore.common.util.NBTSerializable;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;

View file

@ -27,7 +27,6 @@ package reborncore.common.blockentity;
import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.CommandSyntaxException;
import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.ints.IntLists;
import net.minecraft.inventory.Inventory; import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.SidedInventory; import net.minecraft.inventory.SidedInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -35,14 +34,14 @@ import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.StringNbtReader; import net.minecraft.nbt.StringNbtReader;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import reborncore.RebornCore; import reborncore.RebornCore;
import reborncore.api.items.InventoryUtils; import reborncore.api.items.InventoryUtils;
import reborncore.common.util.ItemUtils; import reborncore.common.util.ItemUtils;
import reborncore.common.util.NBTSerializable; import reborncore.common.util.NBTSerializable;
import reborncore.common.util.RebornInventory; import reborncore.common.util.RebornInventory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;

View file

@ -44,7 +44,6 @@ import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldAccess; import net.minecraft.world.WorldAccess;
import reborncore.api.ToolManager; import reborncore.api.ToolManager;
@ -195,8 +194,7 @@ public abstract class BlockMachineBase extends BaseBlockEntityProvider implement
if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, hitResult.getSide())) { if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, hitResult.getSide())) {
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} }
} else if (stack.getItem() instanceof IUpgrade && blockEntity instanceof IUpgradeable) { } else if (stack.getItem() instanceof IUpgrade && blockEntity instanceof IUpgradeable upgradeableEntity) {
IUpgradeable upgradeableEntity = (IUpgradeable) blockEntity;
if (upgradeableEntity.canBeUpgraded()) { if (upgradeableEntity.canBeUpgraded()) {
if (InventoryUtils.insertItemStacked(upgradeableEntity.getUpgradeInvetory(), stack, if (InventoryUtils.insertItemStacked(upgradeableEntity.getUpgradeInvetory(), stack,
true).getCount() > 0) { true).getCount() > 0) {

View file

@ -35,12 +35,9 @@ import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryKey; import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.PersistentState; import net.minecraft.world.PersistentState;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.dimension.DimensionType;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import reborncore.common.network.ClientBoundPackets; import reborncore.common.network.ClientBoundPackets;

View file

@ -24,18 +24,17 @@
package reborncore.common.crafting; package reborncore.common.crafting;
import java.util.HashMap;
import java.util.function.Function;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.tag.ItemTags; import net.minecraft.tag.ItemTags;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.SimpleRegistry; import net.minecraft.util.registry.SimpleRegistry;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import net.fabricmc.loader.api.FabricLoader; import java.util.HashMap;
import java.util.function.Function;
public final class ConditionManager { public final class ConditionManager {

View file

@ -30,15 +30,14 @@ import net.minecraft.fluid.Fluid;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.JsonHelper; import net.minecraft.util.JsonHelper;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import org.jetbrains.annotations.NotNull;
import reborncore.common.crafting.ingredient.RebornIngredient; import reborncore.common.crafting.ingredient.RebornIngredient;
import reborncore.common.fluid.FluidValue; import reborncore.common.fluid.FluidValue;
import reborncore.common.fluid.container.FluidInstance; import reborncore.common.fluid.container.FluidInstance;
import net.minecraft.util.collection.DefaultedList;
import reborncore.common.util.Tank; import reborncore.common.util.Tank;
import org.jetbrains.annotations.NotNull;
public abstract class RebornFluidRecipe extends RebornRecipe { public abstract class RebornFluidRecipe extends RebornRecipe {
@NotNull @NotNull

View file

@ -38,34 +38,27 @@ import reborncore.common.util.serialization.SerializationUtil;
import java.util.List; import java.util.List;
import java.util.function.BiFunction; import java.util.function.BiFunction;
public class RebornRecipeType<R extends RebornRecipe> implements RecipeType, RecipeSerializer { public record RebornRecipeType<R extends RebornRecipe>(
BiFunction<RebornRecipeType<R>, Identifier, R> recipeFunction,
private final BiFunction<RebornRecipeType<R>, Identifier, R> recipeFunction; Identifier name) implements RecipeType, RecipeSerializer {
private final Identifier typeId;
public RebornRecipeType(BiFunction<RebornRecipeType<R>, Identifier, R> recipeFunction, Identifier typeId) {
this.recipeFunction = recipeFunction;
this.typeId = typeId;
}
@Override @Override
public R read(Identifier recipeId, JsonObject json) { public R read(Identifier recipeId, JsonObject json) {
Identifier type = new Identifier(JsonHelper.getString(json, "type")); Identifier type = new Identifier(JsonHelper.getString(json, "type"));
if (!type.equals(typeId)) { if (!type.equals(name)) {
throw new RuntimeException("RebornRecipe type not supported!"); throw new RuntimeException("RebornRecipe type not supported!");
} }
R recipe = newRecipe(recipeId); R recipe = newRecipe(recipeId);
try{ try {
if(!ConditionManager.shouldLoadRecipe(json)) { if (!ConditionManager.shouldLoadRecipe(json)) {
recipe.makeDummy(); recipe.makeDummy();
return recipe; return recipe;
} }
recipe.deserialize(json); recipe.deserialize(json);
} catch (Throwable t){ } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();
RebornCore.LOGGER.error("Failed to read recipe: " + recipeId); RebornCore.LOGGER.error("Failed to read recipe: " + recipeId);
} }
@ -75,7 +68,7 @@ public class RebornRecipeType<R extends RebornRecipe> implements RecipeType, Rec
public JsonObject toJson(R recipe) { public JsonObject toJson(R recipe) {
JsonObject jsonObject = new JsonObject(); JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("type", typeId.toString()); jsonObject.addProperty("type", name.toString());
recipe.serialize(jsonObject); recipe.serialize(jsonObject);
@ -107,12 +100,7 @@ public class RebornRecipeType<R extends RebornRecipe> implements RecipeType, Rec
((R) recipe).serialize(buffer); ((R) recipe).serialize(buffer);
} }
public Identifier getName() {
return typeId;
}
public List<R> getRecipes(World world) { public List<R> getRecipes(World world) {
return RecipeUtils.getRecipes(world, this); return RecipeUtils.getRecipes(world, this);
} }
} }

View file

@ -65,7 +65,7 @@ public class RecipeManager {
} }
public static List<RebornRecipeType> getRecipeTypes(String namespace) { public static List<RebornRecipeType> getRecipeTypes(String namespace) {
return recipeTypes.values().stream().filter(rebornRecipeType -> rebornRecipeType.getName().getNamespace().equals(namespace)).collect(Collectors.toList()); return recipeTypes.values().stream().filter(rebornRecipeType -> rebornRecipeType.name().getNamespace().equals(namespace)).collect(Collectors.toList());
} }
public static void validateRecipes(World world) { public static void validateRecipes(World world) {

View file

@ -29,8 +29,8 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParseException; import com.google.gson.JsonParseException;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.JsonHelper; import net.minecraft.util.JsonHelper;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.HashMap; import java.util.HashMap;
import java.util.function.Function; import java.util.function.Function;

View file

@ -26,20 +26,15 @@ package reborncore.common.crafting.ingredient;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonSyntaxException;
import net.minecraft.client.MinecraftClient;
import net.minecraft.data.server.ItemTagsProvider;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.Ingredient;
import net.minecraft.tag.RequiredTagList;
import net.minecraft.tag.RequiredTagListRegistry;
import net.minecraft.tag.ServerTagManagerHolder; import net.minecraft.tag.ServerTagManagerHolder;
import net.minecraft.tag.Tag; import net.minecraft.tag.Tag;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.JsonHelper; import net.minecraft.util.JsonHelper;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryKey;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import java.util.ArrayList; import java.util.ArrayList;

View file

@ -32,10 +32,10 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion; import net.minecraft.world.explosion.Explosion;
import org.apache.commons.lang3.time.StopWatch; import org.apache.commons.lang3.time.StopWatch;
import reborncore.RebornCore;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import reborncore.RebornCore;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -31,11 +31,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import reborncore.common.fluid.container.FluidInstance; import reborncore.common.fluid.container.FluidInstance;
import reborncore.common.util.Tank; import reborncore.common.util.Tank;
import org.jetbrains.annotations.NotNull;
public class FluidUtil { public class FluidUtil {

View file

@ -26,10 +26,9 @@ package reborncore.common.fluid.container;
import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluid;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import reborncore.common.fluid.FluidValue;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import reborncore.common.fluid.FluidValue;
/* /*

View file

@ -28,40 +28,24 @@ import net.minecraft.util.math.Direction;
public class Functions { public class Functions {
public static int getIntDirFromDirection(Direction dir) { public static int getIntDirFromDirection(Direction dir) {
switch (dir) { return switch (dir) {
case DOWN: case DOWN -> 0;
return 0; case EAST -> 5;
case EAST: case NORTH -> 2;
return 5; case SOUTH -> 3;
case NORTH: case UP -> 1;
return 2; case WEST -> 4;
case SOUTH: };
return 3;
case UP:
return 1;
case WEST:
return 4;
default:
return 0;
}
} }
public static Direction getDirectionFromInt(int dir) { public static Direction getDirectionFromInt(int dir) {
int metaDataToSet = 0; int metaDataToSet = switch (dir) {
switch (dir) { case 0 -> 2;
case 0: case 1 -> 4;
metaDataToSet = 2; case 2 -> 3;
break; case 3 -> 5;
case 1: default -> 0;
metaDataToSet = 4; };
break;
case 2:
metaDataToSet = 3;
break;
case 3:
metaDataToSet = 5;
break;
}
return Direction.byId(metaDataToSet); return Direction.byId(metaDataToSet);
} }
} }

View file

@ -28,8 +28,8 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.Set; import java.util.Set;
public interface MultiBlockBreakingTool { public interface MultiBlockBreakingTool {

View file

@ -26,10 +26,10 @@ package reborncore.common.multiblock;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import reborncore.RebornCore; import reborncore.RebornCore;
@ -79,7 +79,7 @@ public abstract class MultiblockBlockEntityBase extends IMultiblockPart implemen
} }
if (controllers == null) { if (controllers == null) {
controllers = new HashSet<MultiblockControllerBase>(); controllers = new HashSet<>();
bestController = candidate; bestController = candidate;
} else if (!controllers.contains(candidate) && candidate.shouldConsume(bestController)) { } else if (!controllers.contains(candidate) && candidate.shouldConsume(bestController)) {
bestController = candidate; bestController = candidate;
@ -313,7 +313,7 @@ public abstract class MultiblockBlockEntityBase extends IMultiblockPart implemen
@Override @Override
public IMultiblockPart[] getNeighboringParts() { public IMultiblockPart[] getNeighboringParts() {
BlockEntity te; BlockEntity te;
List<IMultiblockPart> neighborParts = new ArrayList<IMultiblockPart>(); List<IMultiblockPart> neighborParts = new ArrayList<>();
BlockPos neighborPosition, partPosition = this.getWorldLocation(); BlockPos neighborPosition, partPosition = this.getWorldLocation();
for (Direction facing : Direction.values()) { for (Direction facing : Direction.values()) {
@ -326,7 +326,7 @@ public abstract class MultiblockBlockEntityBase extends IMultiblockPart implemen
} }
} }
return neighborParts.toArray(new IMultiblockPart[neighborParts.size()]); return neighborParts.toArray(new IMultiblockPart[0]);
} }
@Override @Override

View file

@ -98,7 +98,7 @@ public abstract class MultiblockControllerBase {
protected MultiblockControllerBase(World world) { protected MultiblockControllerBase(World world) {
// Multiblock stuff // Multiblock stuff
worldObj = world; worldObj = world;
connectedParts = new HashSet<IMultiblockPart>(); connectedParts = new HashSet<>();
referenceCoord = null; referenceCoord = null;
assemblyState = AssemblyState.Disassembled; assemblyState = AssemblyState.Disassembled;
@ -178,7 +178,7 @@ public abstract class MultiblockControllerBase {
part.forfeitMultiblockSaveDelegate(); part.forfeitMultiblockSaveDelegate();
} }
Boolean updateRequired = false; boolean updateRequired = false;
BlockPos partPos = part.getPos(); BlockPos partPos = part.getPos();
if (minimumCoord != null) { if (minimumCoord != null) {
@ -467,7 +467,7 @@ public abstract class MultiblockControllerBase {
"The controller with the lowest minimum-coord value must consume the one with the higher coords"); "The controller with the lowest minimum-coord value must consume the one with the higher coords");
} }
Set<IMultiblockPart> partsToAcquire = new HashSet<IMultiblockPart>(other.connectedParts); Set<IMultiblockPart> partsToAcquire = new HashSet<>(other.connectedParts);
// releases all blocks and references gently so they can be incorporated into another multiblock // releases all blocks and references gently so they can be incorporated into another multiblock
other._onAssimilated(this); other._onAssimilated(this);
@ -688,8 +688,8 @@ public abstract class MultiblockControllerBase {
* from the list of connected parts. * from the list of connected parts.
*/ */
public void recalculateMinMaxCoords() { public void recalculateMinMaxCoords() {
Integer minX, minY, minZ; int minX, minY, minZ;
Integer maxX, maxY, maxZ; int maxX, maxY, maxZ;
minX = minY = minZ = Integer.MAX_VALUE; minX = minY = minZ = Integer.MAX_VALUE;
maxX = maxY = maxZ = Integer.MIN_VALUE; maxX = maxY = maxZ = Integer.MIN_VALUE;
@ -845,7 +845,7 @@ public abstract class MultiblockControllerBase {
* exist in the world, they are removed. * exist in the world, they are removed.
*/ */
private void auditParts() { private void auditParts() {
HashSet<IMultiblockPart> deadParts = new HashSet<IMultiblockPart>(); HashSet<IMultiblockPart> deadParts = new HashSet<>();
for (IMultiblockPart part : connectedParts) { for (IMultiblockPart part : connectedParts) {
if (part.isInvalid() || worldObj.getBlockEntity(part.getPos()) != part) { if (part.isInvalid() || worldObj.getBlockEntity(part.getPos()) != part) {
onDetachBlock(part); onDetachBlock(part);
@ -878,7 +878,7 @@ public abstract class MultiblockControllerBase {
referenceCoord = null; referenceCoord = null;
// Reset visitations and find the minimum coordinate // Reset visitations and find the minimum coordinate
Set<IMultiblockPart> deadParts = new HashSet<IMultiblockPart>(); Set<IMultiblockPart> deadParts = new HashSet<>();
BlockPos pos; BlockPos pos;
IMultiblockPart referencePart = null; IMultiblockPart referencePart = null;
@ -926,7 +926,7 @@ public abstract class MultiblockControllerBase {
// Now visit all connected parts, breadth-first, starting from reference // Now visit all connected parts, breadth-first, starting from reference
// coord's part // coord's part
IMultiblockPart part; IMultiblockPart part;
LinkedList<IMultiblockPart> partsToCheck = new LinkedList<IMultiblockPart>(); LinkedList<IMultiblockPart> partsToCheck = new LinkedList<>();
IMultiblockPart[] nearbyParts = null; IMultiblockPart[] nearbyParts = null;
int visitedParts = 0; int visitedParts = 0;
@ -953,7 +953,7 @@ public abstract class MultiblockControllerBase {
} }
// Finally, remove all parts that remain disconnected. // Finally, remove all parts that remain disconnected.
Set<IMultiblockPart> removedParts = new HashSet<IMultiblockPart>(); Set<IMultiblockPart> removedParts = new HashSet<>();
for (IMultiblockPart orphanCandidate : connectedParts) { for (IMultiblockPart orphanCandidate : connectedParts) {
if (!orphanCandidate.isVisited()) { if (!orphanCandidate.isVisited()) {
deadParts.add(orphanCandidate); deadParts.add(orphanCandidate);
@ -988,7 +988,7 @@ public abstract class MultiblockControllerBase {
*/ */
public Set<IMultiblockPart> detachAllBlocks() { public Set<IMultiblockPart> detachAllBlocks() {
if (worldObj == null) { if (worldObj == null) {
return new HashSet<IMultiblockPart>(); return new HashSet<>();
} }
for (IMultiblockPart part : connectedParts) { for (IMultiblockPart part : connectedParts) {
@ -998,7 +998,7 @@ public abstract class MultiblockControllerBase {
} }
Set<IMultiblockPart> detachedParts = connectedParts; Set<IMultiblockPart> detachedParts = connectedParts;
connectedParts = new HashSet<IMultiblockPart>(); connectedParts = new HashSet<>();
return detachedParts; return detachedParts;
} }

View file

@ -73,14 +73,14 @@ public class MultiblockWorldRegistry {
public MultiblockWorldRegistry(final World world) { public MultiblockWorldRegistry(final World world) {
worldObj = world; worldObj = world;
controllers = new HashSet<MultiblockControllerBase>(); controllers = new HashSet<>();
deadControllers = new HashSet<MultiblockControllerBase>(); deadControllers = new HashSet<>();
dirtyControllers = new HashSet<MultiblockControllerBase>(); dirtyControllers = new HashSet<>();
detachedParts = new HashSet<IMultiblockPart>(); detachedParts = new HashSet<>();
orphanedParts = new HashSet<IMultiblockPart>(); orphanedParts = new HashSet<>();
partsAwaitingChunkLoad = new HashMap<Integer, Set<IMultiblockPart>>(); partsAwaitingChunkLoad = new HashMap<>();
partsAwaitingChunkLoadMutex = new Object(); partsAwaitingChunkLoadMutex = new Object();
orphanedPartsMutex = new Object(); orphanedPartsMutex = new Object();
} }
@ -128,7 +128,7 @@ public class MultiblockWorldRegistry {
synchronized (orphanedPartsMutex) { synchronized (orphanedPartsMutex) {
if (orphanedParts.size() > 0) { if (orphanedParts.size() > 0) {
orphansToProcess = orphanedParts; orphansToProcess = orphanedParts;
orphanedParts = new HashSet<IMultiblockPart>(); orphanedParts = new HashSet<>();
} }
} }
@ -166,7 +166,7 @@ public class MultiblockWorldRegistry {
this.controllers.add(newController); this.controllers.add(newController);
} else if (compatibleControllers.size() > 1) { } else if (compatibleControllers.size() > 1) {
if (mergePools == null) { if (mergePools == null) {
mergePools = new ArrayList<Set<MultiblockControllerBase>>(); mergePools = new ArrayList<>();
} }
// THIS IS THE ONLY PLACE WHERE MERGES ARE DETECTED // THIS IS THE ONLY PLACE WHERE MERGES ARE DETECTED
@ -174,7 +174,7 @@ public class MultiblockWorldRegistry {
// impending merge. // impending merge.
// Locate the appropriate merge pool(s) // Locate the appropriate merge pool(s)
//boolean hasAddedToPool = false; //boolean hasAddedToPool = false;
List<Set<MultiblockControllerBase>> candidatePools = new ArrayList<Set<MultiblockControllerBase>>(); List<Set<MultiblockControllerBase>> candidatePools = new ArrayList<>();
for (Set<MultiblockControllerBase> candidatePool : mergePools) { for (Set<MultiblockControllerBase> candidatePool : mergePools) {
if (!Collections.disjoint(candidatePool, compatibleControllers)) { if (!Collections.disjoint(candidatePool, compatibleControllers)) {
// They share at least one element, so that // They share at least one element, so that
@ -325,7 +325,7 @@ public class MultiblockWorldRegistry {
synchronized (partsAwaitingChunkLoadMutex) { synchronized (partsAwaitingChunkLoadMutex) {
if (!partsAwaitingChunkLoad.containsKey(chunkHash)) { if (!partsAwaitingChunkLoad.containsKey(chunkHash)) {
partSet = new HashSet<IMultiblockPart>(); partSet = new HashSet<>();
partsAwaitingChunkLoad.put(chunkHash, partSet); partsAwaitingChunkLoad.put(chunkHash, partSet);
} else { } else {
partSet = partsAwaitingChunkLoad.get(chunkHash); partSet = partsAwaitingChunkLoad.get(chunkHash);

View file

@ -28,16 +28,9 @@ public enum PartPosition {
Unknown, Interior, FrameCorner, Frame, TopFace, BottomFace, NorthFace, SouthFace, EastFace, WestFace; Unknown, Interior, FrameCorner, Frame, TopFace, BottomFace, NorthFace, SouthFace, EastFace, WestFace;
public boolean isFace(PartPosition position) { public boolean isFace(PartPosition position) {
switch (position) { return switch (position) {
case TopFace: case TopFace, BottomFace, NorthFace, SouthFace, EastFace, WestFace -> true;
case BottomFace: default -> false;
case NorthFace: };
case SouthFace:
case EastFace:
case WestFace:
return true;
default:
return false;
}
} }
} }

View file

@ -28,8 +28,8 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import reborncore.common.multiblock.MultiblockControllerBase;
import reborncore.common.multiblock.MultiblockBlockEntityBase; import reborncore.common.multiblock.MultiblockBlockEntityBase;
import reborncore.common.multiblock.MultiblockControllerBase;
import reborncore.common.multiblock.MultiblockValidationException; import reborncore.common.multiblock.MultiblockValidationException;
public abstract class RectangularMultiblockBlockEntityBase extends MultiblockBlockEntityBase { public abstract class RectangularMultiblockBlockEntityBase extends MultiblockBlockEntityBase {

View file

@ -27,21 +27,4 @@ package reborncore.common.network;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
public final class IdentifiedPacket { public record IdentifiedPacket(Identifier channel, PacketByteBuf packetByteBuf) { }
private final Identifier channel;
private final PacketByteBuf packetByteBuf;
public IdentifiedPacket(Identifier channel, PacketByteBuf packetByteBuf) {
this.channel = channel;
this.packetByteBuf = packetByteBuf;
}
public Identifier getChannel() {
return channel;
}
public PacketByteBuf getPacketByteBuf() {
return packetByteBuf;
}
}

View file

@ -64,7 +64,7 @@ public class NetworkManager {
public static void sendToServer(IdentifiedPacket packet) { public static void sendToServer(IdentifiedPacket packet) {
ClientPlayNetworking.send(packet.getChannel(), packet.getPacketByteBuf()); ClientPlayNetworking.send(packet.channel(), packet.packetByteBuf());
} }
public static void sendToAll(IdentifiedPacket packet, MinecraftServer server) { public static void sendToAll(IdentifiedPacket packet, MinecraftServer server) {
@ -86,7 +86,7 @@ public class NetworkManager {
public static void send(IdentifiedPacket packet, Collection<ServerPlayerEntity> players) { public static void send(IdentifiedPacket packet, Collection<ServerPlayerEntity> players) {
for (ServerPlayerEntity player : players) { for (ServerPlayerEntity player : players) {
ServerPlayNetworking.send(player, packet.getChannel(), packet.getPacketByteBuf()); ServerPlayNetworking.send(player, packet.channel(), packet.packetByteBuf());
} }
} }

View file

@ -180,8 +180,7 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im
* @return the calculated comparator output or 0 if {@code blockEntity} is not a {@code PowerAcceptorBlockEntity} * @return the calculated comparator output or 0 if {@code blockEntity} is not a {@code PowerAcceptorBlockEntity}
*/ */
public static int calculateComparatorOutputFromEnergy(@Nullable BlockEntity blockEntity) { public static int calculateComparatorOutputFromEnergy(@Nullable BlockEntity blockEntity) {
if (blockEntity instanceof PowerAcceptorBlockEntity) { if (blockEntity instanceof PowerAcceptorBlockEntity storage) {
PowerAcceptorBlockEntity storage = (PowerAcceptorBlockEntity) blockEntity;
return MathHelper.ceil(storage.getStored(EnergySide.UNKNOWN) * 15.0 / storage.getMaxStoredPower()); return MathHelper.ceil(storage.getStored(EnergySide.UNKNOWN) * 15.0 / storage.getMaxStoredPower());
} else { } else {
return 0; return 0;

View file

@ -29,6 +29,7 @@ import net.minecraft.block.entity.BlockEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import org.jetbrains.annotations.Nullable;
import reborncore.RebornCore; import reborncore.RebornCore;
import reborncore.api.recipe.IRecipeCrafterProvider; import reborncore.api.recipe.IRecipeCrafterProvider;
import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.BlockMachineBase;
@ -41,7 +42,6 @@ import team.reborn.energy.Energy;
import team.reborn.energy.EnergySide; import team.reborn.energy.EnergySide;
import team.reborn.energy.EnergyStorage; import team.reborn.energy.EnergyStorage;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Optional; import java.util.Optional;
@ -336,8 +336,7 @@ public class RecipeCrafter implements IUpgradeHandler {
BlockPos pos = blockEntity.getPos(); BlockPos pos = blockEntity.getPos();
if (blockEntity.getWorld() == null) return; if (blockEntity.getWorld() == null) return;
BlockState oldState = blockEntity.getWorld().getBlockState(pos); BlockState oldState = blockEntity.getWorld().getBlockState(pos);
if (oldState.getBlock() instanceof BlockMachineBase) { if (oldState.getBlock() instanceof BlockMachineBase blockMachineBase) {
BlockMachineBase blockMachineBase = (BlockMachineBase) oldState.getBlock();
boolean isActive = isActive() || canCraftAgain(); boolean isActive = isActive() || canCraftAgain();
if (isActive == oldState.get(BlockMachineBase.ACTIVE)) { if (isActive == oldState.get(BlockMachineBase.ACTIVE)) {

View file

@ -1,49 +0,0 @@
/*
* This file is part of RebornCore, licensed under the MIT License (MIT).
*
* Copyright (c) 2021 TeamReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package reborncore.common.util;
import java.util.Collection;
import java.util.Locale;
/**
* Created by covers1624 on 3/27/2016.
*/
public class ArrayUtils {
public static String[] arrayToLowercase(String[] array) {
String[] copy = new String[array.length];
for (int i = 0; i < array.length; i++) {
copy[i] = array[i].toLowerCase(Locale.ROOT).intern();
}
return copy;
}
public static <E> Collection<E> addAll(Collection<E> dest, Collection<? extends E>... src) {
for (Collection<? extends E> c : src) {
dest.addAll(c);
}
return dest;
}
}

View file

@ -27,42 +27,4 @@ package reborncore.common.util;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Objects; public record IdentifiableObject<T>(@NotNull T object, @NotNull Identifier identifier) { }
public class IdentifiableObject<T> {
@NotNull
private final T object;
@NotNull
private final Identifier identifier;
public IdentifiableObject(@NotNull T object, @NotNull Identifier identifier) {
Objects.requireNonNull(object);
Objects.requireNonNull(identifier);
this.object = object;
this.identifier = identifier;
}
@NotNull
public T getObject() {
return object;
}
@NotNull
public Identifier getIdentifier() {
return identifier;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
IdentifiableObject<?> that = (IdentifiableObject<?>) o;
return object.equals(that.object) &&
identifier.equals(that.identifier);
}
@Override
public int hashCode() {
return Objects.hash(object, identifier);
}
}

View file

@ -27,9 +27,9 @@ package reborncore.common.util;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import org.jetbrains.annotations.NotNull;
import reborncore.api.items.InventoryBase; import reborncore.api.items.InventoryBase;
import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;

View file

@ -41,8 +41,7 @@ public class ItemHandlerUtils {
if (blockEntity == null) { if (blockEntity == null) {
return; return;
} }
if (blockEntity instanceof Inventory) { if (blockEntity instanceof Inventory inventory) {
Inventory inventory = (Inventory) blockEntity;
dropItemHandler(world, pos, inventory); dropItemHandler(world, pos, inventory);
} }
if (blockEntity instanceof IUpgradeable) { if (blockEntity instanceof IUpgradeable) {

View file

@ -30,7 +30,6 @@ import net.minecraft.item.ItemUsageContext;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class ItemUsageContextCustomStack extends ItemUsageContext { public class ItemUsageContextCustomStack extends ItemUsageContext {

View file

@ -28,12 +28,11 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import org.jetbrains.annotations.NotNull;
import reborncore.api.items.InventoryBase; import reborncore.api.items.InventoryBase;
import reborncore.common.blockentity.MachineBaseBlockEntity; import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.blockentity.SlotConfiguration; import reborncore.common.blockentity.SlotConfiguration;
import org.jetbrains.annotations.NotNull;
public class RebornInventory<T extends MachineBaseBlockEntity> extends InventoryBase { public class RebornInventory<T extends MachineBaseBlockEntity> extends InventoryBase {
private final String name; private final String name;
@ -56,13 +55,10 @@ public class RebornInventory<T extends MachineBaseBlockEntity> extends Inventory
if (facing == null) { if (facing == null) {
return true; return true;
} }
switch (direction) { return switch (direction) {
case INSERT: case INSERT -> SlotConfiguration.canInsertItem(slotID, stack, facing, be);
return SlotConfiguration.canInsertItem(slotID, stack, facing, be); case EXTRACT -> SlotConfiguration.canExtractItem(slotID, stack, facing, be);
case EXTRACT: };
return SlotConfiguration.canExtractItem(slotID, stack, facing, be);
}
return false;
}); });
} }

View file

@ -32,14 +32,14 @@ import net.minecraft.util.math.Direction;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import reborncore.client.screen.builder.Syncable; import reborncore.client.screen.builder.Syncable;
import reborncore.common.blockentity.MachineBaseBlockEntity; import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.fluid.FluidValue; import reborncore.common.fluid.FluidValue;
import reborncore.common.fluid.container.FluidInstance; import reborncore.common.fluid.container.FluidInstance;
import reborncore.common.fluid.container.GenericFluidContainer; import reborncore.common.fluid.container.GenericFluidContainer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List; import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Supplier; import java.util.function.Supplier;

View file

@ -29,7 +29,6 @@ import com.google.gson.reflect.TypeToken;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
@ -113,7 +112,7 @@ public class TranslationTools {
System.out.println(key); System.out.println(key);
System.out.println(); System.out.println();
for (int i = 0; i < newKeys.size(); i++) { for (int i = 0; i < newKeys.size(); i++) {
System.out.println(String.format("%d) %s", i, newKeys.get(i))); System.out.printf("%d) %s%n", i, newKeys.get(i));
} }
System.out.print("Input selection:"); System.out.print("Input selection:");
int input = SCANNER.nextInt(); int input = SCANNER.nextInt();
@ -129,7 +128,7 @@ public class TranslationTools {
private static Map<String, String> readJsonFile(Path path) throws IOException { private static Map<String, String> readJsonFile(Path path) throws IOException {
Type mapType = new TypeToken<Map<String, String>>() { Type mapType = new TypeToken<Map<String, String>>() {
}.getType(); }.getType();
return new Gson().fromJson(new String(Files.readAllBytes(path), StandardCharsets.UTF_8), mapType); return new Gson().fromJson(Files.readString(path), mapType);
} }
private static Map<String, String> readLangFile(Path path) throws IOException { private static Map<String, String> readLangFile(Path path) throws IOException {

View file

@ -30,6 +30,7 @@ import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator; import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.item.ItemRenderer; import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
@ -37,8 +38,6 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import reborncore.common.util.ItemDurabilityExtensions; import reborncore.common.util.ItemDurabilityExtensions;
import org.jetbrains.annotations.Nullable;
//Not too happy with this, need to find and get a better solution into fabric soon //Not too happy with this, need to find and get a better solution into fabric soon
@Mixin(ItemRenderer.class) @Mixin(ItemRenderer.class)
public abstract class MixinItemRenderer { public abstract class MixinItemRenderer {
@ -48,8 +47,7 @@ public abstract class MixinItemRenderer {
@Inject(method = "renderGuiItemOverlay(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V", at = @At("HEAD")) @Inject(method = "renderGuiItemOverlay(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V", at = @At("HEAD"))
private void renderGuiItemOverlay(TextRenderer textRenderer, ItemStack stack, int x, int y, @Nullable String string, CallbackInfo info) { private void renderGuiItemOverlay(TextRenderer textRenderer, ItemStack stack, int x, int y, @Nullable String string, CallbackInfo info) {
if (stack.getItem() instanceof ItemDurabilityExtensions) { if (stack.getItem() instanceof ItemDurabilityExtensions durabilityExtensions) {
ItemDurabilityExtensions durabilityExtensions = (ItemDurabilityExtensions) stack.getItem();
if (!durabilityExtensions.showDurability(stack)) { if (!durabilityExtensions.showDurability(stack)) {
return; return;
} }

View file

@ -33,7 +33,7 @@ import net.minecraft.client.render.WorldRenderer;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.world.ClientWorld; import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;; import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes; import net.minecraft.util.shape.VoxelShapes;
@ -49,6 +49,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
;
@Mixin(WorldRenderer.class) @Mixin(WorldRenderer.class)
public abstract class MixinWorldRenderer { public abstract class MixinWorldRenderer {

View file

@ -47,8 +47,7 @@ public abstract class MixinItemStack {
@Inject(method = "getAttributeModifiers", at = @At("RETURN"), cancellable = true) @Inject(method = "getAttributeModifiers", at = @At("RETURN"), cancellable = true)
private void getAttributeModifiers(EquipmentSlot equipmentSlot, CallbackInfoReturnable<Multimap<EntityAttribute, EntityAttributeModifier>> info) { private void getAttributeModifiers(EquipmentSlot equipmentSlot, CallbackInfoReturnable<Multimap<EntityAttribute, EntityAttributeModifier>> info) {
if (getItem() instanceof ItemStackModifiers) { if (getItem() instanceof ItemStackModifiers item) {
ItemStackModifiers item = (ItemStackModifiers) getItem();
Multimap<EntityAttribute, EntityAttributeModifier> modifierHashMap = ArrayListMultimap.create(info.getReturnValue()); Multimap<EntityAttribute, EntityAttributeModifier> modifierHashMap = ArrayListMultimap.create(info.getReturnValue());
item.getAttributeModifiers(equipmentSlot, (ItemStack) (Object) this, modifierHashMap); item.getAttributeModifiers(equipmentSlot, (ItemStack) (Object) this, modifierHashMap);
info.setReturnValue(ImmutableMultimap.copyOf(modifierHashMap)); info.setReturnValue(ImmutableMultimap.copyOf(modifierHashMap));

View file

@ -35,8 +35,8 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import reborncore.api.items.ArmorRemoveHandler;
import reborncore.api.items.ArmorBlockEntityTicker; import reborncore.api.items.ArmorBlockEntityTicker;
import reborncore.api.items.ArmorRemoveHandler;
import reborncore.common.util.ItemUtils; import reborncore.common.util.ItemUtils;
@Mixin(PlayerEntity.class) @Mixin(PlayerEntity.class)

View file

@ -74,7 +74,7 @@ public class TechReborn implements ModInitializer {
// Done to force the class to load // Done to force the class to load
//noinspection ResultOfMethodCallIgnored //noinspection ResultOfMethodCallIgnored
ModRecipes.GRINDER.getName(); ModRecipes.GRINDER.name();
ClientboundPackets.init(); ClientboundPackets.init();
ServerboundPackets.init(); ServerboundPackets.init();

View file

@ -30,7 +30,6 @@ import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry; import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry;
import net.fabricmc.fabric.api.client.rendereregistry.v1.BlockEntityRendererRegistry; import net.fabricmc.fabric.api.client.rendereregistry.v1.BlockEntityRendererRegistry;
import net.fabricmc.fabric.api.renderer.v1.RendererAccess; import net.fabricmc.fabric.api.renderer.v1.RendererAccess;
import net.minecraft.client.item.ModelPredicateProvider;
import net.minecraft.client.item.UnclampedModelPredicateProvider; import net.minecraft.client.item.UnclampedModelPredicateProvider;
import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.model.BakedModel; import net.minecraft.client.render.model.BakedModel;
@ -49,6 +48,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import org.jetbrains.annotations.Nullable;
import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.builder.GuiBase;
import reborncore.client.multiblock.MultiblockRenderer; import reborncore.client.multiblock.MultiblockRenderer;
import reborncore.common.util.ItemUtils; import reborncore.common.util.ItemUtils;
@ -70,7 +70,6 @@ import techreborn.items.armor.BatpackItem;
import techreborn.items.tool.ChainsawItem; import techreborn.items.tool.ChainsawItem;
import techreborn.items.tool.industrial.NanosaberItem; import techreborn.items.tool.industrial.NanosaberItem;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;

View file

@ -28,45 +28,13 @@ package techreborn.api.generator;
import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluid;
import techreborn.utils.FluidUtils; import techreborn.utils.FluidUtils;
public class FluidGeneratorRecipe { public record FluidGeneratorRecipe(Fluid fluid, int energyPerMb,
private final EFluidGenerator generatorType; EFluidGenerator generatorType) {
private final Fluid fluid;
private final int energyPerMb;
public FluidGeneratorRecipe(Fluid fluid, int energyPerMb, EFluidGenerator generatorType) {
this.fluid = fluid;
this.energyPerMb = energyPerMb;
this.generatorType = generatorType;
}
public Fluid getFluid() {
return fluid;
}
public int getEnergyPerBucket() { public int getEnergyPerBucket() {
return energyPerMb * 1000; return energyPerMb * 1000;
} }
public EFluidGenerator getGeneratorType() {
return generatorType;
}
@Override
public String toString() {
return "FluidGeneratorRecipe [generatorType=" + generatorType + ", fluid=" + fluid + ", energyPerMb="
+ energyPerMb + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + energyPerMb;
result = prime * result + ((fluid == null) ? 0 : fluid.hashCode());
result = prime * result + ((generatorType == null) ? 0 : generatorType.hashCode());
return result;
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) if (this == obj)

View file

@ -39,7 +39,7 @@ public class FluidGeneratorRecipeList {
} }
public boolean addRecipe(FluidGeneratorRecipe fluidGeneratorRecipe) { public boolean addRecipe(FluidGeneratorRecipe fluidGeneratorRecipe) {
if (!this.getRecipeForFluid(fluidGeneratorRecipe.getFluid()).isPresent()) if (!this.getRecipeForFluid(fluidGeneratorRecipe.fluid()).isPresent())
return this.getRecipes().add(fluidGeneratorRecipe); return this.getRecipes().add(fluidGeneratorRecipe);
return false; return false;
} }
@ -49,7 +49,7 @@ public class FluidGeneratorRecipeList {
} }
public Optional<FluidGeneratorRecipe> getRecipeForFluid(Fluid fluid) { public Optional<FluidGeneratorRecipe> getRecipeForFluid(Fluid fluid) {
return this.recipes.stream().filter(recipe -> FluidUtils.fluidEquals(recipe.getFluid(), fluid)).findAny(); return this.recipes.stream().filter(recipe -> FluidUtils.fluidEquals(recipe.fluid(), fluid)).findAny();
} }
public HashSet<FluidGeneratorRecipe> getRecipes() { public HashSet<FluidGeneratorRecipe> getRecipes() {

View file

@ -66,8 +66,7 @@ public class BlastFurnaceRecipe extends RebornRecipe {
@Override @Override
public boolean canCraft(final BlockEntity blockEntity) { public boolean canCraft(final BlockEntity blockEntity) {
if (blockEntity instanceof IndustrialBlastFurnaceBlockEntity) { if (blockEntity instanceof final IndustrialBlastFurnaceBlockEntity blastFurnace) {
final IndustrialBlastFurnaceBlockEntity blastFurnace = (IndustrialBlastFurnaceBlockEntity) blockEntity;
return blastFurnace.getHeat() >= heat; return blastFurnace.getHeat() >= heat;
} }
return false; return false;

View file

@ -73,8 +73,7 @@ public class FusionReactorRecipe extends RebornRecipe {
@Override @Override
public boolean canCraft(final BlockEntity blockEntity) { public boolean canCraft(final BlockEntity blockEntity) {
if (blockEntity instanceof FusionControlComputerBlockEntity) { if (blockEntity instanceof final FusionControlComputerBlockEntity reactor) {
final FusionControlComputerBlockEntity reactor = (FusionControlComputerBlockEntity) blockEntity;
return reactor.getSize() >= minSize; return reactor.getSize() >= minSize;
} }
return false; return false;

View file

@ -27,6 +27,7 @@ package techreborn.blockentity.cable;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
@ -36,7 +37,6 @@ import net.minecraft.text.LiteralText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting; import net.minecraft.util.Formatting;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -180,9 +180,7 @@ public class CableBlockEntity extends BlockEntity
continue; continue;
} }
if (blockEntity instanceof CableBlockEntity) { if (blockEntity instanceof CableBlockEntity cableBlockEntity) {
CableBlockEntity cableBlockEntity = (CableBlockEntity) blockEntity;
if (cableBlockEntity.getTier() != this.getTier()) { if (cableBlockEntity.getTier() != this.getTier()) {
continue; continue;
} }

View file

@ -138,19 +138,19 @@ public class DataDrivenBEProvider extends BlockEntityType<DataDrivenBEProvider.D
} }
private int getEnergySlot() { private int getEnergySlot() {
return slots.stream().filter(slot -> slot.getType() == SlotType.ENERGY).findFirst().orElse(null).getId(); return slots.stream().filter(slot -> slot.type() == SlotType.ENERGY).findFirst().orElse(null).id();
} }
private int countOfSlotType(SlotType type) { private int countOfSlotType(SlotType type) {
return (int) slots.stream() return (int) slots.stream()
.filter(slot -> slot.getType() == type) .filter(slot -> slot.type() == type)
.count(); .count();
} }
private int[] slotIds(SlotType type) { private int[] slotIds(SlotType type) {
return slots.stream() return slots.stream()
.filter(slot -> slot.getType() == type) .filter(slot -> slot.type() == type)
.mapToInt(DataDrivenSlot::getId) .mapToInt(DataDrivenSlot::id)
.toArray(); .toArray();
} }

View file

@ -30,7 +30,7 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.JsonHelper; import net.minecraft.util.JsonHelper;
import org.apache.commons.lang3.Validate; import org.jetbrains.annotations.NotNull;
import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.builder.GuiBase;
import reborncore.client.screen.builder.BlockEntityScreenHandlerBuilder; import reborncore.client.screen.builder.BlockEntityScreenHandlerBuilder;
import reborncore.common.util.serialization.SerializationUtil; import reborncore.common.util.serialization.SerializationUtil;
@ -39,7 +39,7 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class DataDrivenSlot { public record DataDrivenSlot(int id, int x, int y, @NotNull SlotType type) {
public static List<DataDrivenSlot> read(JsonArray jsonArray) { public static List<DataDrivenSlot> read(JsonArray jsonArray) {
AtomicInteger idCount = new AtomicInteger(); AtomicInteger idCount = new AtomicInteger();
@ -49,35 +49,6 @@ public class DataDrivenSlot {
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
private final int id;
private final int x;
private final int y;
private final SlotType type;
public DataDrivenSlot(int id, int x, int y, SlotType type) {
this.id = id;
this.x = x;
this.y = y;
this.type = type;
Validate.notNull(type);
}
public int getId() {
return id;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public SlotType getType() {
return type;
}
public void add(BlockEntityScreenHandlerBuilder inventoryBuilder) { public void add(BlockEntityScreenHandlerBuilder inventoryBuilder) {
type.getSlotBiConsumer().accept(inventoryBuilder, this); type.getSlotBiConsumer().accept(inventoryBuilder, this);
} }
@ -85,10 +56,10 @@ public class DataDrivenSlot {
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public void draw(MatrixStack matrixStack, GuiBase<?> guiBase, GuiBase.Layer layer) { public void draw(MatrixStack matrixStack, GuiBase<?> guiBase, GuiBase.Layer layer) {
//TODO find a better way to do this //TODO find a better way to do this
if (getType() == SlotType.OUTPUT) { if (type() == SlotType.OUTPUT) {
guiBase.drawOutputSlot(matrixStack, getX(), getY(), layer); guiBase.drawOutputSlot(matrixStack, x(), y(), layer);
} else { } else {
guiBase.drawSlot(matrixStack, getX(), getY(), layer); guiBase.drawSlot(matrixStack, x(), y(), layer);
} }
} }
} }

View file

@ -32,13 +32,13 @@ import java.util.function.BiConsumer;
public enum SlotType { public enum SlotType {
//Im really not a fan of the way I add the slots to the builder here //Im really not a fan of the way I add the slots to the builder here
INPUT((builder, slot) -> { INPUT((builder, slot) -> {
builder.slot(slot.getId(), slot.getX(), slot.getY()); builder.slot(slot.id(), slot.x(), slot.y());
}), }),
OUTPUT((builder, slot) -> { OUTPUT((builder, slot) -> {
builder.outputSlot(slot.getId(), slot.getX(), slot.getY()); builder.outputSlot(slot.id(), slot.x(), slot.y());
}), }),
ENERGY((builder, slot) -> { ENERGY((builder, slot) -> {
builder.energySlot(slot.getId(), slot.getX(), slot.getY()); builder.energySlot(slot.id(), slot.x(), slot.y());
}); });
public static SlotType fromString(String string) { public static SlotType fromString(String string) {

View file

@ -105,7 +105,7 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
} }
if (!tank.getFluidAmount().isEmpty()) { if (!tank.getFluidAmount().isEmpty()) {
if (currentRecipe == null || !FluidUtils.fluidEquals(currentRecipe.getFluid(), tank.getFluid())) if (currentRecipe == null || !FluidUtils.fluidEquals(currentRecipe.fluid(), tank.getFluid()))
currentRecipe = getRecipes().getRecipeForFluid(tank.getFluid()).orElse(null); currentRecipe = getRecipes().getRecipeForFluid(tank.getFluid()).orElse(null);
if (currentRecipe != null) { if (currentRecipe != null) {

View file

@ -65,12 +65,10 @@ public class LightningRodBlockEntity extends PowerAcceptorBlockEntity implements
} }
Block BEBlock = getCachedState().getBlock(); Block BEBlock = getCachedState().getBlock();
if (!(BEBlock instanceof BlockMachineBase)) { if (!(BEBlock instanceof BlockMachineBase machineBaseBlock)) {
return; return;
} }
BlockMachineBase machineBaseBlock = (BlockMachineBase) BEBlock;
if (onStatusHoldTicks == 0 || getEnergy() <= 0) { if (onStatusHoldTicks == 0 || getEnergy() <= 0) {
machineBaseBlock.setActive(false, world, pos); machineBaseBlock.setActive(false, world, pos);
onStatusHoldTicks = -1; onStatusHoldTicks = -1;

View file

@ -82,8 +82,7 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
return; return;
} }
Block panelBlock = world.getBlockState(pos).getBlock(); Block panelBlock = world.getBlockState(pos).getBlock();
if (panelBlock instanceof BlockSolarPanel) { if (panelBlock instanceof BlockSolarPanel solarPanelBlock) {
BlockSolarPanel solarPanelBlock = (BlockSolarPanel) panelBlock;
panel = solarPanelBlock.panelType; panel = solarPanelBlock.panelType;
} }
} }
@ -133,17 +132,11 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
} }
public int getGenerationRate() { public int getGenerationRate() {
int rate = 0; return switch (getSunState()) {
case DAYGEN -> getPanel().generationRateD;
switch (getSunState()) { case NIGHTGEN -> getPanel().generationRateN;
case DAYGEN: default -> 0;
rate = getPanel().generationRateD; };
break;
case NIGHTGEN:
rate = getPanel().generationRateN;
}
return rate;
} }

View file

@ -122,8 +122,7 @@ public class SolidFuelGeneratorBlockEntity extends PowerAcceptorBlockEntity impl
public void updateState() { public void updateState() {
final BlockState BlockStateContainer = world.getBlockState(pos); final BlockState BlockStateContainer = world.getBlockState(pos);
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) { if (BlockStateContainer.getBlock() instanceof final BlockMachineBase blockMachineBase) {
final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
boolean active = burnTime > 0 && getFreeSpace() > 0.0f; boolean active = burnTime > 0 && getFreeSpace() > 0.0f;
if (BlockStateContainer.get(BlockMachineBase.ACTIVE) != active) { if (BlockStateContainer.get(BlockMachineBase.ACTIVE) != active) {
blockMachineBase.setActive(active, world, pos); blockMachineBase.setActive(active, world, pos);

View file

@ -125,8 +125,7 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
private void updateState() { private void updateState() {
BlockState state = world.getBlockState(pos); BlockState state = world.getBlockState(pos);
if (state.getBlock() instanceof BlockMachineBase) { if (state.getBlock() instanceof BlockMachineBase blockMachineBase) {
BlockMachineBase blockMachineBase = (BlockMachineBase) state.getBlock();
if (state.get(BlockMachineBase.ACTIVE) != burnTime > 0) if (state.get(BlockMachineBase.ACTIVE) != burnTime > 0)
blockMachineBase.setActive(burnTime > 0, world, pos); blockMachineBase.setActive(burnTime > 0, world, pos);
} }

View file

@ -59,8 +59,7 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
} }
public void handleGuiInputFromClient(PlayerEntity playerIn) { public void handleGuiInputFromClient(PlayerEntity playerIn) {
if (playerIn instanceof ServerPlayerEntity) { if (playerIn instanceof ServerPlayerEntity player) {
ServerPlayerEntity player = (ServerPlayerEntity) playerIn;
int totalExperience = (int) experience; int totalExperience = (int) experience;
while (totalExperience > 0) { while (totalExperience > 0) {
int expToDrop = ExperienceOrbEntity.roundToOrbSize(totalExperience); int expToDrop = ExperienceOrbEntity.roundToOrbSize(totalExperience);

View file

@ -26,14 +26,13 @@ package techreborn.blockentity.machine.misc;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting; import net.minecraft.util.Formatting;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import reborncore.api.IToolDrop; import reborncore.api.IToolDrop;
@ -94,15 +93,9 @@ public class AlarmBlockEntity extends BlockEntity
if (world.isReceivingRedstonePower(getPos())) { if (world.isReceivingRedstonePower(getPos())) {
BlockAlarm.setActive(true, world, pos); BlockAlarm.setActive(true, world, pos);
switch (selectedSound) { switch (selectedSound) {
case 1: case 1 -> world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM, SoundCategory.BLOCKS, 4F, 1F);
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM, SoundCategory.BLOCKS, 4F, 1F); case 2 -> world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM_2, SoundCategory.BLOCKS, 4F, 1F);
break; case 3 -> world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM_3, SoundCategory.BLOCKS, 4F, 1F);
case 2:
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM_2, SoundCategory.BLOCKS, 4F, 1F);
break;
case 3:
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM_3, SoundCategory.BLOCKS, 4F, 1F);
break;
} }
} else { } else {
BlockAlarm.setActive(false, world, pos); BlockAlarm.setActive(false, world, pos);

View file

@ -40,6 +40,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.Nullable;
import reborncore.api.IToolDrop; import reborncore.api.IToolDrop;
import reborncore.api.blockentity.InventoryProvider; import reborncore.api.blockentity.InventoryProvider;
import reborncore.client.screen.BuiltScreenHandlerProvider; import reborncore.client.screen.BuiltScreenHandlerProvider;
@ -56,7 +57,6 @@ import techreborn.init.ModSounds;
import techreborn.init.TRBlockEntities; import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent; import techreborn.init.TRContent;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;

View file

@ -131,8 +131,7 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
private void updateState() { private void updateState() {
Block furnaceBlock = getWorld().getBlockState(pos).getBlock(); Block furnaceBlock = getWorld().getBlockState(pos).getBlock();
if (furnaceBlock instanceof BlockMachineBase) { if (furnaceBlock instanceof BlockMachineBase blockMachineBase) {
BlockMachineBase blockMachineBase = (BlockMachineBase) furnaceBlock;
boolean isActive = currentRecipe != null || canCraftAgain(); boolean isActive = currentRecipe != null || canCraftAgain();
blockMachineBase.setActive(isActive, world, pos); blockMachineBase.setActive(isActive, world, pos);
} }

View file

@ -178,8 +178,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
return; return;
} }
isRunning = active; isRunning = active;
if (this.getWorld().getBlockState(this.getPos()).getBlock() instanceof BlockMachineBase) { if (this.getWorld().getBlockState(this.getPos()).getBlock() instanceof BlockMachineBase blockMachineBase) {
BlockMachineBase blockMachineBase = (BlockMachineBase) this.getWorld().getBlockState(this.getPos()).getBlock();
blockMachineBase.setActive(active, this.getWorld(), this.getPos()); blockMachineBase.setActive(active, this.getWorld(), this.getPos());
} }
this.getWorld().updateListeners(this.getPos(), this.getWorld().getBlockState(this.getPos()), this.getWorld().getBlockState(this.getPos()), 3); this.getWorld().updateListeners(this.getPos(), this.getWorld().getBlockState(this.getPos()), this.getWorld().getBlockState(this.getPos()), 3);

View file

@ -27,11 +27,9 @@ package techreborn.blockentity.machine.tier1;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.client.screen.BuiltScreenHandlerProvider; import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler; import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.ScreenHandlerBuilder; import reborncore.client.screen.builder.ScreenHandlerBuilder;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.recipes.RecipeCrafter; import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.util.RebornInventory; import reborncore.common.util.RebornInventory;
import techreborn.blockentity.machine.GenericMachineBlockEntity; import techreborn.blockentity.machine.GenericMachineBlockEntity;

View file

@ -34,6 +34,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.Nullable;
import reborncore.api.IToolDrop; import reborncore.api.IToolDrop;
import reborncore.api.blockentity.InventoryProvider; import reborncore.api.blockentity.InventoryProvider;
import reborncore.client.screen.BuiltScreenHandlerProvider; import reborncore.client.screen.BuiltScreenHandlerProvider;
@ -46,8 +47,6 @@ import techreborn.config.TechRebornConfig;
import techreborn.init.TRBlockEntities; import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent; import techreborn.init.TRContent;
import org.jetbrains.annotations.Nullable;
public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IToolDrop, InventoryProvider, BuiltScreenHandlerProvider { public class ChunkLoaderBlockEntity extends MachineBaseBlockEntity implements IToolDrop, InventoryProvider, BuiltScreenHandlerProvider {
public RebornInventory<ChunkLoaderBlockEntity> inventory = new RebornInventory<>(0, "ChunkLoaderBlockEntity", 64, this); public RebornInventory<ChunkLoaderBlockEntity> inventory = new RebornInventory<>(0, "ChunkLoaderBlockEntity", 64, this);

View file

@ -28,9 +28,9 @@ import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.PersistentState; import net.minecraft.world.PersistentState;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.jetbrains.annotations.NotNull;
import reborncore.common.util.NBTSerializable; import reborncore.common.util.NBTSerializable;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap; import java.util.HashMap;
public class IDSUManager extends PersistentState { public class IDSUManager extends PersistentState {

View file

@ -50,10 +50,9 @@ public class LSUStorageBlockEntity extends MachineBaseBlockEntity
network.addElement(this); network.addElement(this);
for (Direction direction : Direction.values()) { for (Direction direction : Direction.values()) {
BlockEntity be = world.getBlockEntity(pos.offset(direction)); BlockEntity be = world.getBlockEntity(pos.offset(direction));
if (!(be instanceof LSUStorageBlockEntity)) { if (!(be instanceof LSUStorageBlockEntity lesuStorage)) {
continue; continue;
} }
LSUStorageBlockEntity lesuStorage = (LSUStorageBlockEntity) be;
if (lesuStorage.network != null) { if (lesuStorage.network != null) {
lesuStorage.network.merge(network); lesuStorage.network.merge(network);
} }

View file

@ -36,6 +36,7 @@ import net.minecraft.util.Formatting;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import reborncore.api.IListInfoProvider; import reborncore.api.IListInfoProvider;
import reborncore.api.IToolDrop; import reborncore.api.IToolDrop;
import reborncore.api.blockentity.InventoryProvider; import reborncore.api.blockentity.InventoryProvider;
@ -49,7 +50,6 @@ import reborncore.common.util.WorldUtils;
import techreborn.init.TRBlockEntities; import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent; import techreborn.init.TRContent;
import org.jetbrains.annotations.Nullable;
import java.util.List; import java.util.List;
public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implements InventoryProvider, IToolDrop, IListInfoProvider, BuiltScreenHandlerProvider { public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implements InventoryProvider, IToolDrop, IListInfoProvider, BuiltScreenHandlerProvider {

View file

@ -54,6 +54,7 @@ import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldAccess; import net.minecraft.world.WorldAccess;
import org.jetbrains.annotations.Nullable;
import reborncore.api.ToolManager; import reborncore.api.ToolManager;
import reborncore.common.blocks.BlockWrenchEventHandler; import reborncore.common.blocks.BlockWrenchEventHandler;
import reborncore.common.util.WrenchUtils; import reborncore.common.util.WrenchUtils;
@ -65,8 +66,6 @@ import techreborn.init.ModSounds;
import techreborn.init.TRContent; import techreborn.init.TRContent;
import techreborn.utils.damageSources.ElectrialShockSource; import techreborn.utils.damageSources.ElectrialShockSource;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -106,20 +105,14 @@ public class CableBlock extends BlockWithEntity implements Waterloggable {
} }
public BooleanProperty getProperty(Direction facing) { public BooleanProperty getProperty(Direction facing) {
switch (facing) { return switch (facing) {
case WEST: case WEST -> WEST;
return WEST; case NORTH -> NORTH;
case NORTH: case SOUTH -> SOUTH;
return NORTH; case UP -> UP;
case SOUTH: case DOWN -> DOWN;
return SOUTH; default -> EAST;
case UP: };
return UP;
case DOWN:
return DOWN;
default:
return EAST;
}
} }
private BlockState makeConnections(World world, BlockPos pos) { private BlockState makeConnections(World world, BlockPos pos) {
@ -250,11 +243,10 @@ public class CableBlock extends BlockWithEntity implements Waterloggable {
if (blockEntity == null) { if (blockEntity == null) {
return; return;
} }
if (!(blockEntity instanceof CableBlockEntity)) { if (!(blockEntity instanceof CableBlockEntity blockEntityCable)) {
return; return;
} }
CableBlockEntity blockEntityCable = (CableBlockEntity) blockEntity;
if (blockEntityCable.getEnergy() <= 0) { if (blockEntityCable.getEnergy() <= 0) {
return; return;
} }

View file

@ -42,14 +42,13 @@ import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import reborncore.api.ToolManager; import reborncore.api.ToolManager;
import reborncore.common.BaseBlockEntityProvider; import reborncore.common.BaseBlockEntityProvider;
import reborncore.common.blocks.BlockWrenchEventHandler; import reborncore.common.blocks.BlockWrenchEventHandler;
import reborncore.common.util.WrenchUtils; import reborncore.common.util.WrenchUtils;
import techreborn.blockentity.lighting.LampBlockEntity; import techreborn.blockentity.lighting.LampBlockEntity;
import org.jetbrains.annotations.Nullable;
import java.util.function.ToIntFunction; import java.util.function.ToIntFunction;
public class LampBlock extends BaseBlockEntityProvider { public class LampBlock extends BaseBlockEntityProvider {

View file

@ -45,13 +45,13 @@ import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import reborncore.api.ToolManager; import reborncore.api.ToolManager;
import reborncore.common.BaseBlockEntityProvider; import reborncore.common.BaseBlockEntityProvider;
import reborncore.common.blocks.BlockWrenchEventHandler; import reborncore.common.blocks.BlockWrenchEventHandler;
import reborncore.common.util.WrenchUtils; import reborncore.common.util.WrenchUtils;
import techreborn.blockentity.machine.misc.AlarmBlockEntity; import techreborn.blockentity.machine.misc.AlarmBlockEntity;
import org.jetbrains.annotations.Nullable;
import java.util.List; import java.util.List;
public class BlockAlarm extends BaseBlockEntityProvider { public class BlockAlarm extends BaseBlockEntityProvider {

View file

@ -45,11 +45,11 @@ public class BlockMachineCasing extends BlockMultiblockBase {
public static int getHeatFromState(BlockState state) { public static int getHeatFromState(BlockState state) {
Block block = state.getBlock(); Block block = state.getBlock();
if (!(block instanceof BlockMachineCasing)) { if (block instanceof BlockMachineCasing casing) {
return 0; return casing.heatCapacity;
} }
BlockMachineCasing casing = (BlockMachineCasing) block;
return casing.heatCapacity; return 0;
} }
@Override @Override

View file

@ -75,13 +75,12 @@ public class BlockNuke extends BaseBlock {
@Override @Override
public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) { public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) {
if (!worldIn.isClient && entityIn instanceof ProjectileEntity) { if (!worldIn.isClient && entityIn instanceof ProjectileEntity projectileEntity) {
ProjectileEntity entityarrow = (ProjectileEntity) entityIn;
LivingEntity shooter = null; LivingEntity shooter = null;
if (entityarrow.getOwner() instanceof LivingEntity) { if (projectileEntity.getOwner() instanceof LivingEntity) {
shooter = (LivingEntity) entityarrow.getOwner(); shooter = (LivingEntity) projectileEntity.getOwner();
} }
if (entityarrow.isOnFire()) { if (projectileEntity.isOnFire()) {
ignite(worldIn, pos, state, shooter); ignite(worldIn, pos, state, shooter);
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState()); worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
} }

View file

@ -58,8 +58,7 @@ public class LSUStorageBlock extends BaseBlockEntityProvider {
if (state.getBlock() == newState.getBlock()) { if (state.getBlock() == newState.getBlock()) {
return; return;
} }
if (worldIn.getBlockEntity(pos) instanceof LSUStorageBlockEntity) { if (worldIn.getBlockEntity(pos) instanceof LSUStorageBlockEntity blockEntity) {
LSUStorageBlockEntity blockEntity = (LSUStorageBlockEntity) worldIn.getBlockEntity(pos);
if (blockEntity != null) { if (blockEntity != null) {
blockEntity.removeFromNetwork(); blockEntity.removeFromNetwork();
} }
@ -75,8 +74,7 @@ public class LSUStorageBlock extends BaseBlockEntityProvider {
@Override @Override
public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity player, ItemStack itemstack) { public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity player, ItemStack itemstack) {
super.onPlaced(world, pos, state, player, itemstack); super.onPlaced(world, pos, state, player, itemstack);
if (world.getBlockEntity(pos) instanceof LSUStorageBlockEntity) { if (world.getBlockEntity(pos) instanceof LSUStorageBlockEntity blockEntity) {
LSUStorageBlockEntity blockEntity = (LSUStorageBlockEntity) world.getBlockEntity(pos);
if (blockEntity != null) { if (blockEntity != null) {
blockEntity.rebuildNetwork(); blockEntity.rebuildNetwork();
} }

View file

@ -75,10 +75,9 @@ public class TankUnitBlock extends BlockMachineBase {
// Assuming ItemFluidInfo is 1 BUCKET, for now only allow exact amount or less // Assuming ItemFluidInfo is 1 BUCKET, for now only allow exact amount or less
// I am only going to trust cells or buckets, they are known to be 1 BUCKET size, too suss of other items not abiding by that. // I am only going to trust cells or buckets, they are known to be 1 BUCKET size, too suss of other items not abiding by that.
if ((itemInHand instanceof DynamicCellItem || itemInHand instanceof BucketItem) if ((itemInHand instanceof DynamicCellItem || itemInHand instanceof BucketItem)
&& tankUnitEntity != null && itemInHand instanceof ItemFluidInfo) { && tankUnitEntity != null && itemInHand instanceof ItemFluidInfo itemFluid) {
// Get fluid information from item // Get fluid information from item
ItemFluidInfo itemFluid = (ItemFluidInfo) itemInHand;
Fluid fluid = itemFluid.getFluid(stackInHand); Fluid fluid = itemFluid.getFluid(stackInHand);
int amount = stackInHand.getCount(); int amount = stackInHand.getCount();
@ -154,14 +153,11 @@ public class TankUnitBlock extends BlockMachineBase {
boolean isSameItemFluid(ItemStack i1, ItemStack i2){ boolean isSameItemFluid(ItemStack i1, ItemStack i2){
// Only care about cells, buckets don't stack // Only care about cells, buckets don't stack
if(!(i1.getItem() instanceof DynamicCellItem && i2.getItem() instanceof DynamicCellItem)){ if(i1.getItem() instanceof DynamicCellItem dc1 && i2.getItem() instanceof DynamicCellItem dc2){
return false; return dc1.getFluid(i1).matchesType(dc2.getFluid(i2));
} }
DynamicCellItem dc1 = (DynamicCellItem)i1.getItem(); return false;
DynamicCellItem dc2 = (DynamicCellItem)i2.getItem();
return dc1.getFluid(i1).matchesType(dc2.getFluid(i2));
} }
@Override @Override

View file

@ -42,6 +42,7 @@ import net.minecraft.text.Text;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import reborncore.RebornCore; import reborncore.RebornCore;
import reborncore.api.blockentity.IMachineGuiHandler; import reborncore.api.blockentity.IMachineGuiHandler;
import reborncore.client.screen.BuiltScreenHandlerProvider; import reborncore.client.screen.BuiltScreenHandlerProvider;
@ -73,7 +74,6 @@ import techreborn.blockentity.storage.fluid.TankUnitBaseBlockEntity;
import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity; import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity;
import techreborn.client.gui.*; import techreborn.client.gui.*;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.Supplier; import java.util.function.Supplier;

View file

@ -24,7 +24,6 @@
package techreborn.client.gui; package techreborn.client.gui;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;

View file

@ -24,7 +24,6 @@
package techreborn.client.gui; package techreborn.client.gui;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;

View file

@ -24,7 +24,6 @@
package techreborn.client.gui; package techreborn.client.gui;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;

View file

@ -49,15 +49,9 @@ public class GuiSolar extends GuiBase<BuiltScreenHandler> {
builder.drawMultiEnergyBar(matrixStack, this, 156, 19, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxStoredPower(), mouseX, mouseY, 0, layer); builder.drawMultiEnergyBar(matrixStack, this, 156, 19, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxStoredPower(), mouseX, mouseY, 0, layer);
switch (blockEntity.getSunState()) { switch (blockEntity.getSunState()) {
case SolarPanelBlockEntity.DAYGEN: case SolarPanelBlockEntity.DAYGEN -> builder.drawText(matrixStack, this, new TranslatableText("techreborn.message.daygen"), 10, 20, 15129632);
builder.drawText(matrixStack, this, new TranslatableText("techreborn.message.daygen"), 10, 20, 15129632); case SolarPanelBlockEntity.NIGHTGEN -> builder.drawText(matrixStack, this, new TranslatableText("techreborn.message.nightgen"), 10, 20, 7566195);
break; case SolarPanelBlockEntity.ZEROGEN -> builder.drawText(matrixStack, this, new TranslatableText("techreborn.message.zerogen"), 10, 20, 12066591);
case SolarPanelBlockEntity.NIGHTGEN:
builder.drawText(matrixStack, this, new TranslatableText("techreborn.message.nightgen"), 10, 20, 7566195);
break;
case SolarPanelBlockEntity.ZEROGEN:
builder.drawText(matrixStack, this, new TranslatableText("techreborn.message.zerogen"), 10, 20, 12066591);
break;
} }
builder.drawText(matrixStack, this, new LiteralText("Generating: " + blockEntity.getGenerationRate() + " E/t"), 10, 30, 0); builder.drawText(matrixStack, this, new LiteralText("Generating: " + blockEntity.getGenerationRate() + " E/t"), 10, 30, 0);

Some files were not shown because too many files have changed in this diff Show more