Start of 1.20.1 port
This commit is contained in:
@@ -92,13 +92,13 @@ dependencies {
|
||||
implementation "curse.maven:sedna-511276:3885542"
|
||||
minecraftLibrary "org.apache.commons:commons-collections4:4.4"
|
||||
|
||||
implementation fg.deobf("curse.maven:markdownmanual-502485:4306669")
|
||||
implementation fg.deobf("curse.maven:markdownmanual-502485:4873115")
|
||||
implementation fg.deobf("curse.maven:architectury-api-419699:4521273")
|
||||
|
||||
compileOnly fg.deobf("mezz.jei:jei-1.19.2-common-api:11.6.0.1015")
|
||||
compileOnly fg.deobf("mezz.jei:jei-1.19.2-forge-api:11.6.0.1015")
|
||||
compileOnly fg.deobf("mezz.jei:jei-1.20.1-common-api:15.3.0.4")
|
||||
compileOnly fg.deobf("mezz.jei:jei-1.20.1-forge-api:15.3.0.4")
|
||||
|
||||
runtimeOnly fg.deobf("mezz.jei:jei-1.19.2-forge:11.6.0.1015")
|
||||
runtimeOnly fg.deobf("mezz.jei:jei-1.20.1-forge:15.3.0.4")
|
||||
|
||||
testImplementation "org.mockito:mockito-inline:4.3.1"
|
||||
testImplementation "org.junit.jupiter:junit-jupiter-api:5.8.2"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
org.gradle.jvmargs=-Xmx3G
|
||||
org.gradle.daemon=false
|
||||
|
||||
forge_version=43.2.10
|
||||
forge_version=47.2.32
|
||||
|
||||
semver=0.0.0
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
ext {
|
||||
minecraft_version = '1.19.2'
|
||||
minecraft_version = '1.20.1'
|
||||
minecraft_sdk = 'forge'
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.MenuScreens;
|
||||
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.inventory.InventoryMenu;
|
||||
import net.minecraftforge.client.event.EntityRenderersEvent;
|
||||
import net.minecraftforge.client.event.ModelEvent.RegisterGeometryLoaders;
|
||||
@@ -31,10 +32,17 @@ import net.minecraftforge.client.gui.overlay.VanillaGuiOverlay;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public final class ClientSetup {
|
||||
private static final Set<ResourceLocation> sprites = new HashSet<ResourceLocation>();
|
||||
|
||||
@SubscribeEvent
|
||||
public static void handleSetupEvent(final FMLClientSetupEvent event) {
|
||||
BusInterfaceNameRenderer.initialize();
|
||||
@@ -59,6 +67,16 @@ public final class ClientSetup {
|
||||
|
||||
// We need to register this manually, because static init throws errors when running data generation.
|
||||
MinecraftForge.EVENT_BUS.register(ProjectorDepthRenderer.class);
|
||||
|
||||
for (final DeviceType deviceType : DeviceTypes.DEVICE_TYPE_REGISTRY.get().getValues()) {
|
||||
sprites.add(deviceType.getBackgroundIcon());
|
||||
}
|
||||
|
||||
sprites.add(ComputerRenderer.OVERLAY_POWER_LOCATION);
|
||||
sprites.add(ComputerRenderer.OVERLAY_STATUS_LOCATION);
|
||||
sprites.add(ComputerRenderer.OVERLAY_TERMINAL_LOCATION);
|
||||
|
||||
sprites.add(ChargerRenderer.EFFECT_LOCATION);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -76,21 +94,11 @@ public final class ClientSetup {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void handleTextureStitchEvent(final TextureStitchEvent.Pre event) {
|
||||
if (!Objects.equals(event.getAtlas().location(), InventoryMenu.BLOCK_ATLAS)) {
|
||||
return;
|
||||
}
|
||||
@ApiStatus.Internal
|
||||
public static void collectSprites(ResourceLocation atlas, Consumer<ResourceLocation> spriteConsumer) {
|
||||
if(!Objects.equals(atlas, InventoryMenu.BLOCK_ATLAS)) return;
|
||||
|
||||
for (final DeviceType deviceType : DeviceTypes.DEVICE_TYPE_REGISTRY.get().getValues()) {
|
||||
event.addSprite(deviceType.getBackgroundIcon());
|
||||
}
|
||||
|
||||
event.addSprite(ComputerRenderer.OVERLAY_POWER_LOCATION);
|
||||
event.addSprite(ComputerRenderer.OVERLAY_STATUS_LOCATION);
|
||||
event.addSprite(ComputerRenderer.OVERLAY_TERMINAL_LOCATION);
|
||||
|
||||
event.addSprite(ChargerRenderer.EFFECT_LOCATION);
|
||||
sprites.forEach(spriteConsumer);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
package li.cil.oc2.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import li.cil.oc2.api.bus.device.DeviceTypes;
|
||||
import li.cil.oc2.client.gui.util.GuiUtils;
|
||||
import li.cil.oc2.client.gui.widget.ImageButton;
|
||||
@@ -12,6 +11,8 @@ import li.cil.oc2.common.Constants;
|
||||
import li.cil.oc2.common.container.AbstractMachineTerminalContainer;
|
||||
import li.cil.oc2.common.util.TooltipUtils;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.Rect2i;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -69,6 +70,10 @@ public abstract class AbstractMachineInventoryScreen<T extends AbstractMachineTe
|
||||
Sprites.POWER_BUTTON_PRESSED,
|
||||
Sprites.POWER_BUTTON_ACTIVE
|
||||
) {
|
||||
@Override
|
||||
protected void updateWidgetNarration(final NarrationElementOutput narrationElementOutput) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPress() {
|
||||
super.onPress();
|
||||
@@ -90,6 +95,10 @@ public abstract class AbstractMachineInventoryScreen<T extends AbstractMachineTe
|
||||
Sprites.INVENTORY_BUTTON_ACTIVE,
|
||||
Sprites.INVENTORY_BUTTON_INACTIVE
|
||||
) {
|
||||
@Override
|
||||
protected void updateWidgetNarration(final NarrationElementOutput narrationElementOutput) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPress() {
|
||||
menu.switchToTerminal();
|
||||
@@ -98,53 +107,55 @@ public abstract class AbstractMachineInventoryScreen<T extends AbstractMachineTe
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(final PoseStack stack, final float partialTicks, final int mouseX, final int mouseY) {
|
||||
protected void renderBg(final GuiGraphics graphics, final float partialTicks, final int mouseX, final int mouseY) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
|
||||
Sprites.SIDEBAR_2.draw(stack, leftPos - Sprites.SIDEBAR_2.width, topPos + CONTROLS_TOP);
|
||||
Sprites.SIDEBAR_2.draw(graphics, leftPos - Sprites.SIDEBAR_2.width, topPos + CONTROLS_TOP);
|
||||
|
||||
if (shouldRenderEnergyBar()) {
|
||||
final int x = leftPos - Sprites.SIDEBAR_2.width;
|
||||
final int y = topPos + ENERGY_TOP;
|
||||
Sprites.SIDEBAR_2.draw(stack, x, y);
|
||||
Sprites.ENERGY_BASE.draw(stack, x + 4, y + 4);
|
||||
Sprites.SIDEBAR_2.draw(graphics, x, y);
|
||||
Sprites.ENERGY_BASE.draw(graphics, x + 4, y + 4);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderFg(final PoseStack stack, final float partialTicks, final int mouseX, final int mouseY) {
|
||||
super.renderFg(stack, partialTicks, mouseX, mouseY);
|
||||
protected void renderFg(final GuiGraphics graphics, final float partialTicks, final int mouseX, final int mouseY) {
|
||||
super.renderFg(graphics, partialTicks, mouseX, mouseY);
|
||||
|
||||
GuiUtils.renderMissingDeviceInfoIcon(stack, this, DeviceTypes.FLASH_MEMORY, Sprites.WARN_ICON);
|
||||
GuiUtils.renderMissingDeviceInfoIcon(stack, this, DeviceTypes.MEMORY, Sprites.WARN_ICON);
|
||||
GuiUtils.renderMissingDeviceInfoIcon(stack, this, DeviceTypes.HARD_DRIVE, Sprites.INFO_ICON);
|
||||
GuiUtils.renderMissingDeviceInfoIcon(graphics, this, DeviceTypes.FLASH_MEMORY, Sprites.WARN_ICON);
|
||||
GuiUtils.renderMissingDeviceInfoIcon(graphics, this, DeviceTypes.MEMORY, Sprites.WARN_ICON);
|
||||
GuiUtils.renderMissingDeviceInfoIcon(graphics, this, DeviceTypes.HARD_DRIVE, Sprites.INFO_ICON);
|
||||
|
||||
if (shouldRenderEnergyBar()) {
|
||||
final int x = leftPos - Sprites.SIDEBAR_2.width + 4;
|
||||
final int y = topPos + ENERGY_TOP + 4;
|
||||
Sprites.ENERGY_BAR.drawFillY(stack, x, y, menu.getEnergy() / (float) menu.getEnergyCapacity());
|
||||
Sprites.ENERGY_BAR.drawFillY(graphics, x, y, menu.getEnergy() / (float) menu.getEnergyCapacity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderTooltip(final PoseStack stack, final int mouseX, final int mouseY) {
|
||||
super.renderTooltip(stack, mouseX, mouseY);
|
||||
protected void renderTooltip(final GuiGraphics graphics, final int mouseX, final int mouseY) {
|
||||
super.renderTooltip(graphics, mouseX, mouseY);
|
||||
|
||||
GuiUtils.renderMissingDeviceInfoTooltip(stack, this, mouseX, mouseY, DeviceTypes.FLASH_MEMORY);
|
||||
GuiUtils.renderMissingDeviceInfoTooltip(stack, this, mouseX, mouseY, DeviceTypes.MEMORY);
|
||||
GuiUtils.renderMissingDeviceInfoTooltip(stack, this, mouseX, mouseY, DeviceTypes.HARD_DRIVE);
|
||||
GuiUtils.renderMissingDeviceInfoTooltip(graphics, this, mouseX, mouseY, DeviceTypes.FLASH_MEMORY);
|
||||
GuiUtils.renderMissingDeviceInfoTooltip(graphics, this, mouseX, mouseY, DeviceTypes.MEMORY);
|
||||
GuiUtils.renderMissingDeviceInfoTooltip(graphics, this, mouseX, mouseY, DeviceTypes.HARD_DRIVE);
|
||||
|
||||
if (shouldRenderEnergyBar()) {
|
||||
if (isMouseOver(mouseX, mouseY, -Sprites.SIDEBAR_2.width + 4, ENERGY_TOP + 4, Sprites.ENERGY_BAR.width, Sprites.ENERGY_BAR.height)) {
|
||||
final List<? extends FormattedText> tooltip = asList(
|
||||
Component.translatable(Constants.TOOLTIP_ENERGY,
|
||||
withFormat(menu.getEnergy() + "/" + menu.getEnergyCapacity(), ChatFormatting.GREEN)),
|
||||
Component.translatable(Constants.TOOLTIP_ENERGY_CONSUMPTION,
|
||||
withFormat(String.valueOf(menu.getEnergyConsumption()), ChatFormatting.GREEN))
|
||||
);
|
||||
TooltipUtils.drawTooltip(stack, tooltip, mouseX, mouseY, 200);
|
||||
}
|
||||
if (!shouldRenderEnergyBar()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isMouseOver(mouseX, mouseY, -Sprites.SIDEBAR_2.width + 4, ENERGY_TOP + 4, Sprites.ENERGY_BAR.width, Sprites.ENERGY_BAR.height)) {
|
||||
final List<? extends FormattedText> tooltip = asList(
|
||||
Component.translatable(Constants.TOOLTIP_ENERGY,
|
||||
withFormat(menu.getEnergy() + "/" + menu.getEnergyCapacity(), ChatFormatting.GREEN)),
|
||||
Component.translatable(Constants.TOOLTIP_ENERGY_CONSUMPTION,
|
||||
withFormat(String.valueOf(menu.getEnergyConsumption()), ChatFormatting.GREEN))
|
||||
);
|
||||
TooltipUtils.drawTooltip(graphics, tooltip, mouseX, mouseY, 200);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,10 @@ import li.cil.oc2.common.Constants;
|
||||
import li.cil.oc2.common.container.AbstractMachineTerminalContainer;
|
||||
import li.cil.oc2.common.util.TooltipUtils;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||
import net.minecraft.client.renderer.Rect2i;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
@@ -100,7 +103,7 @@ public abstract class AbstractMachineTerminalScreen<T extends AbstractMachineTer
|
||||
terminalWidget.init();
|
||||
|
||||
final EditBox focusIndicatorEditBox = new EditBox(font, 0, 0, 0, 0, Component.empty());
|
||||
focusIndicatorEditBox.setFocus(true);
|
||||
focusIndicatorEditBox.setFocused(true);
|
||||
setFocusIndicatorEditBox(focusIndicatorEditBox);
|
||||
|
||||
addRenderableWidget(new ToggleImageButton(
|
||||
@@ -110,6 +113,10 @@ public abstract class AbstractMachineTerminalScreen<T extends AbstractMachineTer
|
||||
Sprites.POWER_BUTTON_PRESSED,
|
||||
Sprites.POWER_BUTTON_ACTIVE
|
||||
) {
|
||||
@Override
|
||||
protected void updateWidgetNarration(final NarrationElementOutput narrationElementOutput) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPress() {
|
||||
super.onPress();
|
||||
@@ -132,6 +139,10 @@ public abstract class AbstractMachineTerminalScreen<T extends AbstractMachineTer
|
||||
Sprites.INPUT_BUTTON_PRESSED,
|
||||
Sprites.INPUT_BUTTON_ACTIVE
|
||||
) {
|
||||
@Override
|
||||
protected void updateWidgetNarration(final NarrationElementOutput narrationElementOutput) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPress() {
|
||||
super.onPress();
|
||||
@@ -153,6 +164,10 @@ public abstract class AbstractMachineTerminalScreen<T extends AbstractMachineTer
|
||||
Sprites.INVENTORY_BUTTON_INACTIVE,
|
||||
Sprites.INVENTORY_BUTTON_ACTIVE
|
||||
) {
|
||||
@Override
|
||||
protected void updateWidgetNarration(final NarrationElementOutput narrationElementOutput) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPress() {
|
||||
menu.switchToInventory();
|
||||
@@ -174,35 +189,35 @@ public abstract class AbstractMachineTerminalScreen<T extends AbstractMachineTer
|
||||
protected abstract void setFocusIndicatorEditBox(final EditBox editBox);
|
||||
|
||||
@Override
|
||||
protected void renderFg(final PoseStack stack, final float partialTicks, final int mouseX, final int mouseY) {
|
||||
super.renderFg(stack, partialTicks, mouseX, mouseY);
|
||||
protected void renderFg(final GuiGraphics graphics, final float partialTicks, final int mouseX, final int mouseY) {
|
||||
super.renderFg(graphics, partialTicks, mouseX, mouseY);
|
||||
|
||||
if (shouldRenderEnergyBar()) {
|
||||
final int x = leftPos - Sprites.SIDEBAR_2.width + 4;
|
||||
final int y = topPos + ENERGY_TOP + 4;
|
||||
Sprites.ENERGY_BAR.drawFillY(stack, x, y, menu.getEnergy() / (float) menu.getEnergyCapacity());
|
||||
Sprites.ENERGY_BAR.drawFillY(graphics, x, y, menu.getEnergy() / (float) menu.getEnergyCapacity());
|
||||
}
|
||||
|
||||
terminalWidget.render(stack, mouseX, mouseY, menu.getVirtualMachine().getError());
|
||||
terminalWidget.render(graphics, mouseX, mouseY, menu.getVirtualMachine().getError());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(final PoseStack stack, final float partialTicks, final int mouseX, final int mouseY) {
|
||||
Sprites.SIDEBAR_3.draw(stack, leftPos - Sprites.SIDEBAR_3.width, topPos + CONTROLS_TOP);
|
||||
protected void renderBg(final GuiGraphics graphics, final float partialTicks, final int mouseX, final int mouseY) {
|
||||
Sprites.SIDEBAR_3.draw(graphics, leftPos - Sprites.SIDEBAR_3.width, topPos + CONTROLS_TOP);
|
||||
|
||||
if (shouldRenderEnergyBar()) {
|
||||
final int x = leftPos - Sprites.SIDEBAR_2.width;
|
||||
final int y = topPos + ENERGY_TOP;
|
||||
Sprites.SIDEBAR_2.draw(stack, x, y);
|
||||
Sprites.ENERGY_BASE.draw(stack, x + 4, y + 4);
|
||||
Sprites.SIDEBAR_2.draw(graphics, x, y);
|
||||
Sprites.ENERGY_BASE.draw(graphics, x + 4, y + 4);
|
||||
}
|
||||
|
||||
terminalWidget.renderBackground(stack, mouseX, mouseY);
|
||||
terminalWidget.renderBackground(graphics, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderTooltip(final PoseStack stack, final int mouseX, final int mouseY) {
|
||||
super.renderTooltip(stack, mouseX, mouseY);
|
||||
protected void renderTooltip(final GuiGraphics graphics, final int mouseX, final int mouseY) {
|
||||
super.renderTooltip(graphics, mouseX, mouseY);
|
||||
|
||||
if (shouldRenderEnergyBar()) {
|
||||
|
||||
@@ -213,13 +228,13 @@ public abstract class AbstractMachineTerminalScreen<T extends AbstractMachineTer
|
||||
Component.translatable(Constants.TOOLTIP_ENERGY_CONSUMPTION,
|
||||
withFormat(String.valueOf(menu.getEnergyConsumption()), ChatFormatting.GREEN))
|
||||
);
|
||||
TooltipUtils.drawTooltip(stack, tooltip, mouseX, mouseY, 200);
|
||||
//TooltipUtils.drawTooltip(graphics, tooltip, mouseX, mouseY, 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabels(final PoseStack stack, final int mouseX, final int mouseY) {
|
||||
protected void renderLabels(final GuiGraphics graphics, final int mouseX, final int mouseY) {
|
||||
// This is required to prevent the labels from being rendered
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,9 @@ package li.cil.oc2.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.components.Widget;
|
||||
import net.minecraft.client.gui.components.Renderable;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -32,32 +33,32 @@ public abstract class AbstractModContainerScreen<T extends AbstractContainerMenu
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(final PoseStack stack, final int mouseX, final int mouseY, final float partialTicks) {
|
||||
renderBackground(stack);
|
||||
public void render(final GuiGraphics graphics, final int mouseX, final int mouseY, final float partialTicks) {
|
||||
renderBackground(graphics);
|
||||
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
|
||||
super.render(stack, mouseX, mouseY, partialTicks);
|
||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
||||
|
||||
renderFg(stack, partialTicks, mouseX, mouseY);
|
||||
renderFg(graphics, partialTicks, mouseX, mouseY);
|
||||
|
||||
renderTooltip(stack, mouseX, mouseY);
|
||||
renderTooltip(graphics, mouseX, mouseY);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
protected void renderTooltip(final PoseStack stack, final int mouseX, final int mouseY) {
|
||||
super.renderTooltip(stack, mouseX, mouseY);
|
||||
protected void renderTooltip(final GuiGraphics graphics, final int mouseX, final int mouseY) {
|
||||
super.renderTooltip(graphics, mouseX, mouseY);
|
||||
|
||||
for (final Widget widget : renderables) {
|
||||
for (final Renderable widget : renderables) {
|
||||
if (widget instanceof AbstractWidget abstractWidget) {
|
||||
abstractWidget.renderToolTip(stack, mouseX, mouseY);
|
||||
//abstractWidget.renderToolTip(stack, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderFg(final PoseStack stack, final float partialTicks, final int mouseX, final int mouseY) {
|
||||
protected void renderFg(final GuiGraphics graphics, final float partialTicks, final int mouseX, final int mouseY) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,9 @@ import li.cil.oc2.common.blockentity.BusCableBlockEntity;
|
||||
import li.cil.oc2.common.item.Items;
|
||||
import li.cil.oc2.common.network.Network;
|
||||
import li.cil.oc2.common.network.message.BusInterfaceNameMessage;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -48,7 +50,7 @@ public final class BusInterfaceScreen extends Screen {
|
||||
protected void init() {
|
||||
super.init();
|
||||
|
||||
getMinecraft().keyboardHandler.setSendRepeatsToGui(true);
|
||||
//getMinecraft().keyboardHandler.setSendRepeatsToGui(true);
|
||||
|
||||
left = (width - Sprites.BUS_INTERFACE_SCREEN.width) / 2;
|
||||
top = (height - Sprites.BUS_INTERFACE_SCREEN.height) / 2;
|
||||
@@ -68,6 +70,10 @@ public final class BusInterfaceScreen extends Screen {
|
||||
Sprites.CONFIRM_BASE,
|
||||
Sprites.CONFIRM_PRESSED
|
||||
) {
|
||||
@Override
|
||||
protected void updateWidgetNarration(final NarrationElementOutput narrationElementOutput) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPress() {
|
||||
super.onPress();
|
||||
@@ -82,6 +88,10 @@ public final class BusInterfaceScreen extends Screen {
|
||||
Sprites.CANCEL_BASE,
|
||||
Sprites.CANCEL_PRESSED
|
||||
) {
|
||||
@Override
|
||||
protected void updateWidgetNarration(final NarrationElementOutput narrationElementOutput) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPress() {
|
||||
super.onPress();
|
||||
@@ -94,7 +104,7 @@ public final class BusInterfaceScreen extends Screen {
|
||||
public void onClose() {
|
||||
super.onClose();
|
||||
|
||||
getMinecraft().keyboardHandler.setSendRepeatsToGui(false);
|
||||
//getMinecraft().keyboardHandler.setSendRepeatsToGui(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -123,14 +133,14 @@ public final class BusInterfaceScreen extends Screen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(final PoseStack stack, final int mouseX, final int mouseY, final float partialTicks) {
|
||||
renderBackground(stack);
|
||||
Sprites.BUS_INTERFACE_SCREEN.draw(stack, left, top);
|
||||
public void render(final GuiGraphics graphics, final int mouseX, final int mouseY, final float partialTicks) {
|
||||
renderBackground(graphics);
|
||||
Sprites.BUS_INTERFACE_SCREEN.draw(graphics, left, top);
|
||||
|
||||
super.render(stack, mouseX, mouseY, partialTicks);
|
||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
||||
|
||||
RenderSystem.disableBlend();
|
||||
nameField.render(stack, mouseX, mouseY, partialTicks);
|
||||
nameField.render(graphics, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,6 +4,7 @@ package li.cil.oc2.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import li.cil.oc2.common.container.ComputerInventoryContainer;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
@@ -21,8 +22,8 @@ public final class ComputerContainerScreen extends AbstractMachineInventoryScree
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
protected void renderBg(final PoseStack stack, final float partialTicks, final int mouseX, final int mouseY) {
|
||||
super.renderBg(stack, partialTicks, mouseX, mouseY);
|
||||
Sprites.COMPUTER_CONTAINER.draw(stack, leftPos, topPos);
|
||||
protected void renderBg(final GuiGraphics graphics, final float partialTicks, final int mouseX, final int mouseY) {
|
||||
super.renderBg(graphics, partialTicks, mouseX, mouseY);
|
||||
Sprites.COMPUTER_CONTAINER.draw(graphics, leftPos, topPos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,16 @@
|
||||
package li.cil.oc2.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.components.ObjectSelectionList;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextColor;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -120,11 +124,11 @@ public final class FileChooserScreen extends Screen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(final PoseStack stack, final int mouseX, final int mouseY, final float partialTicks) {
|
||||
super.renderBackground(stack);
|
||||
fileList.render(stack, mouseX, mouseY, partialTicks);
|
||||
fileNameTextField.render(stack, mouseX, mouseY, partialTicks);
|
||||
super.render(stack, mouseX, mouseY, partialTicks);
|
||||
public void render(final GuiGraphics graphics, final int mouseX, final int mouseY, final float partialTicks) {
|
||||
super.renderBackground(graphics);
|
||||
fileList.render(graphics, mouseX, mouseY, partialTicks);
|
||||
fileNameTextField.render(graphics, mouseX, mouseY, partialTicks);
|
||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,7 +141,7 @@ public final class FileChooserScreen extends Screen {
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
getMinecraft().keyboardHandler.setSendRepeatsToGui(true);
|
||||
//getMinecraft().keyboardHandler.setSendRepeatsToGui(true);
|
||||
|
||||
final int widgetsWidth = width - MARGIN * 2;
|
||||
final int listHeight = height - MARGIN - WIDGET_SPACING - TEXT_FIELD_HEIGHT - WIDGET_SPACING - BUTTON_HEIGHT - MARGIN;
|
||||
@@ -156,8 +160,8 @@ public final class FileChooserScreen extends Screen {
|
||||
final int buttonTop = fileNameTop + TEXT_FIELD_HEIGHT + WIDGET_SPACING;
|
||||
final int buttonCount = 2;
|
||||
final int buttonWidth = widgetsWidth / buttonCount - (buttonCount - 1) * WIDGET_SPACING;
|
||||
okButton = addRenderableWidget(new Button(MARGIN, buttonTop, buttonWidth, BUTTON_HEIGHT, Component.empty(), this::handleOkPressed));
|
||||
addRenderableWidget(new Button(MARGIN + buttonWidth + WIDGET_SPACING, buttonTop, buttonWidth, BUTTON_HEIGHT, CANCEL_TEXT, this::handleCancelPressed));
|
||||
okButton = addRenderableWidget(new Button(MARGIN, buttonTop, buttonWidth, BUTTON_HEIGHT, Component.empty(), this::handleOkPressed, null));
|
||||
addRenderableWidget(new Button(MARGIN + buttonWidth + WIDGET_SPACING, buttonTop, buttonWidth, BUTTON_HEIGHT, CANCEL_TEXT, this::handleCancelPressed, null));
|
||||
|
||||
fileList.refreshFiles(directory);
|
||||
|
||||
@@ -373,9 +377,15 @@ public final class FileChooserScreen extends Screen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(final PoseStack stack, final int index, final int top, final int left, final int width, final int height,
|
||||
public void render(final GuiGraphics graphics, final int index, final int top, final int left, final int width, final int height,
|
||||
final int mouseX, final int mouseY, final boolean isHovered, final float deltaTime) {
|
||||
font.drawShadow(stack, displayName, left, top, 0xFFFFFFFF);
|
||||
drawShadow(font, graphics, displayName, left, top, 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
private void drawShadow(Font font, GuiGraphics graphics, Component text, float x, float y, int color) {
|
||||
var batch = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
|
||||
font.drawInBatch(text, x, y, color, true, graphics.pose().last().pose(), batch, Font.DisplayMode.NORMAL, 0, 15728880);
|
||||
batch.endBatch();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,6 +11,7 @@ import li.cil.oc2.common.network.Network;
|
||||
import li.cil.oc2.common.network.message.KeyboardInputMessage;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.MouseHandler;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
@@ -90,14 +91,19 @@ public final class KeyboardScreen extends Screen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(final PoseStack stack, final int mouseX, final int mouseY, final float partialTicks) {
|
||||
super.render(stack, mouseX, mouseY, partialTicks);
|
||||
public void render(final GuiGraphics graphics, final int mouseX, final int mouseY, final float partialTicks) {
|
||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
||||
|
||||
renderBorderOverlay(stack);
|
||||
renderBorderOverlay(graphics);
|
||||
|
||||
font.drawWordWrap(CLOSE_INFO,
|
||||
BORDER_SIZE * 3, height - BORDER_SIZE * 3 - font.lineHeight,
|
||||
width - BORDER_SIZE * 6, 0x88FFFFFF);
|
||||
graphics.drawWordWrap(
|
||||
font,
|
||||
CLOSE_INFO,
|
||||
BORDER_SIZE * 3,
|
||||
height - BORDER_SIZE * 3 - font.lineHeight,
|
||||
width - BORDER_SIZE * 6,
|
||||
0x88FFFFFF
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -114,22 +120,22 @@ public final class KeyboardScreen extends Screen {
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
private void renderBorderOverlay(final PoseStack stack) {
|
||||
blitQuad(stack, BORDER_SIZE, BORDER_SIZE, width - BORDER_SIZE, BORDER_SIZE * 2, BORDER_COLOR);
|
||||
blitQuad(stack, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE * 2, height - BORDER_SIZE, BORDER_COLOR);
|
||||
blitQuad(stack, BORDER_SIZE, height - BORDER_SIZE * 2, width - BORDER_SIZE, height - BORDER_SIZE, BORDER_COLOR);
|
||||
blitQuad(stack, width - BORDER_SIZE * 2, BORDER_SIZE, width - BORDER_SIZE, height - BORDER_SIZE, BORDER_COLOR);
|
||||
private void renderBorderOverlay(final GuiGraphics graphics) {
|
||||
blitQuad(graphics, BORDER_SIZE, BORDER_SIZE, width - BORDER_SIZE, BORDER_SIZE * 2, BORDER_COLOR);
|
||||
blitQuad(graphics, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE * 2, height - BORDER_SIZE, BORDER_COLOR);
|
||||
blitQuad(graphics, BORDER_SIZE, height - BORDER_SIZE * 2, width - BORDER_SIZE, height - BORDER_SIZE, BORDER_COLOR);
|
||||
blitQuad(graphics, width - BORDER_SIZE * 2, BORDER_SIZE, width - BORDER_SIZE, height - BORDER_SIZE, BORDER_COLOR);
|
||||
}
|
||||
|
||||
private void blitQuad(final PoseStack stack, final int x0, final int y0, final int x1, final int y1, final int color) {
|
||||
private void blitQuad(final GuiGraphics graphics, final int x0, final int y0, final int x1, final int y1, final int color) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionColorShader);
|
||||
final Tesselator tesselator = Tesselator.getInstance();
|
||||
final BufferBuilder builder = tesselator.getBuilder();
|
||||
builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
|
||||
builder.vertex(stack.last().pose(), x0, y1, getBlitOffset()).color(color).endVertex();
|
||||
builder.vertex(stack.last().pose(), x1, y1, getBlitOffset()).color(color).endVertex();
|
||||
builder.vertex(stack.last().pose(), x1, y0, getBlitOffset()).color(color).endVertex();
|
||||
builder.vertex(stack.last().pose(), x0, y0, getBlitOffset()).color(color).endVertex();
|
||||
builder.vertex(graphics.pose().last().pose(), x0, y1, 0).color(color).endVertex();
|
||||
builder.vertex(graphics.pose().last().pose(), x1, y1, 0).color(color).endVertex();
|
||||
builder.vertex(graphics.pose().last().pose(), x1, y0, 0).color(color).endVertex();
|
||||
builder.vertex(graphics.pose().last().pose(), x0, y0, 0).color(color).endVertex();
|
||||
tesselator.end();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,13 +3,15 @@
|
||||
package li.cil.oc2.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import org.joml.Matrix4f;
|
||||
import li.cil.oc2.client.gui.terminal.TerminalInput;
|
||||
import li.cil.oc2.common.container.AbstractMachineTerminalContainer;
|
||||
import li.cil.oc2.common.vm.Terminal;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -19,7 +21,7 @@ import javax.annotation.Nullable;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public final class MachineTerminalWidget extends GuiComponent {
|
||||
public final class MachineTerminalWidget {
|
||||
private static final int TERMINAL_WIDTH = Terminal.WIDTH * Terminal.CHAR_WIDTH / 2;
|
||||
private static final int TERMINAL_HEIGHT = Terminal.HEIGHT * Terminal.CHAR_HEIGHT / 2;
|
||||
|
||||
@@ -47,27 +49,28 @@ public final class MachineTerminalWidget extends GuiComponent {
|
||||
this.terminal = this.container.getTerminal();
|
||||
}
|
||||
|
||||
public void renderBackground(final PoseStack stack, final int mouseX, final int mouseY) {
|
||||
public void renderBackground(final GuiGraphics graphics, final int mouseX, final int mouseY) {
|
||||
isMouseOverTerminal = isMouseOverTerminal(mouseX, mouseY);
|
||||
|
||||
Sprites.TERMINAL_SCREEN.draw(stack, leftPos, topPos);
|
||||
Sprites.TERMINAL_SCREEN.draw(graphics, leftPos, topPos);
|
||||
|
||||
if (shouldCaptureInput()) {
|
||||
Sprites.TERMINAL_FOCUSED.draw(stack, leftPos, topPos);
|
||||
Sprites.TERMINAL_FOCUSED.draw(graphics, leftPos, topPos);
|
||||
}
|
||||
}
|
||||
|
||||
public void render(final PoseStack stack, final int mouseX, final int mouseY, @Nullable final Component error) {
|
||||
public void render(final GuiGraphics graphics, final int mouseX, final int mouseY, @Nullable final Component error) {
|
||||
if (container.getVirtualMachine().isRunning()) {
|
||||
final PoseStack terminalStack = new PoseStack();
|
||||
terminalStack.translate(leftPos + TERMINAL_X, topPos + TERMINAL_Y, getClient().getItemRenderer().blitOffset);
|
||||
terminalStack.translate(leftPos + TERMINAL_X, topPos + TERMINAL_Y, 0); //TODO: REPLACE 0 with blitOffset fix
|
||||
terminalStack.scale(TERMINAL_WIDTH / (float) terminal.getWidth(), TERMINAL_HEIGHT / (float) terminal.getHeight(), 1f);
|
||||
|
||||
if (rendererView == null) {
|
||||
rendererView = terminal.getRenderer();
|
||||
}
|
||||
|
||||
final Matrix4f projectionMatrix = Matrix4f.orthographic(0, parent.width, 0, parent.height, -10, 10f);
|
||||
//final Matrix4f projectionMatrix = orthographic(0, parent.width, 0, parent.height, -10, 10f);
|
||||
final Matrix4f projectionMatrix = new Matrix4f().ortho(0, parent.width, 0, parent.height, -10, 10f);
|
||||
rendererView.render(terminalStack, projectionMatrix);
|
||||
} else {
|
||||
final Font font = getClient().font;
|
||||
@@ -75,15 +78,38 @@ public final class MachineTerminalWidget extends GuiComponent {
|
||||
final int textWidth = font.width(error);
|
||||
final int textOffsetX = (TERMINAL_WIDTH - textWidth) / 2;
|
||||
final int textOffsetY = (TERMINAL_HEIGHT - font.lineHeight) / 2;
|
||||
font.drawShadow(stack,
|
||||
drawShadow(
|
||||
font,
|
||||
graphics,
|
||||
error,
|
||||
leftPos + TERMINAL_X + textOffsetX,
|
||||
topPos + TERMINAL_Y + textOffsetY,
|
||||
0xEE3322);
|
||||
0xEE3322
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void drawShadow(Font font, GuiGraphics graphics, Component text, float x, float y, int color) {
|
||||
var batch = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
|
||||
font.drawInBatch(text, x, y, color, true, graphics.pose().last().pose(), batch, Font.DisplayMode.NORMAL, 0, 15728880);
|
||||
batch.endBatch();
|
||||
}
|
||||
|
||||
private static Matrix4f orthographic(float pMinX, float pMaxX, float pMinY, float pMaxY, float pMinZ, float pMaxZ) {
|
||||
Matrix4f matrix4f = new Matrix4f();
|
||||
float f = pMaxX - pMinX;
|
||||
float f1 = pMinY - pMaxY;
|
||||
float f2 = pMaxZ - pMinZ;
|
||||
matrix4f.set(
|
||||
2.0F / f, 0, 0, -(pMaxX + pMinX) / f,
|
||||
0, 2.0F / f1, 0, -(pMinY + pMaxY) / f1,
|
||||
0, 0, -2.0F / f2, -(pMaxZ + pMinZ) / f2,
|
||||
0, 0, 0, 1.0F
|
||||
);
|
||||
return matrix4f;
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
final ByteBuffer input = terminal.getInput();
|
||||
if (input != null) {
|
||||
@@ -124,11 +150,11 @@ public final class MachineTerminalWidget extends GuiComponent {
|
||||
this.leftPos = (parent.width - WIDTH) / 2;
|
||||
this.topPos = (parent.height - HEIGHT) / 2;
|
||||
|
||||
getClient().keyboardHandler.setSendRepeatsToGui(true);
|
||||
//getClient().keyboardHandler.setSendRepeatsToGui(true);
|
||||
}
|
||||
|
||||
public void onClose() {
|
||||
getClient().keyboardHandler.setSendRepeatsToGui(false);
|
||||
//getClient().keyboardHandler.setSendRepeatsToGui(false);
|
||||
if (rendererView != null) {
|
||||
terminal.releaseRenderer(rendererView);
|
||||
rendererView = null;
|
||||
|
||||
@@ -6,8 +6,10 @@ import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Quaternion;
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import li.cil.oc2.client.gui.widget.Texture;
|
||||
import li.cil.oc2.client.renderer.ModRenderType;
|
||||
import li.cil.oc2.common.item.Items;
|
||||
@@ -147,11 +149,11 @@ public final class NetworkInterfaceCardScreen extends Screen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(final PoseStack stack, final int mouseX, final int mouseY, final float partialTicks) {
|
||||
renderBackground(stack);
|
||||
Sprites.NETWORK_INTERFACE_CARD_SCREEN.draw(stack, left, top);
|
||||
public void render(final GuiGraphics graphics, final int mouseX, final int mouseY, final float partialTicks) {
|
||||
renderBackground(graphics);
|
||||
Sprites.NETWORK_INTERFACE_CARD_SCREEN.draw(graphics, left, top);
|
||||
|
||||
super.render(stack, mouseX, mouseY, partialTicks);
|
||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
||||
|
||||
final int blockX = left + BLOCK_LEFT;
|
||||
final int blockY = top + BLOCK_TOP;
|
||||
@@ -161,10 +163,10 @@ public final class NetworkInterfaceCardScreen extends Screen {
|
||||
if (focusedSide != null) {
|
||||
final Component enabledComponent = getConfiguration(focusedSide) ? CONNECTIVITY_ENABLED_TEXT : CONNECTIVITY_DISABLED_TEXT;
|
||||
final MutableComponent tooltip = Component.translatable(SIDE_STATE_TEXT, enabledComponent);
|
||||
renderTooltip(stack, tooltip, mouseX, mouseY);
|
||||
//renderTooltip(stack, tooltip, mouseX, mouseY);
|
||||
}
|
||||
|
||||
font.drawWordWrap(INFO_TEXT, left + INFO_TEXT_LEFT, top + INFO_TEXT_TOP, INFO_TEXT_WIDTH, 0xAAAAAA);
|
||||
graphics.drawWordWrap(font, INFO_TEXT, left + INFO_TEXT_LEFT, top + INFO_TEXT_TOP, INFO_TEXT_WIDTH, 0xAAAAAA);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -195,8 +197,8 @@ public final class NetworkInterfaceCardScreen extends Screen {
|
||||
@Nullable
|
||||
private Direction getFocusedSide(final float mouseX, final float mouseY, final Vector3f rotation) {
|
||||
// Rotate ray inversely around block to represent visual block rotation.
|
||||
final Quaternion quaternion = Quaternion.fromXYZDegrees(rotation);
|
||||
quaternion.conj();
|
||||
final Quaternionf quaternion = new Quaternionf().rotateXYZ(rotation.x, rotation.y, rotation.z);
|
||||
quaternion.conjugate();
|
||||
|
||||
// Move ray in screen space to mouse position.
|
||||
final float relMouseX = -mouseX / (float) BLOCK_RENDER_SIZE;
|
||||
@@ -204,11 +206,11 @@ public final class NetworkInterfaceCardScreen extends Screen {
|
||||
|
||||
final Vector3f source = new Vector3f();
|
||||
source.add(relMouseX, relMouseY, 1);
|
||||
source.transform(quaternion);
|
||||
source.rotate(quaternion);
|
||||
|
||||
final Vector3f target = new Vector3f();
|
||||
target.add(relMouseX, relMouseY, -1);
|
||||
target.transform(quaternion);
|
||||
target.rotate(quaternion);
|
||||
|
||||
// Intersect rotated ray with bounding box representing block.
|
||||
final AABB aabb = new AABB(-0.5, -0.5, -0.5, 0.5, 0.5, 0.5);
|
||||
@@ -224,13 +226,13 @@ public final class NetworkInterfaceCardScreen extends Screen {
|
||||
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
|
||||
final Vector3f renderRotation = rotation.copy();
|
||||
final Vector3f renderRotation = new Vector3f(rotation.x, rotation.y, rotation.z);
|
||||
renderRotation.add(0, 180, 0);
|
||||
|
||||
final PoseStack stack = RenderSystem.getModelViewStack();
|
||||
stack.pushPose();
|
||||
stack.translate(x, y, 0);
|
||||
stack.mulPose(Quaternion.fromXYZDegrees(renderRotation));
|
||||
stack.mulPose(new Quaternionf().rotateXYZ(renderRotation.x, renderRotation.y, renderRotation.z));
|
||||
stack.scale(BLOCK_RENDER_SIZE, -BLOCK_RENDER_SIZE, BLOCK_RENDER_SIZE);
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
|
||||
@@ -244,7 +246,7 @@ public final class NetworkInterfaceCardScreen extends Screen {
|
||||
}
|
||||
|
||||
private void renderBlock(final MultiBufferSource.BufferSource bufferSource) {
|
||||
itemRenderer.render(computerItemStack, ItemTransforms.TransformType.NONE, false, new PoseStack(), bufferSource, 0xF000F0, OverlayTexture.NO_OVERLAY, model);
|
||||
itemRenderer.render(computerItemStack, ItemDisplayContext.NONE, false, new PoseStack(), bufferSource, 0xF000F0, OverlayTexture.NO_OVERLAY, model);
|
||||
}
|
||||
|
||||
private void renderOverlays(final PoseStack poseStack, final MultiBufferSource.BufferSource bufferSource) {
|
||||
@@ -267,7 +269,7 @@ public final class NetworkInterfaceCardScreen extends Screen {
|
||||
case EAST -> new Vector3f(0, 90, 0);
|
||||
default -> throw new IllegalStateException("Unexpected value: " + side);
|
||||
};
|
||||
poseStack.mulPose(Quaternion.fromXYZDegrees(sideRotation));
|
||||
poseStack.mulPose(new Quaternionf().rotateXYZ(sideRotation.x, sideRotation.y, sideRotation.z));
|
||||
|
||||
poseStack.translate(-0.5, -0.5, 0);
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ import li.cil.oc2.client.gui.widget.ImageButton;
|
||||
import li.cil.oc2.common.container.NetworkTunnelContainer;
|
||||
import li.cil.oc2.common.network.Network;
|
||||
import li.cil.oc2.common.network.message.NetworkTunnelLinkMessage;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
@@ -35,13 +37,13 @@ public final class NetworkTunnelScreen extends AbstractModContainerScreen<Networ
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void render(final PoseStack stack, final int mouseX, final int mouseY, final float partialTicks) {
|
||||
renderBackground(stack);
|
||||
public void render(final GuiGraphics graphics, final int mouseX, final int mouseY, final float partialTicks) {
|
||||
renderBackground(graphics);
|
||||
|
||||
linkButton.active = getMenu().hasLinkSlotItem();
|
||||
|
||||
super.render(stack, mouseX, mouseY, partialTicks);
|
||||
renderTooltip(stack, mouseX, mouseY);
|
||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
||||
renderTooltip(graphics, mouseX, mouseY);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
@@ -55,6 +57,10 @@ public final class NetworkTunnelScreen extends AbstractModContainerScreen<Networ
|
||||
Sprites.NETWORK_TUNNEL_LINK_BUTTON_INACTIVE.width, Sprites.NETWORK_TUNNEL_LINK_BUTTON_INACTIVE.height,
|
||||
Sprites.NETWORK_TUNNEL_LINK_BUTTON_INACTIVE,
|
||||
Sprites.NETWORK_TUNNEL_LINK_BUTTON_ACTIVE) {
|
||||
@Override
|
||||
protected void updateWidgetNarration(final NarrationElementOutput narrationElementOutput) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPress() {
|
||||
super.onPress();
|
||||
@@ -64,11 +70,11 @@ public final class NetworkTunnelScreen extends AbstractModContainerScreen<Networ
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(final PoseStack stack, final float partialTicks, final int mouseX, final int mouseY) {
|
||||
protected void renderBg(final GuiGraphics graphics, final float partialTicks, final int mouseX, final int mouseY) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
|
||||
Sprites.NETWORK_TUNNEL_SCREEN.draw(stack, leftPos, topPos);
|
||||
Sprites.NETWORK_TUNNEL_SCREEN.draw(graphics, leftPos, topPos);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -5,6 +5,7 @@ package li.cil.oc2.client.gui;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import li.cil.oc2.common.container.RobotInventoryContainer;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
@@ -17,14 +18,14 @@ public final class RobotContainerScreen extends AbstractMachineInventoryScreen<R
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
public static void renderSelection(final PoseStack stack, final int selectedSlot, final int x, final int y, final int columns) {
|
||||
public static void renderSelection(final GuiGraphics graphics, final int selectedSlot, final int x, final int y, final int columns) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
|
||||
final int slotX = (selectedSlot % columns) * SLOT_SIZE;
|
||||
final int slotY = (selectedSlot / columns) * SLOT_SIZE;
|
||||
final int offset = SLOT_SIZE * (int) (15 * (System.currentTimeMillis() % 1000) / 1000);
|
||||
Sprites.SLOT_SELECTION.draw(stack, x + slotX, y + slotY, 0, offset);
|
||||
Sprites.SLOT_SELECTION.draw(graphics, x + slotX, y + slotY, 0, offset);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
@@ -39,10 +40,10 @@ public final class RobotContainerScreen extends AbstractMachineInventoryScreen<R
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
protected void renderBg(final PoseStack stack, final float partialTicks, final int mouseX, final int mouseY) {
|
||||
super.renderBg(stack, partialTicks, mouseX, mouseY);
|
||||
protected void renderBg(final GuiGraphics graphics, final float partialTicks, final int mouseX, final int mouseY) {
|
||||
super.renderBg(graphics, partialTicks, mouseX, mouseY);
|
||||
|
||||
Sprites.ROBOT_CONTAINER.draw(stack, leftPos, topPos);
|
||||
renderSelection(stack, menu.getRobot().getSelectedSlot(), leftPos + 115, topPos + 23, 3);
|
||||
Sprites.ROBOT_CONTAINER.draw(graphics, leftPos, topPos);
|
||||
renderSelection(graphics, menu.getRobot().getSelectedSlot(), leftPos + 115, topPos + 23, 3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ package li.cil.oc2.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import li.cil.oc2.common.container.RobotTerminalContainer;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
@@ -28,11 +29,11 @@ public final class RobotTerminalScreen extends AbstractMachineTerminalScreen<Rob
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
protected void renderBg(final PoseStack stack, final float partialTicks, final int mouseX, final int mouseY) {
|
||||
Sprites.HOTBAR.draw(stack, leftPos + SLOTS_X, topPos + SLOTS_Y);
|
||||
RobotContainerScreen.renderSelection(stack, menu.getRobot().getSelectedSlot(), leftPos + SLOTS_X + 4, topPos + SLOTS_Y + 4, 12);
|
||||
protected void renderBg(final GuiGraphics graphics, final float partialTicks, final int mouseX, final int mouseY) {
|
||||
Sprites.HOTBAR.draw(graphics, leftPos + SLOTS_X, topPos + SLOTS_Y);
|
||||
RobotContainerScreen.renderSelection(graphics, menu.getRobot().getSelectedSlot(), leftPos + SLOTS_X + 4, topPos + SLOTS_Y + 4, 12);
|
||||
|
||||
super.renderBg(stack, partialTicks, mouseX, mouseY);
|
||||
super.renderBg(graphics, partialTicks, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,6 +10,7 @@ import li.cil.oc2.common.container.DeviceTypeSlotItemHandler;
|
||||
import li.cil.oc2.common.util.TooltipUtils;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
@@ -36,20 +37,20 @@ public final class GuiUtils {
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
public static <TContainer extends AbstractContainerMenu> void renderMissingDeviceInfoIcon(final PoseStack stack, final AbstractContainerScreen<TContainer> screen, final DeviceType type, final Sprite icon) {
|
||||
stack.pushPose();
|
||||
stack.translate(0, 0, 100);
|
||||
findFirstSlotOfTypeIfAllSlotsOfTypeEmpty(screen.getMenu(), type).ifPresent(slot -> icon.draw(stack,
|
||||
public static <TContainer extends AbstractContainerMenu> void renderMissingDeviceInfoIcon(final GuiGraphics graphics, final AbstractContainerScreen<TContainer> screen, final DeviceType type, final Sprite icon) {
|
||||
graphics.pose().pushPose();
|
||||
graphics.pose().translate(0, 0, 100);
|
||||
findFirstSlotOfTypeIfAllSlotsOfTypeEmpty(screen.getMenu(), type).ifPresent(slot -> icon.draw(graphics,
|
||||
screen.getGuiLeft() + slot.x - 1 + RELATIVE_ICON_POSITION,
|
||||
screen.getGuiTop() + slot.y - 1 + RELATIVE_ICON_POSITION));
|
||||
stack.popPose();
|
||||
graphics.pose().popPose();
|
||||
}
|
||||
|
||||
public static <TContainer extends AbstractContainerMenu> void renderMissingDeviceInfoTooltip(final PoseStack stack, final AbstractContainerScreen<TContainer> screen, final int mouseX, final int mouseY, final DeviceType type) {
|
||||
renderMissingDeviceInfoTooltip(stack, screen, mouseX, mouseY, type, Objects.requireNonNull(WARNING_BY_DEVICE_TYPE.get(type)));
|
||||
public static <TContainer extends AbstractContainerMenu> void renderMissingDeviceInfoTooltip(final GuiGraphics graphics, final AbstractContainerScreen<TContainer> screen, final int mouseX, final int mouseY, final DeviceType type) {
|
||||
renderMissingDeviceInfoTooltip(graphics, screen, mouseX, mouseY, type, Objects.requireNonNull(WARNING_BY_DEVICE_TYPE.get(type)));
|
||||
}
|
||||
|
||||
public static <TContainer extends AbstractContainerMenu> void renderMissingDeviceInfoTooltip(final PoseStack stack, final AbstractContainerScreen<TContainer> screen, final int mouseX, final int mouseY, final DeviceType type, final Component tooltip) {
|
||||
public static <TContainer extends AbstractContainerMenu> void renderMissingDeviceInfoTooltip(final GuiGraphics graphics, final AbstractContainerScreen<TContainer> screen, final int mouseX, final int mouseY, final DeviceType type, final Component tooltip) {
|
||||
final Minecraft minecraft = screen.getMinecraft();
|
||||
if (minecraft.player == null) {
|
||||
return;
|
||||
@@ -67,7 +68,7 @@ public final class GuiUtils {
|
||||
|
||||
findFirstSlotOfTypeIfAllSlotsOfTypeEmpty(screen.getMenu(), type).ifPresent(slot -> {
|
||||
if (slot == hoveredSlot) {
|
||||
TooltipUtils.drawTooltip(stack, Collections.singletonList(tooltip), mouseX, mouseY);
|
||||
//TooltipUtils.drawTooltip(graphics, Collections.singletonList(tooltip), mouseX, mouseY);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import li.cil.oc2.common.util.TooltipUtils;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.AbstractButton;
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -61,39 +62,13 @@ public abstract class ImageButton extends AbstractButton {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderButton(final PoseStack stack, final int mouseX, final int mouseY, final float partialTicks) {
|
||||
renderBackground(stack, mouseX, mouseY, partialTicks);
|
||||
|
||||
renderToolTip(stack, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderToolTip(final PoseStack stack, final int mouseX, final int mouseY) {
|
||||
if (tooltip.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isHoveredOrFocused()) {
|
||||
if (hoveringStartedAt == 0) {
|
||||
hoveringStartedAt = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
if ((System.currentTimeMillis() - hoveringStartedAt) > TOOLTIP_DELAY) {
|
||||
TooltipUtils.drawTooltip(stack, tooltip, mouseX, mouseY, 200);
|
||||
}
|
||||
} else {
|
||||
hoveringStartedAt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNarration(final NarrationElementOutput element) {
|
||||
this.defaultButtonNarrationText(element);
|
||||
public void renderWidget(final GuiGraphics graphics, final int mouseX, final int mouseY, final float partialTicks) {
|
||||
renderBackground(graphics, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
protected void renderBackground(final PoseStack stack, final int mouseX, final int mouseY, final float partialTicks) {
|
||||
protected void renderBackground(final GuiGraphics graphics, final int mouseX, final int mouseY, final float partialTicks) {
|
||||
RenderSystem.enableDepthTest();
|
||||
|
||||
Sprite background = baseImage;
|
||||
@@ -101,10 +76,10 @@ public abstract class ImageButton extends AbstractButton {
|
||||
background = pressedImage;
|
||||
}
|
||||
|
||||
background.draw(stack, x, y);
|
||||
background.draw(graphics, x, y);
|
||||
|
||||
if (!Objects.equals(getMessage(), Component.empty())) {
|
||||
drawCenteredString(stack, Minecraft.getInstance().font, getMessage(),
|
||||
graphics.drawCenteredString(Minecraft.getInstance().font, getMessage(),
|
||||
x + width / 2, y + (height - 8) / 2,
|
||||
getFGColor() | Mth.ceil(alpha * 255) << 24);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
package li.cil.oc2.client.gui.widget;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
public final class Sprite {
|
||||
@@ -31,21 +30,16 @@ public final class Sprite {
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
public void draw(final PoseStack stack, final int x, final int y) {
|
||||
draw(stack, x, y, 0, 0);
|
||||
public void draw(final GuiGraphics graphics, final int x, final int y) {
|
||||
draw(graphics, x, y, 0, 0);
|
||||
}
|
||||
|
||||
public void draw(final PoseStack stack, final int x, final int y, final int uOffset, final int vOffset) {
|
||||
blit(stack, x, y, u0 + uOffset, v0 + vOffset, width, height);
|
||||
public void draw(final GuiGraphics graphics, final int x, final int y, final int uOffset, final int vOffset) {
|
||||
graphics.blit(texture.location, x, y, u0 + uOffset, v0 + vOffset, width, height);
|
||||
}
|
||||
|
||||
public void drawFillY(final PoseStack stack, final int x, final int y, final float value) {
|
||||
public void drawFillY(final GuiGraphics graphics, final int x, final int y, final float value) {
|
||||
final int h = (int) (this.height * Mth.clamp(value, 0, 1));
|
||||
blit(stack, x, y + (height - h), u0, v0 + (height - h), width, h);
|
||||
}
|
||||
|
||||
private void blit(final PoseStack stack, final int x, final int y, final int u0, final int v0, final int width, final int height) {
|
||||
texture.bind();
|
||||
GuiComponent.blit(stack, x, y, u0, v0, width, height, texture.width, texture.height);
|
||||
graphics.blit(texture.location, x, y + (height - h), u0, v0 + (height - h), width, h);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,4 @@ public final class Texture {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public void bind() {
|
||||
RenderSystem.setShaderTexture(0, location);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package li.cil.oc2.client.gui.widget;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
|
||||
public abstract class ToggleImageButton extends ImageButton {
|
||||
private final Sprite activeImage;
|
||||
@@ -31,10 +32,10 @@ public abstract class ToggleImageButton extends ImageButton {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBackground(final PoseStack stack, final int mouseX, final int mouseY, final float partialTicks) {
|
||||
super.renderBackground(stack, mouseX, mouseY, partialTicks);
|
||||
protected void renderBackground(final GuiGraphics graphics, final int mouseX, final int mouseY, final float partialTicks) {
|
||||
super.renderBackground(graphics, mouseX, mouseY, partialTicks);
|
||||
if (isToggled()) {
|
||||
activeImage.draw(stack, x, y);
|
||||
activeImage.draw(graphics, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,6 @@ public final class ModManualStyle implements ManualStyle {
|
||||
|
||||
@Override
|
||||
public SoundEvent getPageChangeSound() {
|
||||
return SoundEvents.UI_BUTTON_CLICK;
|
||||
return SoundEvents.UI_BUTTON_CLICK.value();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,30 +30,22 @@ public final class BusCableModel implements IUnbakedGeometry<BusCableModel> {
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public BakedModel bake(final IGeometryBakingContext owner, final ModelBakery bakery, final Function<Material, TextureAtlasSprite> spriteGetter, final ModelState modelTransform, final ItemOverrides overrides, final ResourceLocation modelLocation) {
|
||||
final BakedModel bakedBaseModel = proxy.bake(owner, bakery, spriteGetter, modelTransform, overrides, modelLocation);
|
||||
public BakedModel bake(final IGeometryBakingContext owner, final ModelBaker baker, final Function<Material, TextureAtlasSprite> spriteGetter, final ModelState modelTransform, final ItemOverrides overrides, final ResourceLocation modelLocation) {
|
||||
final BakedModel bakedBaseModel = proxy.bake(owner, baker, spriteGetter, modelTransform, overrides, modelLocation);
|
||||
final BakedModel[] straightModelByAxis = {
|
||||
requireNonNull(bakery.bake(BUS_CABLE_STRAIGHT_MODEL, BlockModelRotation.X0_Y90, spriteGetter)),
|
||||
requireNonNull(bakery.bake(BUS_CABLE_STRAIGHT_MODEL, BlockModelRotation.X90_Y0, spriteGetter)),
|
||||
requireNonNull(bakery.bake(BUS_CABLE_STRAIGHT_MODEL, modelTransform, spriteGetter))
|
||||
requireNonNull(baker.bake(BUS_CABLE_STRAIGHT_MODEL, BlockModelRotation.X0_Y90, spriteGetter)),
|
||||
requireNonNull(baker.bake(BUS_CABLE_STRAIGHT_MODEL, BlockModelRotation.X90_Y0, spriteGetter)),
|
||||
requireNonNull(baker.bake(BUS_CABLE_STRAIGHT_MODEL, modelTransform, spriteGetter))
|
||||
};
|
||||
final BakedModel[] supportModelByFace = {
|
||||
requireNonNull(bakery.bake(BUS_CABLE_SUPPORT_MODEL, BlockModelRotation.X270_Y0, spriteGetter)), // -y
|
||||
requireNonNull(bakery.bake(BUS_CABLE_SUPPORT_MODEL, BlockModelRotation.X90_Y0, spriteGetter)), // +y
|
||||
requireNonNull(bakery.bake(BUS_CABLE_SUPPORT_MODEL, BlockModelRotation.X0_Y180, spriteGetter)), // -z
|
||||
requireNonNull(bakery.bake(BUS_CABLE_SUPPORT_MODEL, modelTransform, spriteGetter)), // +z
|
||||
requireNonNull(bakery.bake(BUS_CABLE_SUPPORT_MODEL, BlockModelRotation.X0_Y90, spriteGetter)), // -x
|
||||
requireNonNull(bakery.bake(BUS_CABLE_SUPPORT_MODEL, BlockModelRotation.X0_Y270, spriteGetter)) // +x
|
||||
requireNonNull(baker.bake(BUS_CABLE_SUPPORT_MODEL, BlockModelRotation.X270_Y0, spriteGetter)), // -y
|
||||
requireNonNull(baker.bake(BUS_CABLE_SUPPORT_MODEL, BlockModelRotation.X90_Y0, spriteGetter)), // +y
|
||||
requireNonNull(baker.bake(BUS_CABLE_SUPPORT_MODEL, BlockModelRotation.X0_Y180, spriteGetter)), // -z
|
||||
requireNonNull(baker.bake(BUS_CABLE_SUPPORT_MODEL, modelTransform, spriteGetter)), // +z
|
||||
requireNonNull(baker.bake(BUS_CABLE_SUPPORT_MODEL, BlockModelRotation.X0_Y90, spriteGetter)), // -x
|
||||
requireNonNull(baker.bake(BUS_CABLE_SUPPORT_MODEL, BlockModelRotation.X0_Y270, spriteGetter)) // +x
|
||||
};
|
||||
|
||||
return new BusCableBakedModel(proxy.bake(owner, bakery, spriteGetter, modelTransform, overrides, modelLocation), straightModelByAxis, supportModelByFace);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Material> getMaterials(final IGeometryBakingContext owner, final Function<ResourceLocation, UnbakedModel> modelGetter, final Set<Pair<String, String>> missingTextureErrors) {
|
||||
final ArrayList<Material> textures = new ArrayList<>(proxy.getMaterials(owner, modelGetter, missingTextureErrors));
|
||||
textures.addAll(modelGetter.apply(BUS_CABLE_STRAIGHT_MODEL).getMaterials(modelGetter, missingTextureErrors));
|
||||
textures.addAll(modelGetter.apply(BUS_CABLE_SUPPORT_MODEL).getMaterials(modelGetter, missingTextureErrors));
|
||||
return textures;
|
||||
return new BusCableBakedModel(proxy.bake(owner, baker, spriteGetter, modelTransform, overrides, modelLocation), straightModelByAxis, supportModelByFace);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package li.cil.oc2.client.renderer;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import org.joml.Matrix4f;
|
||||
import li.cil.oc2.common.block.BusCableBlock;
|
||||
import li.cil.oc2.common.blockentity.BusCableBlockEntity;
|
||||
import li.cil.oc2.common.integration.Wrenches;
|
||||
@@ -45,7 +45,7 @@ public enum BusInterfaceNameRenderer {
|
||||
return;
|
||||
}
|
||||
|
||||
final Level level = player.level;
|
||||
final Level level = player.level();
|
||||
|
||||
if (!Wrenches.isHoldingWrench(player)) {
|
||||
return;
|
||||
@@ -99,9 +99,9 @@ public enum BusInterfaceNameRenderer {
|
||||
final int packedLight = LightTexture.pack(15, 15);
|
||||
|
||||
font.drawInBatch(name, horizontalTextOffset, 0, 0xffffffff,
|
||||
false, matrix, buffer, true, backgroundColor, packedLight);
|
||||
false, matrix, buffer, Font.DisplayMode.POLYGON_OFFSET, backgroundColor, packedLight);
|
||||
font.drawInBatch(name, horizontalTextOffset, 0, 0xffffffff,
|
||||
false, matrix, buffer, false, 0, packedLight);
|
||||
false, matrix, buffer, Font.DisplayMode.NORMAL, 0, packedLight);
|
||||
|
||||
buffer.endBatch();
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ package li.cil.oc2.client.renderer;
|
||||
|
||||
import com.mojang.blaze3d.pipeline.RenderTarget;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import org.joml.Matrix4f;
|
||||
import li.cil.oc2.api.API;
|
||||
import net.minecraft.client.renderer.ShaderInstance;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
@@ -67,7 +67,7 @@ public final class ModShaders {
|
||||
@SubscribeEvent
|
||||
public static void handleRegisterShaders(final RegisterShadersEvent event) throws IOException {
|
||||
event.registerShader(new ShaderInstance(
|
||||
event.getResourceManager(),
|
||||
event.getResourceProvider(),
|
||||
PROJECTORS_SHADER_LOCATION,
|
||||
DefaultVertexFormat.POSITION_TEX
|
||||
), instance -> projectorsShader = instance);
|
||||
|
||||
@@ -4,8 +4,10 @@ package li.cil.oc2.client.renderer;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Vector3f;
|
||||
import li.cil.oc2.common.util.Vec3Utils;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3f;
|
||||
import li.cil.oc2.api.API;
|
||||
import li.cil.oc2.common.blockentity.NetworkConnectorBlockEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -183,13 +185,13 @@ public final class NetworkCableRenderer {
|
||||
final Vec3 p = quadraticBezier(p0, p1, p2, t);
|
||||
final Vec3 n = getExtrusionVector(eye, p, connection.forward);
|
||||
|
||||
final BlockPos blockPos = new BlockPos(p);
|
||||
final BlockPos blockPos = new BlockPos(Vec3Utils.round(p));
|
||||
final int blockLight = level.getBrightness(LightLayer.BLOCK, blockPos);
|
||||
final int skyLight = level.getBrightness(LightLayer.SKY, blockPos);
|
||||
final int packedLight = LightTexture.pack(blockLight, skyLight);
|
||||
|
||||
final Vector3f v0 = new Vector3f(p.subtract(n));
|
||||
final Vector3f v1 = new Vector3f(p.add(n));
|
||||
final Vector3f v0 = p.subtract(n).toVector3f();
|
||||
final Vector3f v1 = p.add(n).toVector3f();
|
||||
|
||||
cablePoints.add(new CablePoint(v0, v1, packedLight));
|
||||
}
|
||||
|
||||
@@ -13,9 +13,11 @@ import com.mojang.blaze3d.platform.NativeImage;
|
||||
import com.mojang.blaze3d.platform.TextureUtil;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.*;
|
||||
import com.mojang.math.Matrix3f;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraftforge.client.event.ViewportEvent;
|
||||
import org.joml.Matrix3f;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import li.cil.oc2.common.block.ProjectorBlock;
|
||||
import li.cil.oc2.common.blockentity.ProjectorBlockEntity;
|
||||
import li.cil.oc2.common.bus.device.vm.block.ProjectorDevice;
|
||||
@@ -203,7 +205,7 @@ public final class ProjectorDepthRenderer {
|
||||
* Suppresses fog rendering while rendering depth buffer for projectors.
|
||||
*/
|
||||
@SubscribeEvent
|
||||
public static void handleFog(final EntityRenderersEvent event) {
|
||||
public static void handleFog(final ViewportEvent.RenderFog event) {
|
||||
if (isRenderingProjectorDepth) {
|
||||
FogRenderer.setupNoFog();
|
||||
}
|
||||
@@ -249,7 +251,7 @@ public final class ProjectorDepthRenderer {
|
||||
|
||||
configureProjectorDepthCamera(level, projectorPos, facing.toYRot());
|
||||
|
||||
RenderSystem.setProjectionMatrix(DEPTH_CAMERA_PROJECTION_MATRIX);
|
||||
RenderSystem.setProjectionMatrix(DEPTH_CAMERA_PROJECTION_MATRIX, null);
|
||||
setupViewModelMatrix(viewModelStack);
|
||||
|
||||
storeProjectorMatrix(projectorIndex, projectorPos, mainCameraPosition, viewModelStack);
|
||||
@@ -307,25 +309,23 @@ public final class ProjectorDepthRenderer {
|
||||
|
||||
private static void setupViewModelMatrix(final PoseStack viewModelStack) {
|
||||
viewModelStack.setIdentity();
|
||||
viewModelStack.mulPose(Vector3f.YP.rotationDegrees(PROJECTOR_DEPTH_CAMERA.getYRot() + 180));
|
||||
viewModelStack.mulPose(new Quaternionf().rotateY((float) Math.toRadians(PROJECTOR_DEPTH_CAMERA.getYRot() + 180)));
|
||||
|
||||
final Matrix3f viewRotationMatrix = viewModelStack.last().normal().copy();
|
||||
if (viewRotationMatrix.invert()) {
|
||||
RenderSystem.setInverseViewRotationMatrix(viewRotationMatrix);
|
||||
}
|
||||
final Matrix3f viewRotationMatrix = new Matrix3f(viewModelStack.last().normal());
|
||||
RenderSystem.setInverseViewRotationMatrix(viewRotationMatrix.invert());
|
||||
}
|
||||
|
||||
private static void storeProjectorMatrix(final int projectorIndex, final Vec3 projectorPos, final Vec3 mainCameraPosition, final PoseStack viewModelStack) {
|
||||
// Save model-view-projection matrix for mapping in compositing shader. We use the position relative to the
|
||||
// main camera here, so that the main camera can sit at the origin. This avoids loss of precision.
|
||||
PROJECTOR_CAMERA_MATRICES[projectorIndex].load(DEPTH_CAMERA_PROJECTION_MATRIX);
|
||||
PROJECTOR_CAMERA_MATRICES[projectorIndex] = new Matrix4f(DEPTH_CAMERA_PROJECTION_MATRIX);
|
||||
viewModelStack.pushPose();
|
||||
viewModelStack.translate(
|
||||
mainCameraPosition.x() - projectorPos.x(),
|
||||
mainCameraPosition.y() - projectorPos.y(),
|
||||
mainCameraPosition.z() - projectorPos.z()
|
||||
);
|
||||
PROJECTOR_CAMERA_MATRICES[projectorIndex].multiply(viewModelStack.last().pose());
|
||||
PROJECTOR_CAMERA_MATRICES[projectorIndex].mul(viewModelStack.last().pose());
|
||||
viewModelStack.popPose();
|
||||
}
|
||||
|
||||
@@ -409,12 +409,12 @@ public final class ProjectorDepthRenderer {
|
||||
}
|
||||
|
||||
private static void prepareOrthographicRendering(final Minecraft minecraft) {
|
||||
final Matrix4f screenProjectionMatrix = Matrix4f.orthographic(
|
||||
final Matrix4f screenProjectionMatrix = new Matrix4f().orthoSymmetric(
|
||||
minecraft.getWindow().getWidth(),
|
||||
-minecraft.getWindow().getHeight(),
|
||||
1000, 3000
|
||||
);
|
||||
RenderSystem.setProjectionMatrix(screenProjectionMatrix);
|
||||
RenderSystem.setProjectionMatrix(screenProjectionMatrix, null);
|
||||
|
||||
final PoseStack modelViewStack = RenderSystem.getModelViewStack();
|
||||
modelViewStack.setIdentity();
|
||||
@@ -423,8 +423,8 @@ public final class ProjectorDepthRenderer {
|
||||
}
|
||||
|
||||
private static Matrix4f constructInverseMainCameraMatrix(final Matrix4f modelViewMatrix, final Matrix4f projectionMatrix) {
|
||||
final Matrix4f inverseModelViewMatrix = projectionMatrix.copy();
|
||||
inverseModelViewMatrix.multiply(modelViewMatrix);
|
||||
final Matrix4f inverseModelViewMatrix = new Matrix4f(projectionMatrix);
|
||||
inverseModelViewMatrix.mul(modelViewMatrix);
|
||||
inverseModelViewMatrix.invert();
|
||||
return inverseModelViewMatrix;
|
||||
}
|
||||
@@ -444,12 +444,12 @@ public final class ProjectorDepthRenderer {
|
||||
private static Matrix4f getFrustumMatrix(final float near, final float far, final float dist,
|
||||
final float left, final float right,
|
||||
final float top, final float bottom) {
|
||||
return new Matrix4f(new float[]{
|
||||
return new Matrix4f(
|
||||
2 * dist / (right - left), 0, (right + left) / (right - left), 0,
|
||||
0, 2 * dist / (top - bottom), (top + bottom) / (top - bottom), 0,
|
||||
0, 0, -(far + near) / (far - near), -(2 * far * near) / (far - near),
|
||||
0, 0, -1, 0,
|
||||
});
|
||||
0, 0, -1, 0
|
||||
);
|
||||
}
|
||||
|
||||
private static DynamicTexture getColorBuffer(final ProjectorBlockEntity projector) {
|
||||
@@ -559,14 +559,14 @@ public final class ProjectorDepthRenderer {
|
||||
instance = new ProjectorCameraEntity(level, BlockPos.ZERO, rotationY);
|
||||
}
|
||||
|
||||
instance.level = level;
|
||||
instance.setLevel(level);
|
||||
instance.moveTo(pos.x(), pos.y(), pos.z(), rotationY, 0);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
private ProjectorCameraEntity(final Level level, final BlockPos blockPos, final float rotationY) {
|
||||
super(level, blockPos, rotationY, FakePlayerUtils.getFakePlayerProfile(), null);
|
||||
super(level, blockPos, rotationY, FakePlayerUtils.getFakePlayerProfile());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,7 +4,7 @@ package li.cil.oc2.client.renderer.blockentity;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import org.joml.Matrix4f;
|
||||
import li.cil.oc2.api.API;
|
||||
import li.cil.oc2.client.renderer.ModRenderType;
|
||||
import li.cil.oc2.common.blockentity.ChargerBlockEntity;
|
||||
|
||||
@@ -7,10 +7,10 @@ import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.RemovalNotification;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Quaternion;
|
||||
import com.mojang.math.Vector3f;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Quaternionf;
|
||||
import li.cil.oc2.api.API;
|
||||
import li.cil.oc2.client.renderer.ModRenderType;
|
||||
import li.cil.oc2.common.block.ComputerBlock;
|
||||
@@ -82,7 +82,7 @@ public final class ComputerRenderer implements BlockEntityRenderer<ComputerBlock
|
||||
stack.pushPose();
|
||||
|
||||
// Align with front face of block.
|
||||
final Quaternion rotation = new Quaternion(Vector3f.YN, blockFacing.toYRot() + 180, true);
|
||||
final Quaternionf rotation = new Quaternionf().rotateY((float) Math.toRadians(blockFacing.toYRot() + 180));
|
||||
stack.translate(0.5f, 0, 0.5f);
|
||||
stack.mulPose(rotation);
|
||||
stack.translate(-0.5f, 0, -0.5f);
|
||||
@@ -206,16 +206,28 @@ public final class ComputerRenderer implements BlockEntityRenderer<ComputerBlock
|
||||
final List<FormattedText> wrappedText = fontRenderer.getSplitter().splitLines(text, maxWidth, Style.EMPTY);
|
||||
if (wrappedText.size() == 1) {
|
||||
final int textWidth = fontRenderer.width(text);
|
||||
fontRenderer.draw(stack, text, (maxWidth - textWidth) * 0.5f, 0, 0xEE3322);
|
||||
draw(fontRenderer, stack, text, (maxWidth - textWidth) * 0.5f, 0, 0xEE3322);
|
||||
} else {
|
||||
for (int i = 0; i < wrappedText.size(); i++) {
|
||||
fontRenderer.draw(stack, wrappedText.get(i).getString(), 0, i * fontRenderer.lineHeight, 0xEE3322);
|
||||
draw(fontRenderer, stack, wrappedText.get(i).getString(), 0, i * fontRenderer.lineHeight, 0xEE3322);
|
||||
}
|
||||
}
|
||||
|
||||
stack.popPose();
|
||||
}
|
||||
|
||||
private void draw(Font font, PoseStack stack, Component text, float x, float y, int color) {
|
||||
var batch = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
|
||||
font.drawInBatch(text, x, y, color, false, stack.last().pose(), batch, Font.DisplayMode.NORMAL, 0, 15728880);
|
||||
batch.endBatch();
|
||||
}
|
||||
|
||||
private void draw(Font font, PoseStack stack, String text, float x, float y, int color) {
|
||||
var batch = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
|
||||
font.drawInBatch(text, x, y, color, false, stack.last().pose(), batch, Font.DisplayMode.NORMAL, 0, 15728880, false);
|
||||
batch.endBatch();
|
||||
}
|
||||
|
||||
private void renderStatus(final Matrix4f matrix, final MultiBufferSource bufferSource) {
|
||||
renderStatus(matrix, bufferSource, 0);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
package li.cil.oc2.client.renderer.blockentity;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import li.cil.oc2.common.block.DiskDriveBlock;
|
||||
import li.cil.oc2.common.blockentity.DiskDriveBlockEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -38,13 +40,13 @@ public final class DiskDriveRenderer implements BlockEntityRenderer<DiskDriveBlo
|
||||
stack.pushPose();
|
||||
|
||||
stack.translate(0.5f, 0.5f, 0.5f);
|
||||
stack.mulPose(Vector3f.YN.rotationDegrees(blockFacing.toYRot()));
|
||||
stack.mulPose(new Quaternionf().rotateY((float) Math.toRadians(blockFacing.toYRot())));
|
||||
stack.translate(0.0f, 0.0f, 0.5f);
|
||||
stack.mulPose(Vector3f.XN.rotationDegrees(90));
|
||||
stack.mulPose(new Quaternionf().rotateX((float) Math.toRadians(90)));
|
||||
stack.translate(0.0f, 0.2375f, 2.5f / 16f);
|
||||
stack.scale(0.55f, 0.55f, 0.55f);
|
||||
|
||||
itemRenderer.renderStatic(floppy, ItemTransforms.TransformType.FIXED, neighborLight, overlay, stack, bufferSource, (int) diskDrive.getBlockPos().asLong());
|
||||
itemRenderer.renderStatic(floppy, ItemDisplayContext.FIXED, neighborLight, overlay, stack, bufferSource, null, (int) diskDrive.getBlockPos().asLong());
|
||||
|
||||
stack.popPose();
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ package li.cil.oc2.client.renderer.blockentity;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Quaternion;
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.mojang.math.Vector4f;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector4f;
|
||||
import li.cil.oc2.api.API;
|
||||
import li.cil.oc2.client.renderer.ModRenderType;
|
||||
import li.cil.oc2.client.renderer.ProjectorDepthRenderer;
|
||||
@@ -81,17 +81,17 @@ public final class ProjectorRenderer implements BlockEntityRenderer<ProjectorBlo
|
||||
final Matrix4f matrix = stack.last().pose();
|
||||
|
||||
final Vector4f lookDirection = new Vector4f(0, 0, -1, 0);
|
||||
lookDirection.transform(matrix);
|
||||
lookDirection.mul(matrix);
|
||||
|
||||
final Vector4f relativePosition = new Vector4f(0, 0, 1, 1);
|
||||
relativePosition.transform(matrix);
|
||||
relativePosition.mul(matrix);
|
||||
|
||||
return relativePosition.dot(lookDirection) < ProjectorBlockEntity.MAX_RENDER_DISTANCE;
|
||||
}
|
||||
|
||||
private void alignToFrontFace(final ProjectorBlockEntity projector, final PoseStack stack) {
|
||||
final Direction blockFacing = projector.getBlockState().getValue(ProjectorBlock.FACING);
|
||||
final Quaternion rotation = new Quaternion(Vector3f.YN, blockFacing.toYRot(), true);
|
||||
final Quaternionf rotation = new Quaternionf().rotateAxis((float)Math.toRadians(blockFacing.toYRot()), new Vector3f(0, -1, 0));
|
||||
stack.translate(0.5f, 0, 0.5f);
|
||||
stack.mulPose(rotation);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@ package li.cil.oc2.client.renderer.entity;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Vector3f;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import li.cil.oc2.client.renderer.entity.model.RobotModel;
|
||||
import li.cil.oc2.common.entity.Robot;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
@@ -34,7 +35,7 @@ public final class RobotRenderer extends EntityRenderer<Robot> {
|
||||
@Override
|
||||
public void render(final Robot entity, final float entityYaw, final float partialTicks, final PoseStack stack, final MultiBufferSource bufferSource, final int packedLight) {
|
||||
final Robot.AnimationState state = entity.getAnimationState();
|
||||
state.update(partialTicks, entity.level.random);
|
||||
state.update(partialTicks, entity.level().random);
|
||||
|
||||
stack.pushPose();
|
||||
// NB: we don't entityYaw given to use because that uses a plain lerp which can lead to ugly
|
||||
@@ -43,7 +44,10 @@ public final class RobotRenderer extends EntityRenderer<Robot> {
|
||||
// alternatively prevent this wrapping or patch the prev value instead.
|
||||
final float partialRotation = Mth.degreesDifferenceAbs(entity.yRotO, entity.getYRot()) * partialTicks;
|
||||
final float rotation = Mth.approachDegrees(entity.yRotO, entity.getYRot(), partialRotation);
|
||||
stack.mulPose(Vector3f.YN.rotationDegrees(rotation));
|
||||
|
||||
var axis = new Vector3f(0, -1, 0);
|
||||
var rotationQuaternion = new Quaternionf().rotationAxis((float)Math.toRadians(rotation), axis.x, axis.y, axis.z);
|
||||
stack.mulPose(rotationQuaternion);
|
||||
|
||||
model.setupAnim(entity, 0, 0, 0, 0, 0);
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public final class RobotWithoutLevelRenderer extends BlockEntityWithoutLevelRenderer {
|
||||
@@ -26,7 +27,7 @@ public final class RobotWithoutLevelRenderer extends BlockEntityWithoutLevelRend
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void renderByItem(final ItemStack itemStack, final ItemTransforms.TransformType transformType, final PoseStack poseStack, final MultiBufferSource bufferSource, final int combinedLight, final int combinedOverlay) {
|
||||
public void renderByItem(final ItemStack itemStack, final ItemDisplayContext transformType, final PoseStack poseStack, final MultiBufferSource bufferSource, final int combinedLight, final int combinedOverlay) {
|
||||
poseStack.pushPose();
|
||||
|
||||
poseStack.translate(0.5, 0, 0.5);
|
||||
|
||||
@@ -15,6 +15,7 @@ import li.cil.oc2.common.bus.device.data.FirmwareRegistry;
|
||||
import li.cil.oc2.common.bus.device.provider.ProviderRegistry;
|
||||
import li.cil.oc2.common.container.Containers;
|
||||
import li.cil.oc2.common.entity.Entities;
|
||||
import li.cil.oc2.common.item.ItemGroup;
|
||||
import li.cil.oc2.common.item.Items;
|
||||
import li.cil.oc2.common.item.crafting.RecipeSerializers;
|
||||
import li.cil.oc2.common.serialization.ceres.Serializers;
|
||||
@@ -65,5 +66,7 @@ public final class Main {
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> Manuals::initialize);
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(ClientSetup.class));
|
||||
|
||||
ItemGroup.TAB_REGISTER.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public final class Blocks {
|
||||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, API.MOD_ID);
|
||||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, API.MOD_ID);
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -35,8 +35,9 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.LootParams;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
@@ -123,7 +124,8 @@ public final class BusCableBlock extends BaseEntityBlock {
|
||||
|
||||
public BusCableBlock() {
|
||||
super(Properties
|
||||
.of(Material.METAL)
|
||||
.of()
|
||||
.mapColor(MapColor.METAL)
|
||||
.sound(SoundType.METAL)
|
||||
.strength(1.5f, 6.0f));
|
||||
|
||||
@@ -267,7 +269,7 @@ public final class BusCableBlock extends BaseEntityBlock {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public List<ItemStack> getDrops(final BlockState state, final LootContext.Builder builder) {
|
||||
public List<ItemStack> getDrops(final BlockState state, final LootParams.Builder builder) {
|
||||
final List<ItemStack> drops = new ArrayList<>(super.getDrops(state, builder));
|
||||
|
||||
if (state.getValue(HAS_FACADE)) {
|
||||
|
||||
@@ -14,14 +14,15 @@ import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class ChargerBlock extends HalfTransparentBlock implements EntityBlock {
|
||||
public ChargerBlock() {
|
||||
super(Properties
|
||||
.of(Material.METAL)
|
||||
.of()
|
||||
.mapColor(MapColor.METAL)
|
||||
.sound(SoundType.METAL)
|
||||
.strength(1.5f, 6.0f));
|
||||
registerDefaultState(getStateDefinition().any().setValue(HorizontalDirectionalBlock.FACING, Direction.NORTH));
|
||||
|
||||
@@ -39,7 +39,7 @@ import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
@@ -74,7 +74,8 @@ public final class ComputerBlock extends HorizontalDirectionalBlock implements E
|
||||
|
||||
public ComputerBlock() {
|
||||
super(Properties
|
||||
.of(Material.METAL)
|
||||
.of()
|
||||
.mapColor(MapColor.METAL)
|
||||
.sound(SoundType.METAL)
|
||||
.strength(1.5f, 6.0f));
|
||||
registerDefaultState(getStateDefinition().any().setValue(FACING, Direction.NORTH));
|
||||
@@ -82,12 +83,6 @@ public final class ComputerBlock extends HorizontalDirectionalBlock implements E
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void fillItemCategory(final CreativeModeTab group, final NonNullList<ItemStack> items) {
|
||||
items.add(getComputerWithFlash());
|
||||
items.add(getPreconfiguredComputer());
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void appendHoverText(final ItemStack stack, @Nullable final BlockGetter level, final List<Component> tooltip, final TooltipFlag advanced) {
|
||||
@@ -123,11 +118,6 @@ public final class ComputerBlock extends HorizontalDirectionalBlock implements E
|
||||
return getSignal(state, level, pos, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCheckWeakPower(final BlockState state, final LevelReader level, final BlockPos pos, final Direction side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void neighborChanged(final BlockState state, final Level level, final BlockPos pos, final Block changedBlock, final BlockPos changedBlockPos, final boolean isMoving) {
|
||||
|
||||
@@ -13,14 +13,15 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class CreativeEnergyBlock extends Block implements EntityBlock {
|
||||
public CreativeEnergyBlock() {
|
||||
super(Properties
|
||||
.of(Material.METAL)
|
||||
.of()
|
||||
.mapColor(MapColor.METAL)
|
||||
.sound(SoundType.METAL)
|
||||
.strength(-1, 3600000)
|
||||
.noLootTable());
|
||||
|
||||
@@ -19,7 +19,7 @@ import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -27,7 +27,8 @@ import javax.annotation.Nullable;
|
||||
public final class DiskDriveBlock extends HorizontalDirectionalBlock implements EntityBlock {
|
||||
public DiskDriveBlock() {
|
||||
super(Properties
|
||||
.of(Material.METAL)
|
||||
.of()
|
||||
.mapColor(MapColor.METAL)
|
||||
.sound(SoundType.METAL)
|
||||
.strength(1.5f, 6.0f));
|
||||
registerDefaultState(getStateDefinition().any().setValue(FACING, Direction.NORTH));
|
||||
|
||||
@@ -20,7 +20,7 @@ import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -28,7 +28,8 @@ import javax.annotation.Nullable;
|
||||
public final class FlashMemoryFlasherBlock extends HorizontalDirectionalBlock implements EntityBlock {
|
||||
public FlashMemoryFlasherBlock() {
|
||||
super(Properties
|
||||
.of(Material.METAL)
|
||||
.of()
|
||||
.mapColor(MapColor.METAL)
|
||||
.sound(SoundType.METAL)
|
||||
.strength(1.5f, 6.0f));
|
||||
registerDefaultState(getStateDefinition().any().setValue(FACING, Direction.NORTH));
|
||||
|
||||
@@ -22,7 +22,7 @@ import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
@@ -42,7 +42,7 @@ public final class KeyboardBlock extends HorizontalDirectionalBlock implements E
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
public KeyboardBlock() {
|
||||
super(Properties.of(Material.METAL).sound(SoundType.METAL).strength(1.5f, 6.0f));
|
||||
super(Properties.of().mapColor(MapColor.METAL).sound(SoundType.METAL).strength(1.5f, 6.0f));
|
||||
registerDefaultState(getStateDefinition().any().setValue(FACING, Direction.NORTH));
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.AttachFace;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
@@ -38,7 +38,8 @@ public final class NetworkConnectorBlock extends FaceAttachedHorizontalDirection
|
||||
|
||||
public NetworkConnectorBlock() {
|
||||
super(Properties
|
||||
.of(Material.METAL)
|
||||
.of()
|
||||
.mapColor(MapColor.METAL)
|
||||
.sound(SoundType.METAL)
|
||||
.strength(1.5f, 6.0f));
|
||||
registerDefaultState(getStateDefinition().any()
|
||||
|
||||
@@ -15,14 +15,15 @@ import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class NetworkHubBlock extends HorizontalDirectionalBlock implements EntityBlock {
|
||||
public NetworkHubBlock() {
|
||||
super(Properties
|
||||
.of(Material.METAL)
|
||||
.of()
|
||||
.mapColor(MapColor.METAL)
|
||||
.sound(SoundType.METAL)
|
||||
.strength(1.5f, 6.0f));
|
||||
registerDefaultState(getStateDefinition().any().setValue(FACING, Direction.NORTH));
|
||||
|
||||
@@ -13,14 +13,15 @@ import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class NetworkSwitchBlock extends HorizontalDirectionalBlock implements EntityBlock {
|
||||
public NetworkSwitchBlock() {
|
||||
super(Properties
|
||||
.of(Material.METAL)
|
||||
.of()
|
||||
.mapColor(MapColor.METAL)
|
||||
.sound(SoundType.METAL)
|
||||
.strength(1.5f, 6.0f));
|
||||
registerDefaultState(getStateDefinition().any().setValue(FACING, Direction.NORTH));
|
||||
|
||||
@@ -22,7 +22,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
@@ -45,7 +45,8 @@ public final class PciCardCageBlock extends HorizontalDirectionalBlock implement
|
||||
|
||||
public PciCardCageBlock() {
|
||||
super(Properties
|
||||
.of(Material.METAL)
|
||||
.of()
|
||||
.mapColor(MapColor.METAL)
|
||||
.sound(SoundType.METAL)
|
||||
.lightLevel(state -> state.getValue(LIT) ? 8 : 0)
|
||||
.strength(1.5f, 6.0f));
|
||||
|
||||
@@ -22,7 +22,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
@@ -45,7 +45,8 @@ public final class ProjectorBlock extends HorizontalDirectionalBlock implements
|
||||
|
||||
public ProjectorBlock() {
|
||||
super(Properties
|
||||
.of(Material.METAL)
|
||||
.of()
|
||||
.mapColor(MapColor.METAL)
|
||||
.sound(SoundType.METAL)
|
||||
.lightLevel(state -> state.getValue(LIT) ? 8 : 0)
|
||||
.strength(1.5f, 6.0f));
|
||||
|
||||
@@ -16,14 +16,15 @@ import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class RedstoneInterfaceBlock extends HorizontalDirectionalBlock implements EntityBlock {
|
||||
public RedstoneInterfaceBlock() {
|
||||
super(Properties
|
||||
.of(Material.METAL)
|
||||
.of()
|
||||
.mapColor(MapColor.METAL)
|
||||
.sound(SoundType.METAL)
|
||||
.strength(1.5f, 6.0f));
|
||||
registerDefaultState(getStateDefinition().any().setValue(FACING, Direction.NORTH));
|
||||
@@ -55,11 +56,6 @@ public final class RedstoneInterfaceBlock extends HorizontalDirectionalBlock imp
|
||||
return super.getSignal(state, level, pos, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCheckWeakPower(final BlockState state, final LevelReader level, final BlockPos pos, final Direction side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public int getDirectSignal(final BlockState state, final BlockGetter level, final BlockPos pos, final Direction side) {
|
||||
|
||||
@@ -16,14 +16,15 @@ import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class VxlanBlock extends HorizontalDirectionalBlock implements EntityBlock {
|
||||
public VxlanBlock() {
|
||||
super(Properties
|
||||
.of(Material.METAL)
|
||||
.of()
|
||||
.mapColor(MapColor.METAL)
|
||||
.sound(SoundType.METAL)
|
||||
.strength(1.5f, 6.0f));
|
||||
registerDefaultState(getStateDefinition().any().setValue(FACING, Direction.NORTH));
|
||||
|
||||
@@ -130,7 +130,7 @@ public final class BusCableBlockEntity extends ModBlockEntity {
|
||||
stack = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (ItemStack.isSame(stack, facade)) {
|
||||
if (ItemStack.isSameItem(stack, facade)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ public final class BusCableBlockEntity extends ModBlockEntity {
|
||||
|
||||
public void handleNeighborChanged(final BlockPos pos) {
|
||||
final BlockPos toPos = pos.subtract(getBlockPos());
|
||||
final Direction side = Direction.fromNormal(toPos.getX(), toPos.getY(), toPos.getZ());
|
||||
final Direction side = Direction.fromDelta(toPos.getX(), toPos.getY(), toPos.getZ());
|
||||
if (side != null) {
|
||||
busElement.updateDevicesForNeighbor(side);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import li.cil.oc2.common.util.ThrottledSoundEmitter;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -85,7 +86,7 @@ public final class DiskDriveBlockEntity extends ModBlockEntity implements DiskDr
|
||||
ItemStackUtils.spawnAsEntity(level, getBlockPos().relative(facing), stack, facing).ifPresent(entity -> {
|
||||
if (player != null) {
|
||||
entity.setNoPickUpDelay();
|
||||
entity.setOwner(player.getUUID());
|
||||
entity.setThrower(player.getUUID());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public final class FlashMemoryFlasherBlockEntity extends ModBlockEntity implemen
|
||||
ItemStackUtils.spawnAsEntity(level, getBlockPos().relative(facing), stack, facing).ifPresent(entity -> {
|
||||
if (player != null) {
|
||||
entity.setNoPickUpDelay();
|
||||
entity.setOwner(player.getUUID());
|
||||
entity.setThrower(player.getUUID());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public final class BlockOperationsModuleDevice extends AbstractItemRPCDevice {
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(final CompoundTag tag) {
|
||||
lastOperation = Mth.clamp(tag.getLong(LAST_OPERATION_TAG_NAME), 0, entity.level.getGameTime());
|
||||
lastOperation = (long) Mth.clamp(tag.getLong(LAST_OPERATION_TAG_NAME), 0, entity.level().getGameTime());
|
||||
}
|
||||
|
||||
@Callback
|
||||
@@ -89,7 +89,7 @@ public final class BlockOperationsModuleDevice extends AbstractItemRPCDevice {
|
||||
|
||||
beginCooldown();
|
||||
|
||||
final Level level = entity.level;
|
||||
final Level level = entity.level();
|
||||
if (!(level instanceof final ServerLevel serverLevel)) {
|
||||
return false;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ public final class BlockOperationsModuleDevice extends AbstractItemRPCDevice {
|
||||
|
||||
beginCooldown();
|
||||
|
||||
final Level level = entity.level;
|
||||
final Level level = entity.level();
|
||||
if (!(level instanceof final ServerLevel serverLevel)) {
|
||||
return false;
|
||||
}
|
||||
@@ -212,15 +212,15 @@ public final class BlockOperationsModuleDevice extends AbstractItemRPCDevice {
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
private void beginCooldown() {
|
||||
lastOperation = entity.level.getGameTime();
|
||||
lastOperation = entity.level().getGameTime();
|
||||
}
|
||||
|
||||
private boolean isOnCooldown() {
|
||||
return entity.level.getGameTime() - lastOperation < COOLDOWN;
|
||||
return entity.level().getGameTime() - lastOperation < COOLDOWN;
|
||||
}
|
||||
|
||||
private List<ItemEntity> getItemsInRange() {
|
||||
return entity.level.getEntitiesOfClass(ItemEntity.class, entity.getBoundingBox().inflate(2));
|
||||
return entity.level().getEntitiesOfClass(ItemEntity.class, entity.getBoundingBox().inflate(2));
|
||||
}
|
||||
|
||||
private boolean tryHarvestBlock(final ServerLevel level, final BlockPos blockPos) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import li.cil.oc2.api.util.RobotOperationSide;
|
||||
import li.cil.oc2.common.capabilities.Capabilities;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -220,15 +221,16 @@ public final class InventoryOperationsModuleDevice extends AbstractItemRPCDevice
|
||||
|
||||
private Stream<IItemHandler> getEntityItemHandlersAt(final Vec3 position, final Direction side) {
|
||||
final AABB bounds = AABB.unitCubeFromLowerCorner(position.subtract(0.5, 0.5, 0.5));
|
||||
return entity.level.getEntities(entity, bounds).stream()
|
||||
return entity.level().getEntities(entity, bounds).stream()
|
||||
.map(e -> e.getCapability(Capabilities.itemHandler(), side))
|
||||
.filter(LazyOptional::isPresent)
|
||||
.map(c -> c.orElseThrow(AssertionError::new));
|
||||
}
|
||||
|
||||
private Stream<IItemHandler> getBlockItemHandlersAt(final Vec3 position, final Direction side) {
|
||||
final BlockPos pos = new BlockPos(position);
|
||||
final BlockEntity blockEntity = entity.level.getBlockEntity(pos);
|
||||
Vec3i posi = new Vec3i((int) position.x, (int) position.y, (int) position.z);
|
||||
final BlockPos pos = new BlockPos(posi);
|
||||
final BlockEntity blockEntity = entity.level().getBlockEntity(pos);
|
||||
if (blockEntity == null) {
|
||||
return Stream.empty();
|
||||
}
|
||||
@@ -242,7 +244,7 @@ public final class InventoryOperationsModuleDevice extends AbstractItemRPCDevice
|
||||
}
|
||||
|
||||
private List<ItemEntity> getItemsInRange() {
|
||||
return entity.level.getEntitiesOfClass(ItemEntity.class, entity.getBoundingBox().inflate(1));
|
||||
return entity.level().getEntitiesOfClass(ItemEntity.class, entity.getBoundingBox().inflate(1));
|
||||
}
|
||||
|
||||
private int takeFromWorld(final int count) {
|
||||
|
||||
@@ -58,7 +58,7 @@ public abstract class AbstractContainer extends AbstractContainerMenu {
|
||||
}
|
||||
|
||||
final ItemStack intoStack = into.getItem();
|
||||
final boolean itemsAreEqual = fromStack.sameItem(intoStack) && ItemStack.tagMatches(fromStack, intoStack);
|
||||
final boolean itemsAreEqual = fromStack.equals(intoStack, false);
|
||||
if (!itemsAreEqual) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public final class ComputerInventoryContainer extends AbstractComputerContainer
|
||||
|
||||
public static ComputerInventoryContainer createClient(final int id, final Inventory playerInventory, final FriendlyByteBuf data) {
|
||||
final BlockPos pos = data.readBlockPos();
|
||||
final BlockEntity blockEntity = playerInventory.player.level.getBlockEntity(pos);
|
||||
final BlockEntity blockEntity = playerInventory.player.level().getBlockEntity(pos);
|
||||
if (blockEntity instanceof final ComputerBlockEntity computer) {
|
||||
return new ComputerInventoryContainer(id, computer, playerInventory.player, createClientEnergyInfo());
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public final class ComputerTerminalContainer extends AbstractComputerContainer {
|
||||
|
||||
public static ComputerTerminalContainer createClient(final int id, final Inventory inventory, final FriendlyByteBuf data) {
|
||||
final BlockPos pos = data.readBlockPos();
|
||||
final BlockEntity blockEntity = inventory.player.level.getBlockEntity(pos);
|
||||
final BlockEntity blockEntity = inventory.player.level().getBlockEntity(pos);
|
||||
if (blockEntity instanceof final ComputerBlockEntity computer) {
|
||||
return new ComputerTerminalContainer(id, inventory.player, computer, createClientEnergyInfo());
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public final class NetworkTunnelContainer extends AbstractContainer {
|
||||
public void removed(final Player player) {
|
||||
super.removed(player);
|
||||
|
||||
if (!player.getLevel().isClientSide()) {
|
||||
if (!player.level().isClientSide()) {
|
||||
clearContainer(player, linkSlot);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public final class RobotInventoryContainer extends AbstractRobotContainer {
|
||||
|
||||
public static RobotInventoryContainer createClient(final int id, final Inventory inventory, final FriendlyByteBuf data) {
|
||||
final int entityId = data.readVarInt();
|
||||
final Entity entity = inventory.player.level.getEntity(entityId);
|
||||
final Entity entity = inventory.player.level().getEntity(entityId);
|
||||
if (entity instanceof final Robot robot) {
|
||||
return new RobotInventoryContainer(id, robot, inventory.player, createClientEnergyInfo());
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public final class RobotTerminalContainer extends AbstractRobotContainer {
|
||||
|
||||
public static RobotTerminalContainer createClient(final int id, final Inventory inventory, final FriendlyByteBuf data) {
|
||||
final int entityId = data.readVarInt();
|
||||
final Entity entity = inventory.player.level.getEntity(entityId);
|
||||
final Entity entity = inventory.player.level().getEntity(entityId);
|
||||
if (entity instanceof final Robot robot) {
|
||||
return new RobotTerminalContainer(id, inventory.player, robot, createClientEnergyInfo());
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import li.cil.oc2.common.capabilities.Capabilities;
|
||||
import li.cil.oc2.common.container.FixedSizeItemStackHandler;
|
||||
import li.cil.oc2.common.container.RobotInventoryContainer;
|
||||
import li.cil.oc2.common.container.RobotTerminalContainer;
|
||||
import li.cil.oc2.common.energy.EnergyStorageItemStack;
|
||||
import li.cil.oc2.common.energy.FixedEnergyStorage;
|
||||
import li.cil.oc2.common.entity.robot.*;
|
||||
import li.cil.oc2.common.integration.Wrenches;
|
||||
@@ -38,6 +37,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
@@ -58,7 +58,7 @@ import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.LootParams;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
@@ -205,13 +205,13 @@ public final class Robot extends Entity implements li.cil.oc2.api.capabilities.R
|
||||
}
|
||||
|
||||
public void start() {
|
||||
if (!level.isClientSide()) {
|
||||
if (!level().isClientSide()) {
|
||||
virtualMachine.start();
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (!level.isClientSide()) {
|
||||
if (!level().isClientSide()) {
|
||||
virtualMachine.stop();
|
||||
}
|
||||
}
|
||||
@@ -247,12 +247,12 @@ public final class Robot extends Entity implements li.cil.oc2.api.capabilities.R
|
||||
spawnAtLocation(stack);
|
||||
|
||||
discard();
|
||||
LevelUtils.playSound(level, blockPosition(), SoundType.METAL, SoundType::getBreakSound);
|
||||
LevelUtils.playSound(level(), blockPosition(), SoundType.METAL, SoundType::getBreakSound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
final boolean isClient = level.isClientSide();
|
||||
final boolean isClient = level().isClientSide();
|
||||
|
||||
if (firstTick) {
|
||||
if (isClient) {
|
||||
@@ -278,7 +278,7 @@ public final class Robot extends Entity implements li.cil.oc2.api.capabilities.R
|
||||
|
||||
actionProcessor.tick();
|
||||
|
||||
if (!isClient && level instanceof final ServerLevel serverLevel) {
|
||||
if (!isClient && level() instanceof final ServerLevel serverLevel) {
|
||||
final VoxelShape shape = Shapes.create(getBoundingBox());
|
||||
final Cursor3D iterator = getBlockPosIterator();
|
||||
while (iterator.advance()) {
|
||||
@@ -296,8 +296,7 @@ public final class Robot extends Entity implements li.cil.oc2.api.capabilities.R
|
||||
final VoxelShape blockShape = blockState.getCollisionShape(serverLevel, mutablePosition);
|
||||
if (Shapes.joinIsNotEmpty(shape, blockShape.move(x, y, z), BooleanOp.AND)) {
|
||||
final BlockEntity blockEntity = serverLevel.getBlockEntity(mutablePosition);
|
||||
final LootContext.Builder builder = new LootContext.Builder(serverLevel)
|
||||
.withRandom(serverLevel.random)
|
||||
final LootParams.Builder builder = new LootParams.Builder(serverLevel)
|
||||
.withParameter(LootContextParams.THIS_ENTITY, this)
|
||||
.withParameter(LootContextParams.ORIGIN, position())
|
||||
.withParameter(LootContextParams.TOOL, ItemStack.EMPTY)
|
||||
@@ -324,7 +323,7 @@ public final class Robot extends Entity implements li.cil.oc2.api.capabilities.R
|
||||
@Override
|
||||
public InteractionResult interact(final Player player, final InteractionHand hand) {
|
||||
final ItemStack stack = player.getItemInHand(hand);
|
||||
if (!level.isClientSide()) {
|
||||
if (!level().isClientSide()) {
|
||||
if (Wrenches.isWrench(stack)) {
|
||||
if (player.isShiftKeyDown()) {
|
||||
dropSelf();
|
||||
@@ -340,11 +339,11 @@ public final class Robot extends Entity implements li.cil.oc2.api.capabilities.R
|
||||
}
|
||||
}
|
||||
|
||||
return InteractionResult.sidedSuccess(level.isClientSide());
|
||||
return InteractionResult.sidedSuccess(level().isClientSide());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet<?> getAddEntityPacket() {
|
||||
public Packet<ClientGamePacketListener> getAddEntityPacket() {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
@@ -352,7 +351,7 @@ public final class Robot extends Entity implements li.cil.oc2.api.capabilities.R
|
||||
public void setRemoved(final RemovalReason reason) {
|
||||
super.setRemoved(reason);
|
||||
|
||||
if (!level.isClientSide()) {
|
||||
if (!level().isClientSide()) {
|
||||
// Full unload to release out-of-nbt persisted runtime-only data such as ram.
|
||||
virtualMachine.stop();
|
||||
virtualMachine.dispose();
|
||||
@@ -453,7 +452,7 @@ public final class Robot extends Entity implements li.cil.oc2.api.capabilities.R
|
||||
|
||||
@Override
|
||||
protected Vec3 limitPistonMovement(final Vec3 pos) {
|
||||
lastPistonMovement = level.getGameTime();
|
||||
lastPistonMovement = level().getGameTime();
|
||||
return super.limitPistonMovement(pos);
|
||||
}
|
||||
|
||||
@@ -475,7 +474,7 @@ public final class Robot extends Entity implements li.cil.oc2.api.capabilities.R
|
||||
}
|
||||
|
||||
private void handleChunkUnload(final ChunkEvent.Unload event) {
|
||||
if (event.getLevel() != level) {
|
||||
if (event.getLevel() != level()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -490,7 +489,7 @@ public final class Robot extends Entity implements li.cil.oc2.api.capabilities.R
|
||||
}
|
||||
|
||||
private void handleWorldUnload(final LevelEvent.Unload event) {
|
||||
if (event.getLevel() != level) {
|
||||
if (event.getLevel() != level()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -627,7 +626,7 @@ public final class Robot extends Entity implements li.cil.oc2.api.capabilities.R
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
if (level.isClientSide()) {
|
||||
if (level().isClientSide()) {
|
||||
RobotActions.performClient(Robot.this);
|
||||
} else {
|
||||
if (action != null) {
|
||||
@@ -710,7 +709,7 @@ public final class Robot extends Entity implements li.cil.oc2.api.capabilities.R
|
||||
}
|
||||
|
||||
private boolean addAction(final AbstractRobotAction action) {
|
||||
if (level.isClientSide()) {
|
||||
if (level().isClientSide()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -749,7 +748,7 @@ public final class Robot extends Entity implements li.cil.oc2.api.capabilities.R
|
||||
@Override
|
||||
protected void onChanged() {
|
||||
super.onChanged();
|
||||
if (!level.isClientSide()) {
|
||||
if (!level().isClientSide()) {
|
||||
virtualMachine.busController.scheduleBusScan();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,8 +152,8 @@ public final class RobotMovementAction extends AbstractRobotAction {
|
||||
moveTowards(robot, targetPos);
|
||||
|
||||
final boolean didCollide = robot.horizontalCollision || robot.verticalCollision;
|
||||
final long gameTime = robot.level.getGameTime();
|
||||
if (didCollide && !robot.level.isClientSide()
|
||||
final long gameTime = robot.level().getGameTime();
|
||||
if (didCollide && !robot.level().isClientSide()
|
||||
&& robot.getLastPistonMovement() < gameTime - 1) {
|
||||
final BlockPos newStart = target;
|
||||
target = start;
|
||||
|
||||
@@ -68,13 +68,6 @@ public final class BusInterfaceItem extends ModBlockItem {
|
||||
return getOrCreateDescriptionId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillItemCategory(final CreativeModeTab tab, final NonNullList<ItemStack> items) {
|
||||
if (this.allowedIn(tab)) {
|
||||
items.add(new ItemStack(this));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlocks(final Map<Block, Item> map, final Item item) {
|
||||
}
|
||||
|
||||
@@ -14,11 +14,4 @@ public final class ChargerItem extends ModBlockItem {
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void fillItemCategory(final CreativeModeTab tab, final NonNullList<ItemStack> items) {
|
||||
if (Config.chargerUseEnergy()) {
|
||||
super.fillItemCategory(tab, items);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,20 +29,6 @@ public final class HardDriveWithExternalDataItem extends AbstractBlockDeviceItem
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void fillItemCategory(final CreativeModeTab tab, final NonNullList<ItemStack> items) {
|
||||
super.fillItemCategory(tab, items);
|
||||
|
||||
BlockDeviceDataRegistry.values().forEach(data -> {
|
||||
if (!Objects.equals(BlockDeviceDataRegistry.getKey(data), getDefaultData())) {
|
||||
final ItemStack stack = withData(data);
|
||||
if (!stack.isEmpty()) {
|
||||
items.add(stack);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor(final ItemStack stack) {
|
||||
return hasCustomColor(stack) ? DyeableLeatherItem.super.getColor(stack) : defaultColor;
|
||||
|
||||
@@ -3,13 +3,111 @@
|
||||
package li.cil.oc2.common.item;
|
||||
|
||||
import li.cil.oc2.api.API;
|
||||
import li.cil.oc2.api.bus.device.DeviceTypes;
|
||||
import li.cil.oc2.common.block.Blocks;
|
||||
import li.cil.oc2.common.block.ComputerBlock;
|
||||
import li.cil.oc2.common.util.NBTUtils;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import static li.cil.oc2.common.Constants.BLOCK_ENTITY_TAG_NAME_IN_ITEM;
|
||||
import static li.cil.oc2.common.Constants.ITEMS_TAG_NAME;
|
||||
import static li.cil.oc2.common.util.NBTUtils.makeInventoryTag;
|
||||
import static li.cil.oc2.common.util.RegistryUtils.key;
|
||||
import static li.cil.oc2.common.util.TranslationUtils.text;
|
||||
|
||||
public final class ItemGroup {
|
||||
public static final net.minecraft.world.item.CreativeModeTab COMMON = new net.minecraft.world.item.CreativeModeTab(API.MOD_ID + ".common") {
|
||||
@Override
|
||||
public ItemStack makeIcon() {
|
||||
return new ItemStack(Items.COMPUTER.get());
|
||||
}
|
||||
};
|
||||
public static final DeferredRegister<CreativeModeTab> TAB_REGISTER = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, API.MOD_ID);
|
||||
|
||||
public static final RegistryObject<CreativeModeTab> COMMON_TAB = TAB_REGISTER.register("common", () -> CreativeModeTab.builder()
|
||||
// Set name of tab to display
|
||||
.title(Component.translatable("item_group." + API.MOD_ID + ".common"))
|
||||
// Set icon of creative tab
|
||||
.icon(() -> new ItemStack(Items.COMPUTER.get()))
|
||||
// Add default items to tab
|
||||
.displayItems((params, output) -> {
|
||||
// Items
|
||||
output.accept(Items.BUS_CABLE.get());
|
||||
output.accept(Items.BUS_INTERFACE.get());
|
||||
output.accept(Items.CHARGER.get());
|
||||
// Computer With Flash
|
||||
ItemStack computerWithFlash = new ItemStack(Blocks.COMPUTER.get());
|
||||
|
||||
final CompoundTag itemsTag = NBTUtils.getOrCreateChildTag(computerWithFlash.getOrCreateTag(), BLOCK_ENTITY_TAG_NAME_IN_ITEM, ITEMS_TAG_NAME);
|
||||
itemsTag.put(key(DeviceTypes.FLASH_MEMORY), makeInventoryTag(
|
||||
new ItemStack(Items.FLASH_MEMORY_CUSTOM.get())
|
||||
));
|
||||
|
||||
output.accept(computerWithFlash);
|
||||
|
||||
// Preconfigured Computer
|
||||
ItemStack preconfiguredComputer = new ItemStack(Blocks.COMPUTER.get());
|
||||
|
||||
final CompoundTag preconfiguredItemsTag = NBTUtils.getOrCreateChildTag(preconfiguredComputer.getOrCreateTag(), BLOCK_ENTITY_TAG_NAME_IN_ITEM, ITEMS_TAG_NAME);
|
||||
preconfiguredItemsTag.put(key(DeviceTypes.FLASH_MEMORY), makeInventoryTag(
|
||||
new ItemStack(Items.FLASH_MEMORY_CUSTOM.get())
|
||||
));
|
||||
preconfiguredItemsTag.put(key(DeviceTypes.MEMORY), makeInventoryTag(
|
||||
new ItemStack(Items.MEMORY_LARGE.get()),
|
||||
new ItemStack(Items.MEMORY_LARGE.get()),
|
||||
new ItemStack(Items.MEMORY_LARGE.get()),
|
||||
new ItemStack(Items.MEMORY_LARGE.get())
|
||||
));
|
||||
preconfiguredItemsTag.put(key(DeviceTypes.HARD_DRIVE), makeInventoryTag(
|
||||
new ItemStack(Items.HARD_DRIVE_CUSTOM.get())
|
||||
));
|
||||
preconfiguredItemsTag.put(key(DeviceTypes.CARD), makeInventoryTag(
|
||||
new ItemStack(Items.NETWORK_INTERFACE_CARD.get())
|
||||
));
|
||||
|
||||
preconfiguredComputer.setHoverName(text("block.{mod}.computer.preconfigured"));
|
||||
|
||||
output.accept(preconfiguredComputer);
|
||||
|
||||
// Normal Items Again
|
||||
output.accept(Items.CREATIVE_ENERGY.get());
|
||||
output.accept(Items.DISK_DRIVE.get());
|
||||
output.accept(Items.FLASH_MEMORY_FLASHER.get());
|
||||
output.accept(Items.KEYBOARD.get());
|
||||
output.accept(Items.NETWORK_CONNECTOR.get());
|
||||
output.accept(Items.NETWORK_HUB.get());
|
||||
output.accept(Items.PROJECTOR.get());
|
||||
output.accept(Items.REDSTONE_INTERFACE.get());
|
||||
output.accept(Items.WRENCH.get());
|
||||
output.accept(Items.MANUAL.get());
|
||||
output.accept(Items.ROBOT.get());
|
||||
output.accept(Items.NETWORK_CABLE.get());
|
||||
output.accept(Items.MEMORY_SMALL.get());
|
||||
output.accept(Items.MEMORY_MEDIUM.get());
|
||||
output.accept(Items.MEMORY_LARGE.get());
|
||||
output.accept(Items.HARD_DRIVE_SMALL.get());
|
||||
output.accept(Items.HARD_DRIVE_MEDIUM.get());
|
||||
output.accept(Items.HARD_DRIVE_LARGE.get());
|
||||
output.accept(Items.HARD_DRIVE_CUSTOM.get());
|
||||
output.accept(Items.FLASH_MEMORY.get());
|
||||
output.accept(Items.FLASH_MEMORY_CUSTOM.get());
|
||||
output.accept(Items.FLOPPY.get());
|
||||
output.accept(Items.REDSTONE_INTERFACE_CARD.get());
|
||||
output.accept(Items.NETWORK_INTERFACE_CARD.get());
|
||||
output.accept(Items.NETWORK_TUNNEL_CARD.get());
|
||||
output.accept(Items.FILE_IMPORT_EXPORT_CARD.get());
|
||||
output.accept(Items.SOUND_CARD.get());
|
||||
output.accept(Items.INVENTORY_OPERATIONS_MODULE.get());
|
||||
output.accept(Items.BLOCK_OPERATIONS_MODULE.get());
|
||||
output.accept(Items.NETWORK_TUNNEL_MODULE.get());
|
||||
output.accept(Items.TRANSISTOR.get());
|
||||
output.accept(Items.CIRCUIT_BOARD.get());
|
||||
output.accept(Items.NETWORK_SWITCH.get());
|
||||
output.accept(Items.VXLAN_HUB.get());
|
||||
output.accept(Items.PCI_CARD_CAGE.get());
|
||||
})
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.List;
|
||||
|
||||
public final class ManualItem extends AbstractManualItem {
|
||||
public ManualItem() {
|
||||
super(new Item.Properties().tab(ItemGroup.COMMON));
|
||||
super(new Item.Properties());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.List;
|
||||
|
||||
public class ModBlockItem extends BlockItem {
|
||||
public ModBlockItem(final Block block, final Properties properties) {
|
||||
super(block, properties.tab(ItemGroup.COMMON));
|
||||
super(block, properties);
|
||||
}
|
||||
|
||||
public ModBlockItem(final Block block) {
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.List;
|
||||
|
||||
public class ModItem extends Item {
|
||||
public ModItem(final Properties properties) {
|
||||
super(properties.tab(ItemGroup.COMMON));
|
||||
super(properties);
|
||||
}
|
||||
|
||||
public ModItem() {
|
||||
|
||||
@@ -95,13 +95,13 @@ public final class NetworkInterfaceCardItem extends ModItem {
|
||||
public InteractionResultHolder<ItemStack> use(final Level level, final Player player, final InteractionHand hand) {
|
||||
final ItemStack itemStack = player.getItemInHand(hand);
|
||||
|
||||
if (player.getLevel().isClientSide()) {
|
||||
if (player.level().isClientSide()) {
|
||||
if (itemStack.is(Items.NETWORK_INTERFACE_CARD.get())) {
|
||||
openConfigurationScreen(player, hand);
|
||||
}
|
||||
}
|
||||
|
||||
return InteractionResultHolder.sidedSuccess(itemStack, player.getLevel().isClientSide());
|
||||
return InteractionResultHolder.sidedSuccess(itemStack, player.level().isClientSide());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -18,6 +18,7 @@ import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.stats.Stats;
|
||||
@@ -44,11 +45,6 @@ import static li.cil.oc2.common.util.NBTUtils.makeInventoryTag;
|
||||
import static li.cil.oc2.common.util.RegistryUtils.key;
|
||||
|
||||
public final class RobotItem extends ModItem {
|
||||
@Override
|
||||
public void fillItemCategory(final CreativeModeTab tab, final NonNullList<ItemStack> items) {
|
||||
items.add(getRobotWithFlash());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(final ItemStack stack, @Nullable final Level level, final List<Component> tooltip, final TooltipFlag flag) {
|
||||
super.appendHoverText(stack, level, tooltip, flag);
|
||||
@@ -95,7 +91,8 @@ public final class RobotItem extends ModItem {
|
||||
robot.importFromItemStack(context.getItemInHand());
|
||||
|
||||
level.addFreshEntity(robot);
|
||||
LevelUtils.playSound(level, new BlockPos(position), SoundType.METAL, SoundType::getPlaceSound);
|
||||
Vec3i posi = new Vec3i((int) position.x, (int) position.y, (int) position.z);
|
||||
LevelUtils.playSound(level, new BlockPos(posi), SoundType.METAL, SoundType::getPlaceSound);
|
||||
|
||||
if (context.getPlayer() == null || !context.getPlayer().isCreative()) {
|
||||
context.getItemInHand().shrink(1);
|
||||
|
||||
@@ -5,10 +5,12 @@ package li.cil.oc2.common.item.crafting;
|
||||
import com.google.gson.JsonObject;
|
||||
import li.cil.oc2.common.integration.Wrenches;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.CraftingBookCategory;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.world.item.crafting.ShapelessRecipe;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
@@ -16,7 +18,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public final class WrenchRecipe extends ShapelessRecipe {
|
||||
public WrenchRecipe(final ShapelessRecipe recipe) {
|
||||
super(recipe.getId(), recipe.getGroup(), recipe.getResultItem(), recipe.getIngredients());
|
||||
super(recipe.getId(), recipe.getGroup(), CraftingBookCategory.MISC, recipe.getResultItem(RegistryAccess.EMPTY), recipe.getIngredients());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
27
src/main/java/li/cil/oc2/common/mixin/AtlasAdder.java
Normal file
27
src/main/java/li/cil/oc2/common/mixin/AtlasAdder.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package li.cil.oc2.common.mixin;
|
||||
|
||||
import li.cil.oc2.client.ClientSetup;
|
||||
import net.minecraft.client.renderer.texture.atlas.SpriteResourceLoader;
|
||||
import net.minecraft.client.renderer.texture.atlas.SpriteSource;
|
||||
import net.minecraft.client.renderer.texture.atlas.sources.SingleFile;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Mixin(SpriteResourceLoader.class)
|
||||
public class AtlasAdder {
|
||||
@ModifyVariable(
|
||||
method = "load(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/renderer/texture/atlas/SpriteResourceLoader;",
|
||||
at = @At("STORE"),
|
||||
ordinal = 0
|
||||
)
|
||||
private static List<SpriteSource> appendSprites(List<SpriteSource> sprites, ResourceManager resourceManager, ResourceLocation atlas){
|
||||
ClientSetup.collectSprites(atlas, location -> sprites.add(new SingleFile(location, Optional.empty())));
|
||||
return sprites;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ package li.cil.oc2.common.mixin;
|
||||
import com.mojang.blaze3d.pipeline.RenderTarget;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import org.joml.Matrix4f;
|
||||
import li.cil.oc2.client.renderer.ProjectorDepthRenderer;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
@@ -32,7 +32,7 @@ public final class MessageUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
final ServerLevel level = player.getLevel();
|
||||
final ServerLevel level = player.getServer().getLevel(player.level().dimension());
|
||||
final BlockEntity blockEntity = LevelUtils.getBlockEntityIfChunkExists(level, pos);
|
||||
if (type.isInstance(blockEntity)) {
|
||||
callback.accept(player, (T) blockEntity);
|
||||
@@ -46,7 +46,7 @@ public final class MessageUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
final ServerLevel level = player.getLevel();
|
||||
final ServerLevel level = player.getServer().getLevel(player.level().dimension());
|
||||
final Entity entity = level.getEntity(id);
|
||||
if (type.isInstance(entity)) {
|
||||
callback.accept((T) entity);
|
||||
@@ -60,7 +60,7 @@ public final class MessageUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
final ServerLevel level = player.getLevel();
|
||||
final ServerLevel level = player.getServer().getLevel(player.level().dimension());
|
||||
final Entity entity = level.getEntity(id);
|
||||
if (type.isInstance(entity) && entity.closerThan(player, 8)) {
|
||||
callback.accept((T) entity);
|
||||
|
||||
@@ -4,6 +4,7 @@ package li.cil.oc2.common.tags;
|
||||
|
||||
import li.cil.oc2.api.API;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
@@ -21,6 +22,6 @@ public final class BlockTags {
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
private static TagKey<Block> tag(final String name) {
|
||||
return TagKey.create(Registry.BLOCK_REGISTRY, new ResourceLocation(API.MOD_ID, name));
|
||||
return TagKey.create(Registries.BLOCK, new ResourceLocation(API.MOD_ID, name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ package li.cil.oc2.common.tags;
|
||||
|
||||
import li.cil.oc2.api.API;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
@@ -30,6 +31,6 @@ public final class ItemTags {
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
private static TagKey<Item> tag(final String name) {
|
||||
return TagKey.create(Registry.ITEM_REGISTRY, new ResourceLocation(API.MOD_ID, name));
|
||||
return TagKey.create(Registries.ITEM, new ResourceLocation(API.MOD_ID, name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.Optional;
|
||||
|
||||
public record BlockLocation(WeakReference<LevelAccessor> level, BlockPos blockPos) {
|
||||
public static BlockLocation of(final Entity entity) {
|
||||
return new BlockLocation(new WeakReference<>(entity.level), entity.blockPosition());
|
||||
return new BlockLocation(new WeakReference<>(entity.level()), entity.blockPosition());
|
||||
}
|
||||
|
||||
public static BlockLocation of(final BlockEntity blockEntity) {
|
||||
|
||||
@@ -4,9 +4,9 @@ package li.cil.oc2.common.util;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Matrix3f;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Vector3f;
|
||||
import org.joml.Matrix3f;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3f;
|
||||
import net.minecraft.client.renderer.SpriteCoordinateExpander;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
|
||||
|
||||
@@ -30,6 +30,6 @@ public final class SoundEvents {
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
private static RegistryObject<SoundEvent> register(final String name) {
|
||||
return SOUNDS.register(name, () -> new SoundEvent(new ResourceLocation(API.MOD_ID, name)));
|
||||
return SOUNDS.register(name, () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(API.MOD_ID, name)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,10 @@ import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.StringSplitter;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner;
|
||||
import net.minecraft.locale.Language;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
@@ -26,6 +29,8 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.registries.ForgeRegistry;
|
||||
import net.minecraftforge.registries.RegistryManager;
|
||||
import org.joml.Vector2i;
|
||||
import org.joml.Vector2ic;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
@@ -44,15 +49,15 @@ public final class TooltipUtils {
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
public static void drawTooltip(final PoseStack poseStack, final List<? extends FormattedText> tooltip, final int x, final int y) {
|
||||
drawTooltip(poseStack, tooltip, x, y, 200, ItemStack.EMPTY);
|
||||
public static void drawTooltip(final GuiGraphics graphics, final List<? extends FormattedText> tooltip, final int x, final int y) {
|
||||
drawTooltip(graphics, tooltip, x, y, 200, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
public static void drawTooltip(final PoseStack poseStack, final List<? extends FormattedText> tooltip, final int x, final int y, final int widthHint) {
|
||||
drawTooltip(poseStack, tooltip, x, y, widthHint, ItemStack.EMPTY);
|
||||
public static void drawTooltip(final GuiGraphics graphics, final List<? extends FormattedText> tooltip, final int x, final int y, final int widthHint) {
|
||||
drawTooltip(graphics, tooltip, x, y, widthHint, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
public static void drawTooltip(final PoseStack poseStack, final List<? extends FormattedText> tooltip, final int x, final int y, final int widthHint, final ItemStack itemStack) {
|
||||
public static void drawTooltip(final GuiGraphics graphics, final List<? extends FormattedText> tooltip, final int x, final int y, final int widthHint, final ItemStack itemStack) {
|
||||
final Minecraft minecraft = Minecraft.getInstance();
|
||||
final Screen screen = minecraft.screen;
|
||||
if (screen == null) {
|
||||
@@ -61,16 +66,16 @@ public final class TooltipUtils {
|
||||
|
||||
final int availableWidth = Math.max(x, screen.width - x);
|
||||
final int targetWidth = Math.min(availableWidth, widthHint);
|
||||
final Font font = ForgeHooksClient.getTooltipFont(null, itemStack, minecraft.font);
|
||||
final Font font = ForgeHooksClient.getTooltipFont(itemStack, minecraft.font);
|
||||
|
||||
final boolean needsWrapping = tooltip.stream().anyMatch(line -> font.width(line) > targetWidth);
|
||||
if (!needsWrapping) {
|
||||
screen.renderComponentTooltip(poseStack, tooltip, x, y, font, itemStack);
|
||||
graphics.renderComponentTooltip(font, tooltip, x, y, itemStack);
|
||||
} else {
|
||||
final StringSplitter splitter = font.getSplitter();
|
||||
final List<? extends FormattedText> wrappedTooltip = tooltip.stream().flatMap(line ->
|
||||
splitter.splitLines(line, targetWidth, Style.EMPTY).stream()).toList();
|
||||
screen.renderComponentTooltip(poseStack, wrappedTooltip, x, y, font, itemStack);
|
||||
graphics.renderComponentTooltip(font, wrappedTooltip, x, y, itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
10
src/main/java/li/cil/oc2/common/util/Vec3Utils.java
Normal file
10
src/main/java/li/cil/oc2/common/util/Vec3Utils.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package li.cil.oc2.common.util;
|
||||
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class Vec3Utils {
|
||||
public static Vec3i round(Vec3 vec) {
|
||||
return new Vec3i((int)Math.round(vec.x), (int)Math.round(vec.y), (int)Math.round(vec.z));
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ package li.cil.oc2.common.vm;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.*;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import org.joml.Matrix4f;
|
||||
import it.unimi.dsi.fastutil.bytes.ByteArrayFIFOQueue;
|
||||
import li.cil.ceres.api.Serialized;
|
||||
import li.cil.oc2.api.API;
|
||||
@@ -808,7 +808,7 @@ public final class Terminal {
|
||||
}
|
||||
BufferBuilder builder = Tesselator.getInstance().getBuilder();
|
||||
|
||||
final Matrix4f matrix = Matrix4f.createTranslateMatrix(0, row * CHAR_HEIGHT, 0);
|
||||
final Matrix4f matrix = new Matrix4f().translate(0, row * CHAR_HEIGHT, 0);
|
||||
|
||||
builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR_TEX);
|
||||
|
||||
@@ -818,10 +818,10 @@ public final class Terminal {
|
||||
BufferBuilder.RenderedBuffer rb = builder.end();
|
||||
|
||||
if (lines[row] == null) {
|
||||
lines[row] = new VertexBuffer();
|
||||
lines[row] = new VertexBuffer(VertexBuffer.Usage.STATIC);
|
||||
}else if (lines[row] != null) {
|
||||
lines[row].close();
|
||||
lines[row] = new VertexBuffer();
|
||||
lines[row] = new VertexBuffer(VertexBuffer.Usage.STATIC);
|
||||
}
|
||||
|
||||
if (!lines[row].isInvalid()){
|
||||
|
||||
@@ -2,13 +2,20 @@
|
||||
|
||||
package li.cil.oc2.data;
|
||||
|
||||
import li.cil.oc2.api.API;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.tags.BlockTagsProvider;
|
||||
import net.minecraft.data.DataProvider;
|
||||
import net.minecraft.data.loot.LootTableProvider;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
||||
import net.minecraftforge.common.data.BlockTagsProvider;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.data.event.GatherDataEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public final class DataGenerators {
|
||||
@SubscribeEvent
|
||||
@@ -16,16 +23,23 @@ public final class DataGenerators {
|
||||
final DataGenerator generator = event.getGenerator();
|
||||
final ExistingFileHelper existingFileHelper = event.getExistingFileHelper();
|
||||
|
||||
if (event.includeServer()) {
|
||||
generator.addProvider(true, new ModLootTableProvider(generator));
|
||||
final BlockTagsProvider blockTagProvider = new ModBlockTagsProvider(generator, existingFileHelper);
|
||||
generator.addProvider(true, blockTagProvider);
|
||||
generator.addProvider(true, new ModItemTagsProvider(generator, blockTagProvider, existingFileHelper));
|
||||
generator.addProvider(true, new ModRecipesProvider(generator));
|
||||
}
|
||||
if (event.includeClient()) {
|
||||
generator.addProvider(true, new ModBlockStateProvider(generator, existingFileHelper));
|
||||
generator.addProvider(true, new ModItemModelProvider(generator, existingFileHelper));
|
||||
}
|
||||
generator.addProvider(
|
||||
event.includeServer(),
|
||||
(DataProvider.Factory<LootTableProvider>) output -> new LootTableProvider(
|
||||
output,
|
||||
Set.of(),
|
||||
Collections.singletonList(
|
||||
new LootTableProvider.SubProviderEntry(
|
||||
ModLootTableProvider.ModBlockLootTables::new,
|
||||
LootContextParamSets.BLOCK
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
var blockTagsProvider = generator.addProvider(event.includeServer(), (DataProvider.Factory<ModBlockTagsProvider>) output -> new ModBlockTagsProvider(output, event.getLookupProvider(), existingFileHelper));
|
||||
generator.addProvider(event.includeServer(), (DataProvider.Factory<ModItemTagsProvider>) output -> new ModItemTagsProvider(output, event.getLookupProvider(), blockTagsProvider.contentsGetter(), API.MOD_ID, existingFileHelper));
|
||||
generator.addProvider(event.includeServer(), (DataProvider.Factory<ModRecipesProvider>) ModRecipesProvider::new);
|
||||
generator.addProvider(event.includeClient(), new ModBlockStateProvider(generator.getPackOutput(), existingFileHelper));
|
||||
generator.addProvider(event.includeClient(), new ModItemModelProvider(generator.getPackOutput(), existingFileHelper));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,10 @@ import li.cil.oc2.common.item.Items;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraftforge.client.model.generators.*;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
@@ -32,8 +34,8 @@ public final class ModBlockStateProvider extends BlockStateProvider {
|
||||
private static final ResourceLocation PCI_CARD_CAGE_MODEL = new ResourceLocation(API.MOD_ID, "block/pci_card_cage");
|
||||
|
||||
|
||||
public ModBlockStateProvider(final DataGenerator generator, final ExistingFileHelper existingFileHelper) {
|
||||
super(generator, API.MOD_ID, existingFileHelper);
|
||||
public ModBlockStateProvider(final PackOutput output, final ExistingFileHelper existingFileHelper) {
|
||||
super(output, API.MOD_ID, existingFileHelper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,12 +47,12 @@ public final class ModBlockStateProvider extends BlockStateProvider {
|
||||
horizontalBlock(Blocks.KEYBOARD, Items.KEYBOARD, KEYBOARD_MODEL);
|
||||
horizontalFaceBlock(Blocks.NETWORK_CONNECTOR, Items.NETWORK_CONNECTOR, NETWORK_CONNECTOR_MODEL)
|
||||
.transforms()
|
||||
.transform(ItemTransforms.TransformType.GUI)
|
||||
.transform(ItemDisplayContext.GUI)
|
||||
.rotation(30, 315, 0)
|
||||
.translation(0, 2, 0)
|
||||
.scale(0.75f, 0.75f, 0.75f)
|
||||
.end()
|
||||
.transform(ItemTransforms.TransformType.FIXED)
|
||||
.transform(ItemDisplayContext.FIXED)
|
||||
.rotation(270, 0, 0)
|
||||
.translation(0, 0, -5)
|
||||
.scale(1, 1, 1)
|
||||
@@ -114,28 +116,28 @@ public final class ModBlockStateProvider extends BlockStateProvider {
|
||||
itemModels().getBuilder(Items.BUS_CABLE.getId().getPath())
|
||||
.parent(straightModel)
|
||||
.transforms()
|
||||
.transform(ItemTransforms.TransformType.GUI)
|
||||
.transform(ItemDisplayContext.GUI)
|
||||
.rotation(30, 225, 0)
|
||||
.scale(0.75f)
|
||||
.end()
|
||||
.transform(ItemTransforms.TransformType.GROUND)
|
||||
.transform(ItemDisplayContext.GROUND)
|
||||
.translation(0, 3, 0)
|
||||
.scale(0.75f)
|
||||
.end()
|
||||
.transform(ItemTransforms.TransformType.FIXED)
|
||||
.transform(ItemDisplayContext.FIXED)
|
||||
.rotation(0, 180, 0)
|
||||
.scale(1.0f)
|
||||
.end()
|
||||
.transform(ItemTransforms.TransformType.THIRD_PERSON_RIGHT_HAND)
|
||||
.transform(ItemDisplayContext.THIRD_PERSON_RIGHT_HAND)
|
||||
.rotation(75, 45, 0)
|
||||
.translation(0, 2.5f, 0)
|
||||
.scale(0.75f)
|
||||
.end()
|
||||
.transform(ItemTransforms.TransformType.FIRST_PERSON_RIGHT_HAND)
|
||||
.transform(ItemDisplayContext.FIRST_PERSON_RIGHT_HAND)
|
||||
.rotation(0, 45, 0)
|
||||
.scale(0.75f)
|
||||
.end()
|
||||
.transform(ItemTransforms.TransformType.FIRST_PERSON_LEFT_HAND)
|
||||
.transform(ItemDisplayContext.FIRST_PERSON_LEFT_HAND)
|
||||
.rotation(0, 225, 0)
|
||||
.scale(0.75f)
|
||||
.end();
|
||||
@@ -143,31 +145,31 @@ public final class ModBlockStateProvider extends BlockStateProvider {
|
||||
itemModels().getBuilder(Items.BUS_INTERFACE.getId().getPath())
|
||||
.parent(plugModel)
|
||||
.transforms()
|
||||
.transform(ItemTransforms.TransformType.GUI)
|
||||
.transform(ItemDisplayContext.GUI)
|
||||
.rotation(30, 315, 0)
|
||||
.translation(2, 1, 0)
|
||||
.scale(0.75f)
|
||||
.end()
|
||||
.transform(ItemTransforms.TransformType.GROUND)
|
||||
.transform(ItemDisplayContext.GROUND)
|
||||
.translation(0, 3, -5)
|
||||
.scale(0.75f)
|
||||
.end()
|
||||
.transform(ItemTransforms.TransformType.FIXED)
|
||||
.transform(ItemDisplayContext.FIXED)
|
||||
.rotation(0, 180, 0)
|
||||
.translation(0, 0, 4)
|
||||
.scale(1.0f)
|
||||
.end()
|
||||
.transform(ItemTransforms.TransformType.THIRD_PERSON_RIGHT_HAND)
|
||||
.transform(ItemDisplayContext.THIRD_PERSON_RIGHT_HAND)
|
||||
.rotation(75, 180, 0)
|
||||
.translation(0, -1, 0)
|
||||
.scale(0.75f)
|
||||
.end()
|
||||
.transform(ItemTransforms.TransformType.FIRST_PERSON_RIGHT_HAND)
|
||||
.transform(ItemDisplayContext.FIRST_PERSON_RIGHT_HAND)
|
||||
.rotation(0, 180, 0)
|
||||
.translation(0, 0, 2)
|
||||
.scale(0.75f)
|
||||
.end()
|
||||
.transform(ItemTransforms.TransformType.FIRST_PERSON_LEFT_HAND)
|
||||
.transform(ItemDisplayContext.FIRST_PERSON_LEFT_HAND)
|
||||
.rotation(0, 180, 0)
|
||||
.translation(0, 0, 2)
|
||||
.scale(0.75f)
|
||||
|
||||
@@ -4,21 +4,25 @@ package li.cil.oc2.data;
|
||||
|
||||
import li.cil.oc2.api.API;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.tags.BlockTagsProvider;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraftforge.common.data.BlockTagsProvider;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static li.cil.oc2.common.block.Blocks.*;
|
||||
import static li.cil.oc2.common.tags.BlockTags.*;
|
||||
|
||||
public final class ModBlockTagsProvider extends BlockTagsProvider {
|
||||
public ModBlockTagsProvider(final DataGenerator generatorIn, @Nullable final ExistingFileHelper existingFileHelper) {
|
||||
super(generatorIn, API.MOD_ID, existingFileHelper);
|
||||
public ModBlockTagsProvider(final PackOutput packOutput, CompletableFuture<HolderLookup.Provider> lookupProvider, @Nullable final ExistingFileHelper existingFileHelper) {
|
||||
super(packOutput, lookupProvider, API.MOD_ID, existingFileHelper);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addTags() {
|
||||
protected void addTags(HolderLookup.Provider provider) {
|
||||
tag(DEVICES).add(
|
||||
COMPUTER.get(),
|
||||
REDSTONE_INTERFACE.get(),
|
||||
|
||||
@@ -6,6 +6,7 @@ import li.cil.oc2.api.API;
|
||||
import li.cil.oc2.common.entity.Entities;
|
||||
import li.cil.oc2.common.item.Items;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraftforge.client.model.generators.ItemModelBuilder;
|
||||
@@ -14,8 +15,8 @@ import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public final class ModItemModelProvider extends ItemModelProvider {
|
||||
public ModItemModelProvider(final DataGenerator generator, final ExistingFileHelper existingFileHelper) {
|
||||
super(generator, API.MOD_ID, existingFileHelper);
|
||||
public ModItemModelProvider(final PackOutput output, final ExistingFileHelper existingFileHelper) {
|
||||
super(output, API.MOD_ID, existingFileHelper);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,22 +6,31 @@ import li.cil.oc2.api.API;
|
||||
import li.cil.oc2.common.item.Items;
|
||||
import li.cil.oc2.common.tags.BlockTags;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.tags.BlockTagsProvider;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.data.tags.ItemTagsProvider;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static li.cil.oc2.common.tags.ItemTags.*;
|
||||
|
||||
public final class ModItemTagsProvider extends ItemTagsProvider {
|
||||
public ModItemTagsProvider(final DataGenerator generator, final BlockTagsProvider blockTagProvider, @Nullable final ExistingFileHelper existingFileHelper) {
|
||||
super(generator, blockTagProvider, API.MOD_ID, existingFileHelper);
|
||||
public ModItemTagsProvider(
|
||||
final PackOutput output,
|
||||
final CompletableFuture<HolderLookup.Provider> lookupProvider,
|
||||
final CompletableFuture<TagLookup<Block>> tagLookup,
|
||||
final String modId,
|
||||
@Nullable final ExistingFileHelper existingFileHelper) {
|
||||
super(output, lookupProvider, tagLookup, modId, existingFileHelper);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected void addTags() {
|
||||
protected void addTags(HolderLookup.Provider provider) {
|
||||
copy(BlockTags.CABLES, CABLES);
|
||||
|
||||
copy(BlockTags.DEVICES, DEVICES);
|
||||
|
||||
@@ -5,26 +5,27 @@ package li.cil.oc2.data;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import li.cil.oc2.api.API;
|
||||
import li.cil.oc2.common.block.Blocks;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.loot.BlockLoot;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.data.loot.BlockLootSubProvider;
|
||||
import net.minecraft.world.flag.FeatureFlags;
|
||||
import net.minecraft.data.loot.LootTableProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.storage.loot.LootPool;
|
||||
import net.minecraft.world.level.storage.loot.LootTable;
|
||||
import net.minecraft.world.level.storage.loot.LootTables;
|
||||
import net.minecraft.world.level.storage.loot.ValidationContext;
|
||||
import net.minecraft.world.level.storage.loot.entries.LootItem;
|
||||
import net.minecraft.world.level.storage.loot.functions.CopyNbtFunction;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSet;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
||||
import net.minecraft.world.level.storage.loot.providers.nbt.ContextNbtProvider;
|
||||
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.ForgeRegistry;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
@@ -36,25 +37,29 @@ import static java.util.Objects.requireNonNull;
|
||||
import static li.cil.oc2.common.Constants.*;
|
||||
|
||||
public final class ModLootTableProvider extends LootTableProvider {
|
||||
public ModLootTableProvider(final DataGenerator generator) {
|
||||
super(generator);
|
||||
public ModLootTableProvider(final PackOutput output, final Set<ResourceLocation> additionalTables, final List<SubProviderEntry> subProviders) {
|
||||
super(output, additionalTables, subProviders);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validate(final Map<ResourceLocation, LootTable> map, final ValidationContext context) {
|
||||
map.forEach((location, table) -> LootTables.validate(context, location, table));
|
||||
public List<SubProviderEntry> getTables() {
|
||||
return singletonList(
|
||||
new LootTableProvider.SubProviderEntry(
|
||||
ModBlockLootTables::new,
|
||||
LootContextParamSets.BLOCK
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Pair<Supplier<Consumer<BiConsumer<ResourceLocation, LootTable.Builder>>>, LootContextParamSet>> getTables() {
|
||||
return singletonList(Pair.of(ModBlockLootTables::new, LootContextParamSets.BLOCK));
|
||||
}
|
||||
public static final class ModBlockLootTables extends BlockLootSubProvider {
|
||||
public ModBlockLootTables() {
|
||||
super(Collections.emptySet(), FeatureFlags.REGISTRY.allFlags());
|
||||
}
|
||||
|
||||
public static final class ModBlockLootTables extends BlockLoot {
|
||||
@Override
|
||||
protected void addTables() {
|
||||
protected void generate() {
|
||||
dropSelf(Blocks.CHARGER.get());
|
||||
add(Blocks.COMPUTER.get(), ModBlockLootTables::droppingWithInventory);
|
||||
add(Blocks.COMPUTER.get(), this::droppingWithInventory);
|
||||
dropSelf(Blocks.DISK_DRIVE.get());
|
||||
dropSelf(Blocks.KEYBOARD.get());
|
||||
dropSelf(Blocks.NETWORK_CONNECTOR.get());
|
||||
@@ -65,13 +70,14 @@ public final class ModLootTableProvider extends LootTableProvider {
|
||||
|
||||
@Override
|
||||
protected Iterable<Block> getKnownBlocks() {
|
||||
return StreamSupport.stream(super.getKnownBlocks().spliterator(), false)
|
||||
.filter(block -> requireNonNull(ForgeRegistries.BLOCKS.getKey(block)).getNamespace().equals(API.MOD_ID))
|
||||
.filter(block -> block != Blocks.BUS_CABLE.get()) // All bus drops depend on block state.
|
||||
return Blocks.BLOCKS.getEntries()
|
||||
.stream()
|
||||
.filter(blockRegObj -> blockRegObj.get() != Blocks.BUS_CABLE.get())
|
||||
.map(RegistryObject::get)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static LootTable.Builder droppingWithInventory(final Block block) {
|
||||
private LootTable.Builder droppingWithInventory(final Block block) {
|
||||
return LootTable.lootTable()
|
||||
.withPool(applyExplosionCondition(block, LootPool.lootPool()
|
||||
.setRolls(ConstantValue.exactly(1))
|
||||
|
||||
@@ -5,10 +5,8 @@ package li.cil.oc2.data;
|
||||
import li.cil.oc2.common.item.Items;
|
||||
import net.minecraft.advancements.critereon.InventoryChangeTrigger;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.recipes.FinishedRecipe;
|
||||
import net.minecraft.data.recipes.RecipeProvider;
|
||||
import net.minecraft.data.recipes.ShapedRecipeBuilder;
|
||||
import net.minecraft.data.recipes.ShapelessRecipeBuilder;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.data.recipes.*;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraftforge.common.Tags;
|
||||
@@ -16,14 +14,14 @@ import net.minecraftforge.common.Tags;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public final class ModRecipesProvider extends RecipeProvider {
|
||||
public ModRecipesProvider(final DataGenerator generator) {
|
||||
super(generator);
|
||||
public ModRecipesProvider(final PackOutput output) {
|
||||
super(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildCraftingRecipes(final Consumer<FinishedRecipe> consumer) {
|
||||
protected void buildRecipes(final Consumer<FinishedRecipe> consumer) {
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.COMPUTER.get())
|
||||
.shaped(RecipeCategory.MISC, Items.COMPUTER.get())
|
||||
.pattern("ICI")
|
||||
.pattern("XTX")
|
||||
.pattern("IBI")
|
||||
@@ -37,7 +35,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.BUS_CABLE.get(), 16)
|
||||
.shaped(RecipeCategory.MISC, Items.BUS_CABLE.get(), 16)
|
||||
.pattern("III")
|
||||
.pattern("GTG")
|
||||
.pattern("III")
|
||||
@@ -48,14 +46,14 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapelessRecipeBuilder
|
||||
.shapeless(Items.BUS_INTERFACE.get())
|
||||
.shapeless(RecipeCategory.MISC, Items.BUS_INTERFACE.get())
|
||||
.requires(Items.TRANSISTOR.get())
|
||||
.requires(Items.BUS_CABLE.get())
|
||||
.unlockedBy("has_bus_cable", inventoryChange(Items.BUS_CABLE.get()))
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.NETWORK_CONNECTOR.get(), 4)
|
||||
.shaped(RecipeCategory.MISC, Items.NETWORK_CONNECTOR.get(), 4)
|
||||
.pattern("IGI")
|
||||
.pattern("ITI")
|
||||
.define('I', Tags.Items.INGOTS_IRON)
|
||||
@@ -65,7 +63,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.NETWORK_HUB.get())
|
||||
.shaped(RecipeCategory.MISC, Items.NETWORK_HUB.get())
|
||||
.pattern("ICI")
|
||||
.pattern("XTX")
|
||||
.pattern("IBI")
|
||||
@@ -78,7 +76,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.REDSTONE_INTERFACE.get())
|
||||
.shaped(RecipeCategory.MISC, Items.REDSTONE_INTERFACE.get())
|
||||
.pattern("ICI")
|
||||
.pattern("XTX")
|
||||
.pattern("IBI")
|
||||
@@ -91,7 +89,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.DISK_DRIVE.get())
|
||||
.shaped(RecipeCategory.MISC, Items.DISK_DRIVE.get())
|
||||
.pattern("IUI")
|
||||
.pattern("XTD")
|
||||
.pattern("IBI")
|
||||
@@ -105,7 +103,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.KEYBOARD.get())
|
||||
.shaped(RecipeCategory.MISC, Items.KEYBOARD.get())
|
||||
.pattern("UUU")
|
||||
.pattern("XTU")
|
||||
.pattern("IBI")
|
||||
@@ -118,7 +116,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.CHARGER.get())
|
||||
.shaped(RecipeCategory.MISC, Items.CHARGER.get())
|
||||
.pattern("IPI")
|
||||
.pattern("XTX")
|
||||
.pattern("IRI")
|
||||
@@ -131,7 +129,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.PROJECTOR.get())
|
||||
.shaped(RecipeCategory.MISC, Items.PROJECTOR.get())
|
||||
.pattern("GLG")
|
||||
.pattern("XTD")
|
||||
.pattern("GBG")
|
||||
@@ -146,7 +144,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.WRENCH.get())
|
||||
.shaped(RecipeCategory.MISC, Items.WRENCH.get())
|
||||
.pattern("I I")
|
||||
.pattern(" T ")
|
||||
.pattern(" I ")
|
||||
@@ -164,7 +162,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.NETWORK_CABLE.get(), 8)
|
||||
.shaped(RecipeCategory.MISC, Items.NETWORK_CABLE.get(), 8)
|
||||
.pattern("SSS")
|
||||
.pattern("GTG")
|
||||
.pattern("SSS")
|
||||
@@ -175,7 +173,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.ROBOT.get())
|
||||
.shaped(RecipeCategory.MISC, Items.ROBOT.get())
|
||||
.pattern("ICI")
|
||||
.pattern("PTP")
|
||||
.pattern("IBI")
|
||||
@@ -189,7 +187,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.MEMORY_SMALL.get(), 2)
|
||||
.shaped(RecipeCategory.MISC, Items.MEMORY_SMALL.get(), 2)
|
||||
.pattern("ITI")
|
||||
.pattern(" B ")
|
||||
.define('I', Tags.Items.INGOTS_IRON)
|
||||
@@ -200,7 +198,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.MEMORY_MEDIUM.get(), 2)
|
||||
.shaped(RecipeCategory.MISC, Items.MEMORY_MEDIUM.get(), 2)
|
||||
.pattern("GTG")
|
||||
.pattern(" B ")
|
||||
.define('G', Tags.Items.INGOTS_GOLD)
|
||||
@@ -211,7 +209,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.MEMORY_LARGE.get(), 2)
|
||||
.shaped(RecipeCategory.MISC, Items.MEMORY_LARGE.get(), 2)
|
||||
.pattern("DTD")
|
||||
.pattern(" B ")
|
||||
.define('D', Tags.Items.GEMS_DIAMOND)
|
||||
@@ -222,7 +220,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.HARD_DRIVE_SMALL.get())
|
||||
.shaped(RecipeCategory.MISC, Items.HARD_DRIVE_SMALL.get())
|
||||
.pattern("ITI")
|
||||
.pattern("EBE")
|
||||
.define('I', Tags.Items.INGOTS_IRON)
|
||||
@@ -234,7 +232,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.HARD_DRIVE_MEDIUM.get())
|
||||
.shaped(RecipeCategory.MISC, Items.HARD_DRIVE_MEDIUM.get())
|
||||
.pattern("GTG")
|
||||
.pattern("EBE")
|
||||
.define('G', Tags.Items.INGOTS_GOLD)
|
||||
@@ -246,7 +244,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.HARD_DRIVE_LARGE.get())
|
||||
.shaped(RecipeCategory.MISC, Items.HARD_DRIVE_LARGE.get())
|
||||
.pattern("DTD")
|
||||
.pattern("EBE")
|
||||
.define('D', Tags.Items.GEMS_DIAMOND)
|
||||
@@ -265,7 +263,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.FLASH_MEMORY.get())
|
||||
.shaped(RecipeCategory.MISC, Items.FLASH_MEMORY.get())
|
||||
.pattern("ITI")
|
||||
.pattern("RBR")
|
||||
.define('I', Tags.Items.INGOTS_IRON)
|
||||
@@ -284,7 +282,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.REDSTONE_INTERFACE_CARD.get())
|
||||
.shaped(RecipeCategory.MISC, Items.REDSTONE_INTERFACE_CARD.get())
|
||||
.pattern("IRT")
|
||||
.pattern(" B ")
|
||||
.define('R', net.minecraft.world.item.Items.REDSTONE_TORCH)
|
||||
@@ -295,7 +293,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.NETWORK_INTERFACE_CARD.get())
|
||||
.shaped(RecipeCategory.MISC, Items.NETWORK_INTERFACE_CARD.get())
|
||||
.pattern("IGT")
|
||||
.pattern(" B ")
|
||||
.define('G', Tags.Items.GLASS)
|
||||
@@ -306,7 +304,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.NETWORK_TUNNEL_CARD.get())
|
||||
.shaped(RecipeCategory.MISC, Items.NETWORK_TUNNEL_CARD.get())
|
||||
.pattern("IET")
|
||||
.pattern(" B ")
|
||||
.define('E', Tags.Items.ENDER_PEARLS)
|
||||
@@ -317,7 +315,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.FILE_IMPORT_EXPORT_CARD.get())
|
||||
.shaped(RecipeCategory.MISC, Items.FILE_IMPORT_EXPORT_CARD.get())
|
||||
.pattern("IET")
|
||||
.pattern(" B ")
|
||||
.define('E', net.minecraft.world.item.Items.PAPER)
|
||||
@@ -328,7 +326,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.SOUND_CARD.get())
|
||||
.shaped(RecipeCategory.MISC, Items.SOUND_CARD.get())
|
||||
.pattern("IST")
|
||||
.pattern(" B ")
|
||||
.define('S', net.minecraft.world.item.Items.NOTE_BLOCK)
|
||||
@@ -339,7 +337,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.FLOPPY.get())
|
||||
.shaped(RecipeCategory.MISC, Items.FLOPPY.get())
|
||||
.pattern("ITI")
|
||||
.pattern("QBQ")
|
||||
.define('I', Tags.Items.INGOTS_IRON)
|
||||
@@ -351,7 +349,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.INVENTORY_OPERATIONS_MODULE.get())
|
||||
.shaped(RecipeCategory.MISC, Items.INVENTORY_OPERATIONS_MODULE.get())
|
||||
.pattern("TCG")
|
||||
.pattern(" B ")
|
||||
.define('T', Items.TRANSISTOR.get())
|
||||
@@ -362,7 +360,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.BLOCK_OPERATIONS_MODULE.get())
|
||||
.shaped(RecipeCategory.MISC, Items.BLOCK_OPERATIONS_MODULE.get())
|
||||
.pattern("TPG")
|
||||
.pattern(" B ")
|
||||
.define('T', Items.TRANSISTOR.get())
|
||||
@@ -373,7 +371,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.NETWORK_TUNNEL_MODULE.get())
|
||||
.shaped(RecipeCategory.MISC, Items.NETWORK_TUNNEL_MODULE.get())
|
||||
.pattern("TEG")
|
||||
.pattern(" B ")
|
||||
.define('T', Items.TRANSISTOR.get())
|
||||
@@ -385,7 +383,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
|
||||
|
||||
ShapedRecipeBuilder
|
||||
.shaped(Items.TRANSISTOR.get(), 12)
|
||||
.shaped(RecipeCategory.MISC, Items.TRANSISTOR.get(), 12)
|
||||
.pattern("RCR")
|
||||
.pattern("III")
|
||||
.define('I', Tags.Items.INGOTS_IRON)
|
||||
@@ -395,7 +393,7 @@ public final class ModRecipesProvider extends RecipeProvider {
|
||||
.save(consumer);
|
||||
|
||||
ShapelessRecipeBuilder
|
||||
.shapeless(Items.CIRCUIT_BOARD.get(), 6)
|
||||
.shapeless(RecipeCategory.MISC, Items.CIRCUIT_BOARD.get(), 6)
|
||||
.requires(Tags.Items.INGOTS_GOLD)
|
||||
.requires(net.minecraft.world.item.Items.CLAY_BALL)
|
||||
.requires(Items.TRANSISTOR.get())
|
||||
|
||||
@@ -105,10 +105,10 @@ public final class WrenchRecipeBuilder {
|
||||
public void save(final Consumer<FinishedRecipe> consumerIn, final ResourceLocation id) {
|
||||
this.validate(id);
|
||||
this.advancementBuilder.parent(new ResourceLocation("recipes/root")).addCriterion("has_the_recipe", RecipeUnlockedTrigger.unlocked(id)).rewards(AdvancementRewards.Builder.recipe(id)).requirements(RequirementsStrategy.OR);
|
||||
final CreativeModeTab itemCategory = this.result.getItemCategory();
|
||||
if (itemCategory != null) {
|
||||
consumerIn.accept(new WrenchRecipeBuilder.Result(id, this.result, this.count, this.group == null ? "" : this.group, this.ingredients, this.advancementBuilder, new ResourceLocation(id.getNamespace(), "recipes/" + itemCategory.getRecipeFolderName() + "/" + id.getPath())));
|
||||
}
|
||||
//final CreativeModeTab itemCategory = this.result.; TODO: FIX THIS
|
||||
//if (itemCategory != null) {
|
||||
// consumerIn.accept(new WrenchRecipeBuilder.Result(id, this.result, this.count, this.group == null ? "" : this.group, this.ingredients, this.advancementBuilder, new ResourceLocation(id.getNamespace(), "recipes/" + itemCategory.getRecipeFolderName() + "/" + id.getPath())));
|
||||
//}
|
||||
}
|
||||
|
||||
private void validate(final ResourceLocation id) {
|
||||
|
||||
@@ -2,3 +2,6 @@ public net.minecraft.client.MouseHandler f_91520_ # mouseGrabbed
|
||||
public-f net.minecraft.world.entity.Entity m_142467_(Lnet/minecraft/world/entity/Entity$RemovalReason;)V # setRemoved
|
||||
public-f net.minecraft.client.renderer.GameRenderer f_109054_ # mainCamera
|
||||
public net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket f_179586_ # MAX_PAYLOAD_SIZE
|
||||
public net.minecraft.client.gui.components.AbstractWidget f_93620_ # x
|
||||
public net.minecraft.client.gui.components.AbstractWidget f_93621_ # y
|
||||
public net.minecraft.client.gui.components.Button <init>(IIIILnet/minecraft/network/chat/Component;Lnet/minecraft/client/gui/components/Button$OnPress;Lnet/minecraft/client/gui/components/Button$CreateNarration;)V # Button
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"itemGroup.oc2.common": "OpenComputers II",
|
||||
"item_group.oc2.common": "OpenComputers II",
|
||||
|
||||
"block.oc2.computer": "Computer",
|
||||
"block.oc2.computer.desc": "Runs software from Flash Memory and Hard Disks.",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"itemGroup.oc2.common": "OpenComputers II",
|
||||
"item_group.oc2.common": "OpenComputers II",
|
||||
|
||||
"block.oc2.computer": "Компьютер",
|
||||
"block.oc2.computer.desc": "Выполняет программы из карт памяти и жестких дисков.",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"itemGroup.oc2.common": "开放式电脑 II",
|
||||
"item_group.oc2.common": "开放式电脑 II",
|
||||
|
||||
"block.oc2.computer": "电脑",
|
||||
"block.oc2.computer.desc": "使用螺丝刀扳手或者兼容的扳手来添加或移除组件。",
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
"client": [
|
||||
"FrustumMixin",
|
||||
"LevelRendererMixin",
|
||||
"MinecraftMixin"
|
||||
"MinecraftMixin",
|
||||
"AtlasAdder"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"pack": {
|
||||
"description": "Resources",
|
||||
"pack_format": 5
|
||||
"pack_format": 15
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user