Skip to content

Commit

Permalink
Fix compile errors part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Jab125 committed Aug 12, 2023
1 parent 0ef8d9c commit 8d0052f
Show file tree
Hide file tree
Showing 17 changed files with 115 additions and 114 deletions.
7 changes: 5 additions & 2 deletions common/src/main/java/com/ultreon/devices/DeviceTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import com.ultreon.devices.init.DeviceBlocks;
import com.ultreon.devices.init.DeviceItems;
import dev.architectury.registry.CreativeTabRegistry;
import dev.architectury.registry.registries.DeferredSupplier;
import dev.architectury.registry.registries.RegistrySupplier;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
Expand All @@ -12,9 +15,9 @@

public class DeviceTab {
@SuppressWarnings("UnstableApiUsage")
public static CreativeTabRegistry.TabSupplier create() {
public static DeferredSupplier<CreativeModeTab> create() {
Devices.LOGGER.info("Creating Creative Tab...");
CreativeTabRegistry.TabSupplier devicesTabDevice = CreativeTabRegistry.create(id("devices_tab_device"), () -> new ItemStack(DeviceBlocks.LAPTOPS.of(DyeColor.RED).get()));
DeferredSupplier<CreativeModeTab> devicesTabDevice = CreativeTabRegistry.defer(id("devices_tab_device")); //TODO () -> new ItemStack(DeviceBlocks.LAPTOPS.of(DyeColor.RED).get()
CreativeTabRegistry.modify(devicesTabDevice, (flags, output, canUseGameMasterBlocks) -> {
for (RegistrySupplier<Item> laptop : DeviceItems.LAPTOPS) {
output.accept(laptop.get());
Expand Down
6 changes: 4 additions & 2 deletions common/src/main/java/com/ultreon/devices/Devices.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import dev.architectury.injectables.targets.ArchitecturyTarget;
import dev.architectury.platform.Platform;
import dev.architectury.registry.CreativeTabRegistry;
import dev.architectury.registry.registries.DeferredSupplier;
import dev.architectury.registry.registries.RegistrarManager;
import dev.architectury.utils.Env;
import dev.architectury.utils.EnvExecutor;
Expand All @@ -58,6 +59,7 @@
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.RecipeType;
Expand All @@ -80,7 +82,7 @@ public abstract class Devices {
public static final String MOD_ID = "devices";
public static final Logger LOGGER = LoggerFactory.getLogger("Devices Mod");

public static final CreativeTabRegistry.TabSupplier TAB_DEVICE = DeviceTab.create();
public static final DeferredSupplier<CreativeModeTab> TAB_DEVICE = DeviceTab.create();
public static final Supplier<RegistrarManager> REGISTRIES = Suppliers.memoize(() -> RegistrarManager.get(MOD_ID));
public static final List<SiteRegistration> SITE_REGISTRATIONS = new ProtectedArrayList<>();
private static final Pattern DEV_PREVIEW_PATTERN = Pattern.compile("\\d+\\.\\d+\\.\\d+-dev\\d+");
Expand Down Expand Up @@ -375,7 +377,7 @@ private static void setupEvents() {
LifecycleEvent.SERVER_STARTING.register((instance -> server = instance));
LifecycleEvent.SERVER_STOPPED.register(instance -> server = null);
InteractionEvent.RIGHT_CLICK_BLOCK.register(((player, hand, pos, face) -> {
Level level = player.getLevel();
Level level = player.level();
if (!player.getItemInHand(hand).isEmpty() && player.getItemInHand(hand).getItem() == Items.PAPER) {
if (level.getBlockState(pos).getBlock() instanceof PrinterBlock) {
return EventResult.interruptTrue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.ultreon.devices.util.DataHandler;
import com.ultreon.devices.util.GLHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -121,7 +122,7 @@ public void onTick() {
/**
* Renders the application. This method is called every frame.
*
* @param pose the current pose stack.
* @param graphics gui graphics helper
* @param laptop the laptop instance.
* @param mc the minecraft instance.
* @param x the x position of the top left corner of the application window.
Expand All @@ -132,11 +133,11 @@ public void onTick() {
* @param partialTicks the render partial ticks.
*/
@Override
public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean active, float partialTicks) {
public void render(GuiGraphics graphics, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean active, float partialTicks) {
// GL11.glEnable(GL11.GL_SCISSOR_TEST);

GLHelper.pushScissor(x, y, width, height);
currentLayout.render(pose, laptop, mc, x, y, mouseX, mouseY, active, partialTicks);
currentLayout.render(graphics, laptop, mc, x, y, mouseX, mouseY, active, partialTicks);
GLHelper.popScissor();

// TODO Port this to 1.18.2 if possible
Expand All @@ -147,7 +148,7 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in

// GL11.glDisable(GL11.GL_SCISSOR_TEST);

currentLayout.renderOverlay(pose, laptop, mc, mouseX, mouseY, active);
currentLayout.renderOverlay(graphics, laptop, mc, mouseX, mouseY, active);

RenderSystem.setShaderColor(1f, 1f, 1f, 1f);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.client.sounds.SoundManager;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -210,7 +210,7 @@ protected void handleTick() {
}

@Override
public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) {
public void render(GuiGraphics graphics, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) {
if (this.visible) {
RenderSystem.setShaderTexture(0, Component.COMPONENTS_GUI);
RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
Expand All @@ -225,19 +225,19 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in
RenderSystem.blendFunc(770, 771);

/* Corners */
GuiComponent.blit(pose, x, y, 2, 2, 96 + i * 5, 12, 2, 2, 256, 256);
GuiComponent.blit(pose, x + width - 2, y, 2, 2, 99 + i * 5, 12, 2, 2, 256, 256);
GuiComponent.blit(pose, x + width - 2, y + height - 2, 2, 2, 99 + i * 5, 15, 2, 2, 256, 256);
GuiComponent.blit(pose, x, y + height - 2, 2, 2, 96 + i * 5, 15, 2, 2, 256, 256);
graphics.blit(Component.COMPONENTS_GUI, x, y, 2, 2, 96 + i * 5, 12, 2, 2, 256, 256);
graphics.blit(Component.COMPONENTS_GUI, x + width - 2, y, 2, 2, 99 + i * 5, 12, 2, 2, 256, 256);
graphics.blit(Component.COMPONENTS_GUI, x + width - 2, y + height - 2, 2, 2, 99 + i * 5, 15, 2, 2, 256, 256);
graphics.blit(Component.COMPONENTS_GUI, x, y + height - 2, 2, 2, 96 + i * 5, 15, 2, 2, 256, 256);

/* Middles */
GuiComponent.blit(pose, x + 2, y, width - 4, 2, 98 + i * 5, 12, 1, 2, 256, 256);
GuiComponent.blit(pose, x + width - 2, y + 2, 2, height - 4, 99 + i * 5, 14, 2, 1, 256, 256);
GuiComponent.blit(pose, x + 2, y + height - 2, width - 4, 2, 98 + i * 5, 15, 1, 2, 256, 256);
GuiComponent.blit(pose, x, y + 2, 2, height - 4, 96 + i * 5, 14, 2, 1, 256, 256);
graphics.blit(Component.COMPONENTS_GUI, x + 2, y, width - 4, 2, 98 + i * 5, 12, 1, 2, 256, 256);
graphics.blit(Component.COMPONENTS_GUI, x + width - 2, y + 2, 2, height - 4, 99 + i * 5, 14, 2, 1, 256, 256);
graphics.blit(Component.COMPONENTS_GUI, x + 2, y + height - 2, width - 4, 2, 98 + i * 5, 15, 1, 2, 256, 256);
graphics.blit(Component.COMPONENTS_GUI, x, y + 2, 2, height - 4, 96 + i * 5, 14, 2, 1, 256, 256);

/* Center */
GuiComponent.blit(pose, x + 2, y + 2, width - 4, height - 4, 98 + i * 5, 14, 1, 1, 256, 256);
graphics.blit(Component.COMPONENTS_GUI, x + 2, y + 2, width - 4, height - 4, 98 + i * 5, 14, 1, 1, 256, 256);

RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
Expand All @@ -249,22 +249,22 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in
if (iconResource != null) {
int iconY = (height - iconHeight) / 2;
RenderSystem.setShaderTexture(0, iconResource);
GuiComponent.blit(pose, x + contentX, y + iconY, iconWidth, iconHeight, iconU, iconV, iconVWidth, iconUHeight, iconSourceWidth, iconSourceHeight);
graphics.blit(Component.COMPONENTS_GUI, x + contentX, y + iconY, iconWidth, iconHeight, iconU, iconV, iconVWidth, iconUHeight, iconSourceWidth, iconSourceHeight);
}

if (!StringUtils.isNullOrEmpty(text)) {
int textY = (height - mc.font.lineHeight) / 2 + 1;
int textOffsetX = iconResource != null ? iconWidth + 3 : 0;
int textColor = !Button.this.enabled ? 0xa0a0a0 : 0xe0e0e0;
drawString(pose, mc.font, text, x + contentX + textOffsetX, y + textY, textColor);
graphics.drawString(mc.font, text, x + contentX + textOffsetX, y + textY, textColor);
}
}
}

@Override
public void renderOverlay(PoseStack pose, Laptop laptop, Minecraft mc, int mouseX, int mouseY, boolean windowActive) {
public void renderOverlay(GuiGraphics graphics, Laptop laptop, Minecraft mc, int mouseX, int mouseY, boolean windowActive) {
if (this.hovered && this.toolTip != null && toolTipTick >= TOOLTIP_DELAY) {
laptop.renderComponentTooltip(pose, Arrays.asList(net.minecraft.network.chat.Component.literal(this.toolTipTitle).withStyle(ChatFormatting.GOLD), net.minecraft.network.chat.Component.literal(this.toolTip)), mouseX, mouseY);
laptop.renderComponentTooltip(graphics, Arrays.asList(net.minecraft.network.chat.Component.literal(this.toolTipTitle).withStyle(ChatFormatting.GOLD), net.minecraft.network.chat.Component.literal(this.toolTip)), mouseX, mouseY);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.GuiGraphics;

/**
* @author MrCrayfish
*/
public abstract class ItemRenderer<E> {
public abstract void render(PoseStack pose, E e, GuiComponent gui, Minecraft mc, int x, int y, int width, int height);
public abstract void render(GuiGraphics pose, E e, Minecraft mc, int x, int y, int width, int height);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import net.minecraft.world.level.block.state.BlockState;
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.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.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
Expand All @@ -51,7 +51,7 @@ public class LaptopBlock extends ComputerBlock.Colored {
private static final VoxelShape SHAPE_CLOSED_WEST = Block.box(1, 0, 1, 13, 2, 15);

public LaptopBlock(DyeColor color) {
super(Properties.of(Material.HEAVY_METAL, color).strength(6f).sound(SoundType.METAL), color, ModDeviceTypes.COMPUTER);
super(Properties.of().mapColor(color).strength(6f).sound(SoundType.METAL), color, ModDeviceTypes.COMPUTER);
}

@Override
Expand Down Expand Up @@ -83,7 +83,7 @@ protected void removeTagsForDrop(CompoundTag tileEntityTag) {

@Override
@SuppressWarnings("deprecation")
public @NotNull List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
public @NotNull List<ItemStack> getDrops(BlockState state, LootParams.Builder builder) {
List<ItemStack> drops = super.getDrops(state, builder);
BlockEntity parameter = builder.getOptionalParameter(LootContextParams.BLOCK_ENTITY);
if (parameter == null) return drops;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext;
Expand Down Expand Up @@ -85,7 +84,7 @@ public class MacMaxXBlock extends ComputerBlock {
);

public MacMaxXBlock() {
super(BlockBehaviour.Properties.of(Material.HEAVY_METAL, DyeColor.WHITE).strength(6f).sound(SoundType.METAL).noOcclusion().dynamicShape());
super(BlockBehaviour.Properties.of().mapColor(DyeColor.WHITE).strength(6f).sound(SoundType.METAL).noOcclusion().dynamicShape());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
Expand Down Expand Up @@ -255,7 +254,7 @@ public class MacMaxXBlockPart extends HorizontalDirectionalBlock {
Block.box(6.5, 0 - 16, 17 - 16, 9, 0.5 - 16, 23 - 16));

public MacMaxXBlockPart() {
super(Properties.of(Material.HEAVY_METAL, DyeColor.WHITE).strength(6f).sound(SoundType.METAL));
super(Properties.of().mapColor(DyeColor.WHITE).strength(6f).sound(SoundType.METAL));
registerDefaultState(this.getStateDefinition().any().setValue(FACING, Direction.NORTH).setValue(PART, Part.T));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.EntityCollisionContext;
Expand All @@ -44,7 +43,7 @@ public class OfficeChairBlock extends DeviceBlock.Colored

public OfficeChairBlock(DyeColor color)
{
super(BlockBehaviour.Properties.of(Material.STONE, color.getMaterialColor()), color, ModDeviceTypes.SEAT);
super(BlockBehaviour.Properties.of().mapColor(color), color, ModDeviceTypes.SEAT);
//this.setUnlocalizedName("office_chair");
//this.setRegistryName("office_chair");
//this.setCreativeTab(MrCrayfishDeviceMod.TAB_DEVICE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
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.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.LootParams;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
Expand All @@ -40,7 +40,7 @@ public class PaperBlock extends HorizontalDirectionalBlock implements EntityBloc
private static final VoxelShape[] SELECTION_BOUNDING_BOX = {SELECTION_BOX_SOUTH, SELECTION_BOX_WEST, SELECTION_BOX_NORTH, SELECTION_BOX_EAST};

public PaperBlock() {
super(Properties.of(Material.CLOTH_DECORATION).noCollission().instabreak().noOcclusion().noLootTable());
super(Properties.of().noCollission().instabreak().noOcclusion().noLootTable());

registerDefaultState(getStateDefinition().any().setValue(FACING, Direction.NORTH));
}
Expand Down Expand Up @@ -76,7 +76,7 @@ public InteractionResult use(BlockState pState, Level level, BlockPos pPos, Play
}

@Override
public List<ItemStack> getDrops(BlockState pState, LootContext.Builder pBuilder) {
public List<ItemStack> getDrops(BlockState pState, LootParams.Builder pBuilder) {
return new ArrayList<>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
Expand Down Expand Up @@ -78,7 +77,7 @@ public class PrinterBlock extends DeviceBlock.Colored implements Colored {
box(12, 3, 4, 16, 9.3, 12));

public PrinterBlock(DyeColor color) {
super(Properties.of(Material.HEAVY_METAL, color).strength(6f).sound(SoundType.METAL), color, ModDeviceTypes.PRINTER);
super(Properties.of().mapColor(color).strength(6f).sound(SoundType.METAL), color, ModDeviceTypes.PRINTER);
this.registerDefaultState(getStateDefinition().any().setValue(FACING, Direction.NORTH));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
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.material.Material;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
Expand Down Expand Up @@ -59,7 +58,7 @@ public class RouterBlock extends DeviceBlock.Colored {
};

public RouterBlock(DyeColor color) {
super(Properties.of(Material.HEAVY_METAL).strength(6f).sound(SoundType.METAL), color, ModDeviceTypes.ROUTER);
super(Properties.of().mapColor(color).strength(6f).sound(SoundType.METAL), color, ModDeviceTypes.ROUTER);
this.registerDefaultState(this.getStateDefinition().any().setValue(FACING, Direction.NORTH).setValue(VERTICAL, false));
}

Expand Down
Loading

0 comments on commit 8d0052f

Please sign in to comment.