Skip to content

Commit

Permalink
⚙️ More progression
Browse files Browse the repository at this point in the history
  • Loading branch information
XyperCode committed Jun 23, 2024
1 parent 93df7d3 commit 76692f0
Show file tree
Hide file tree
Showing 20 changed files with 120 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class LaptopFont extends FontRenderer {
private boolean debug = false;

public LaptopFont(Minecraft mc) {
super(res -> new LaptopFontSet(mc.getTextureManager(), Devices.res("laptop")));
super(res -> new LaptopFont(mc.getTextureManager(), Devices.res("laptop")));
}

// Todo: Port to 1.18.2 where possible.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package com.ultreon.devices.core.client;

import com.mojang.blaze3d.font.GlyphInfo;
import net.minecraft.client.gui.font.FontSet;
import com.mojang.blaze3d.font.IGlyph;
import net.minecraft.client.gui.font.Font;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
import org.jetbrains.annotations.Nullable;

/**
* @author Qboi123
*/
public class LaptopFontSet extends FontSet {
private static final GlyphInfo TAB_INFO = () -> 16.0f;
public class LaptopFont extends Font {
private static final IGlyph TAB_INFO = () -> 16.0f;

public LaptopFontSet(TextureManager pTextureManager, ResourceLocation pName) {
public LaptopFont(TextureManager pTextureManager, ResourceLocation pName) {
super(pTextureManager, pName);
}

@Nullable
@Override
public GlyphInfo getGlyphInfoForSpace(int i) {
return i == 9 ? TAB_INFO : super.getGlyphInfoForSpace(i);
public IGlyph getIGlyphForSpace(int i) {
return i == 9 ? TAB_INFO : super.getIGlyphForSpace(i);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
import net.minecraft.network.protocol.game.SSpawnObjectPacket;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntitySize;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.Pose;
import net.minecraft.entity.decoration.ArmorStand;
Expand All @@ -29,7 +29,7 @@ public SeatEntity(EntityType<SeatEntity> type, World worldIn)
}

@Override
protected float getEyeHeight(Pose pose, EntityDimensions dimensions) {
protected float getEyeHeight(Pose pose, EntitySize dimensions) {
return 0;
}

Expand Down Expand Up @@ -79,7 +79,7 @@ public Entity getControllingPassenger()

@Override
public Packet<?> getAddEntityPacket() {
return new ClientboundAddEntityPacket(this);
return new SSpawnObjectPacket(this);
}

// @Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.ultreon.devices.mixin.common;

import com.mojang.blaze3d.font.GlyphInfo;
import com.mojang.blaze3d.font.IGlyph;
import com.ultreon.devices.Devices;
import net.minecraft.client.gui.font.FontSet;
import net.minecraft.client.gui.font.Font;
import net.minecraft.util.ResourceLocation;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -11,13 +11,13 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(FontSet.class)
public class FontSetMixin {
@Mixin(Font.class)
public class FontMixin {
@Shadow @Final private ResourceLocation name;
private static final GlyphInfo DEVICES_TAB_INFO = () -> 16.0f;
private static final IGlyph DEVICES_TAB_INFO = () -> 16.0f;

@Inject(method = "getGlyphInfoForSpace", at = @At("HEAD"))
public void getGlyphInfoForSpace(int i, CallbackInfoReturnable<GlyphInfo> cir) {
@Inject(method = "getIGlyphForSpace", at = @At("HEAD"))
public void getIGlyphForSpace(int i, CallbackInfoReturnable<IGlyph> cir) {
if (name.equals(Devices.res("laptop")) && i == 9) {
cir.setReturnValue(DEVICES_TAB_INFO);
}
Expand Down
6 changes: 3 additions & 3 deletions common/src/main/resources/devices.accesswidener
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
accessWidener v2 named
accessible method net/minecraft/client/gui/font/FontSet getGlyphInfoForSpace (I)Lcom/mojang/blaze3d/font/GlyphInfo;
extendable method net/minecraft/client/gui/font/FontSet getGlyphInfoForSpace (I)Lcom/mojang/blaze3d/font/GlyphInfo;
accessible method net/minecraft/client/gui/Font getFontSet (Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/gui/font/FontSet;
accessible method net/minecraft/client/gui/font/Font getIGlyphForSpace (I)Lcom/mojang/blaze3d/font/IGlyph;
extendable method net/minecraft/client/gui/font/Font getIGlyphForSpace (I)Lcom/mojang/blaze3d/font/IGlyph;
accessible method net/minecraft/client/gui/Font getFont (Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/gui/font/Font;
accessible field net/minecraft/client/Minecraft fontManager Lnet/minecraft/client/gui/font/FontManager;
accessible method net/minecraft/client/renderer/LevelRenderer renderEntity (Lnet/minecraft/world/entity/Entity;DDDFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;)V
11 changes: 0 additions & 11 deletions src/main/java/com/ultreon/devices/Devices.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.ultreon.devices;

import com.google.common.base.Suppliers;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
Expand Down Expand Up @@ -41,16 +40,6 @@
import com.ultreon.devices.programs.system.*;
import com.ultreon.devices.programs.system.task.*;
import com.ultreon.devices.util.SiteRegistration;
import dev.architectury.event.EventResult;
import dev.architectury.event.events.client.ClientPlayerEvent;
import dev.architectury.event.events.common.InteractionEvent;
import dev.architectury.event.events.common.LifecycleEvent;
import dev.architectury.event.events.common.PlayerEvent;
import dev.architectury.injectables.annotations.ExpectPlatform;
import dev.architectury.injectables.targets.ArchitecturyTarget;
import dev.architectury.platform.Platform;
import dev.architectury.registry.CreativeTabRegistry;
import dev.architectury.registry.registries.Registries;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
import com.ultreon.devices.api.utils.RenderUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.widget.toasts.Toast;
import net.minecraft.client.gui.widget.toasts.ToastComponent;
import net.minecraft.client.gui.toasts.IToast;
import net.minecraft.client.gui.toasts.ToastGui;
import net.minecraft.client.resources.I18n;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.Constants;
import org.jetbrains.annotations.NotNull;

/**
* @author MrCrayfish
*/
public class ClientNotification implements Toast {
public class ClientNotification implements IToast {
private static final ResourceLocation TEXTURE_TOASTS = new ResourceLocation("devices:textures/gui/toast.png");

private IIcon icon;
Expand All @@ -28,9 +29,9 @@ private ClientNotification() {

@NotNull
@Override
public Visibility render(@NotNull MatrixStack pose, ToastComponent toastComponent, long timeSinceLastVisible) {
public Visibility render(@NotNull MatrixStack pose, ToastGui toastComponent, long timeSinceLastVisible) {
RenderSystem.blendColor(1f, 1f, 1f, 1f);
mc.textureManager.bind(TEXTURE_TOASTS);
Minecraft.getInstance().textureManager.bind(TEXTURE_TOASTS);
toastComponent.blit(pose, 0, 0, 0, 0, 160, 32);
FontRenderer font = toastComponent.getMinecraft().font;

Expand All @@ -41,7 +42,7 @@ public Visibility render(@NotNull MatrixStack pose, ToastComponent toastComponen
font.draw(pose, font.plainSubstrByWidth(I18n.get(subTitle), 118), 38, 18, -1);
}

mc.textureManager.bind(icon.getIconAsset());
Minecraft.getInstance().textureManager.bind(icon.getIconAsset());
RenderUtil.drawRectWithTexture(pose, 6, 6, icon.getGridWidth(), icon.getGridHeight(), icon.getU(), icon.getV(), icon.getSourceWidth(), icon.getSourceHeight(), icon.getIconSize(), icon.getIconSize());

return timeSinceLastVisible >= 5000L ? Visibility.HIDE : Visibility.SHOW;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class LaptopFont extends FontRenderer {
private boolean debug = false;

public LaptopFont(Minecraft mc) {
super(res -> new LaptopFontSet(mc.getTextureManager(), Devices.res("laptop")));
super(res -> new LaptopFont(mc.getTextureManager(), Devices.res("laptop")));
}

// Todo: Port to 1.18.2 where possible.
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/ultreon/devices/core/client/LaptopFontSet.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package com.ultreon.devices.core.client;

import com.mojang.blaze3d.font.GlyphInfo;
import net.minecraft.client.gui.font.FontSet;
import net.minecraft.client.gui.fonts.Font;
import net.minecraft.client.gui.fonts.IGlyph;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
import org.jetbrains.annotations.Nullable;

/**
* @author Qboi123
*/
public class LaptopFontSet extends FontSet {
private static final GlyphInfo TAB_INFO = () -> 16.0f;
public class LaptopFontSet extends Font {
private static final IGlyph TAB_INFO = () -> 16.0f;

public LaptopFontSet(TextureManager pTextureManager, ResourceLocation pName) {
super(pTextureManager, pName);
}

@Nullable
@Override
public GlyphInfo getGlyphInfoForSpace(int i) {
return i == 9 ? TAB_INFO : super.getGlyphInfoForSpace(i);
public IGlyph getGlyphInfo(int i) {
return i == 9 ? TAB_INFO : super.getGlyphInfo(i);
}
}
Original file line number Diff line number Diff line change
@@ -1,50 +1,38 @@
package com.ultreon.devices.core.client.debug;

import com.ultreon.devices.DeviceConfig;
import com.ultreon.devices.block.entity.LaptopBlockEntity;
import com.ultreon.devices.core.Laptop;
import com.ultreon.devices.core.laptop.client.ClientLaptop;
import com.ultreon.devices.core.laptop.client.ClientLaptopScreen;
import com.ultreon.devices.core.laptop.server.ServerLaptop;
import dev.architectury.event.events.client.ClientGuiEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.gui.screens.TitleScreen;
import net.minecraft.util.text.StringTextComponent;

/**
* Adds a button to the title screen to test system applications that don't require the system
*/
public class ClientAppDebug {
public static void register() {
if (DeviceConfig.DEBUG_BUTTON.get()) {
ClientGuiEvent.INIT_POST.register(((screen, access) -> {
if (!(screen instanceof TitleScreen)) return;
int rowHeight = 24;
var y = screen.height / 4 + 48;

Button a = new Button(screen.width / 2 - 100, y + rowHeight * -2, 200, 20, new StringTextComponent("DV TEST"), (button) -> {
Minecraft.getInstance().setScreen(new Laptop(new LaptopBlockEntity(), true));
}, Button.NO_TOOLTIP);
access.addRenderableWidget(a);
}));


ClientGuiEvent.INIT_POST.register(((screen, access) -> {
if (!(screen instanceof TitleScreen)) return;
int rowHeight = 24;
var y = screen.height / 4 + 48;

Button a = new Button(screen.width / 2 - 100, y + rowHeight * -3, 200, 20, new StringTextComponent("DV TEST #2"), (button) -> {
ServerLaptop serverLaptop = new ServerLaptop();
ServerLaptop.laptops.put(serverLaptop.getUuid(), serverLaptop);
ClientLaptop clientLaptop = new ClientLaptop();
clientLaptop.setUuid(serverLaptop.getUuid());
ClientLaptop.laptops.put(clientLaptop.getUuid(), clientLaptop);
Minecraft.getInstance().setScreen(new ClientLaptopScreen(clientLaptop));
}, Button.NO_TOOLTIP);
access.addRenderableWidget(a);
}));
}
// if (DeviceConfig.DEBUG_BUTTON.get()) {
// ClientGuiEvent.INIT_POST.register(((screen, access) -> {
// if (!(screen instanceof TitleScreen)) return;
// int rowHeight = 24;
// var y = screen.height / 4 + 48;
//
// Button a = new Button(screen.width / 2 - 100, y + rowHeight * -2, 200, 20, new StringTextComponent("DV TEST"), (button) -> {
// Minecraft.getInstance().setScreen(new Laptop(new LaptopBlockEntity(), true));
// }, Button.NO_TOOLTIP);
// access.addRenderableWidget(a);
// }));
//
//
// ClientGuiEvent.INIT_POST.register(((screen, access) -> {
// if (!(screen instanceof TitleScreen)) return;
// int rowHeight = 24;
// var y = screen.height / 4 + 48;
//
// Button a = new Button(screen.width / 2 - 100, y + rowHeight * -3, 200, 20, new StringTextComponent("DV TEST #2"), (button) -> {
// ServerLaptop serverLaptop = new ServerLaptop();
// ServerLaptop.laptops.put(serverLaptop.getUuid(), serverLaptop);
// ClientLaptop clientLaptop = new ClientLaptop();
// clientLaptop.setUuid(serverLaptop.getUuid());
// ClientLaptop.laptops.put(clientLaptop.getUuid(), clientLaptop);
// Minecraft.getInstance().setScreen(new ClientLaptopScreen(clientLaptop));
// }, Button.NO_TOOLTIP);
// access.addRenderableWidget(a);
// }));
// }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.ultreon.devices.Reference;
import net.minecraft.client.gui.IngameGui;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TranslationTextComponent;
import org.jetbrains.annotations.NotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import com.ultreon.devices.init.DeviceBlocks;
import com.ultreon.devices.init.ModTags;
import net.minecraft.block.Block;
import net.minecraft.data.BlockTagsProvider;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.tags.BlockTagsProvider;
import org.jetbrains.annotations.NotNull;

public class ModBlockTagsProvider extends BlockTagsProvider {
Expand All @@ -20,9 +20,9 @@ public String getName() {

@Override
protected void addTags() {
TagAppender<Block> laptops = this.tag(ModTags.Blocks.LAPTOPS);
TagAppender<Block> printers = this.tag(ModTags.Blocks.PRINTERS);
TagAppender<Block> routers = this.tag(ModTags.Blocks.ROUTERS);
Builder<Block> laptops = this.tag(ModTags.Blocks.LAPTOPS);
Builder<Block> printers = this.tag(ModTags.Blocks.PRINTERS);
Builder<Block> routers = this.tag(ModTags.Blocks.ROUTERS);

DeviceBlocks.getAllLaptops().forEach(laptops::add);
DeviceBlocks.getAllPrinters().forEach(printers::add);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.ultreon.devices.init.DeviceItems;
import com.ultreon.devices.init.ModTags;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.tags.ItemTagsProvider;
import net.minecraft.data.ItemTagsProvider;
import net.minecraft.item.Item;
import org.jetbrains.annotations.NotNull;

Expand All @@ -20,10 +20,10 @@ public String getName() {

@Override
protected void addTags() {
TagAppender<Item> laptops = this.tag(ModTags.Items.LAPTOPS);
TagAppender<Item> printers = this.tag(ModTags.Items.PRINTERS);
TagAppender<Item> routers = this.tag(ModTags.Items.ROUTERS);
TagAppender<Item> flashDrives = this.tag(ModTags.Items.FLASH_DRIVES);
Builder<Item> laptops = this.tag(ModTags.Items.LAPTOPS);
Builder<Item> printers = this.tag(ModTags.Items.PRINTERS);
Builder<Item> routers = this.tag(ModTags.Items.ROUTERS);
Builder<Item> flashDrives = this.tag(ModTags.Items.FLASH_DRIVES);

DeviceItems.getAllLaptops().forEach(laptops::add);
DeviceItems.getAllPrinters().forEach(printers::add);
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/ultreon/devices/entity/SeatEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import com.ultreon.devices.init.DeviceEntities;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntitySize;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.Pose;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
import net.minecraft.network.IPacket;
import net.minecraft.network.play.server.SSpawnObjectPacket;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
Expand All @@ -27,7 +27,7 @@ public SeatEntity(EntityType<SeatEntity> type, World worldIn)
}

@Override
protected float getEyeHeight(Pose pose, EntityDimensions dimensions) {
protected float getEyeHeight(Pose pose, EntitySize dimensions) {
return 0;
}

Expand Down Expand Up @@ -61,7 +61,7 @@ protected void defineSynchedData() {
@Override
public void tick()
{
if(!this.level.isClientSide && (!this.hasExactlyOnePlayerPassenger() || this.level.isEmptyBlock(this.getOnPos())))
if(!this.level.isClientSide && (!this.hasOnePlayerPassenger() || this.level.isEmptyBlock(this.getOnPos())))
{
this.kill();
}
Expand All @@ -77,8 +77,8 @@ public Entity getControllingPassenger()
}

@Override
public @NotNull Packet<?> getAddEntityPacket() {
return new ClientboundAddEntityPacket(this);
public @NotNull IPacket<?> getAddEntityPacket() {
return new SSpawnObjectPacket(this);
}

// @Override
Expand Down
Loading

0 comments on commit 76692f0

Please sign in to comment.