RGB Chat

RGB Chat

699 Downloads

Lootbeams and ItemBoarders integrations code

Titoo8899 opened this issue · 2 comments

commented

Hi,
I have a little check and look this code. I have a little time with the function of ItemBoarders and Lootbeams work and look this code. It will work for 1.12.2. Look and I hope this help you a little the Problems with Item Boarders to fix.

Code:

LootBeams + ItemBoarders Code for 1.12.2 MC Version Forge:

@mod(modid = "coloredbordersmod", name = "Colored Borders Mod", version = "1.0", acceptedMinecraftVersions = "[1.12.2]")
public class ColoredBordersMod {
private List whiteList = new ArrayList<>();
private List blackList = new ArrayList<>();
private Map<String, Integer> itemColors = new HashMap<>();

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
    //Initialisiere Konfiguration hier
    File configFile = event.getSuggestedConfigurationFile();
    Configuration config = new Configuration(configFile);
    config.load();

    whiteList = Arrays.asList(config.getStringList("whitelist", "items", new String[] {}, "A list of item names to be included in the colored border."));
    blackList = Arrays.asList(config.getStringList("blacklist", "items", new String[] {}, "A list of item names to be excluded from the colored border."));

    ConfigurationSection colorConfig = config.getConfigurationSection("colors");
    if (colorConfig != null) {
        for (String key : colorConfig.getKeys(false)) {
            itemColors.put(key, Integer.decode(colorConfig.getString(key)));
        }
    }
    
    //Beispiel, um eine Farbe hinzuzufügen
    itemColors.put("minecraft:diamond", 0x00FF00);
    
    config.save();
}

@SubscribeEvent
public void onRenderInventory(RenderGameOverlayEvent.Pre event) {
    if (event.getType() == RenderGameOverlayEvent.ElementType.INVENTORY) {
        //Render Code hier für das Inventar
        ItemStack stack = Minecraft.getMinecraft().player.inventory.getCurrentItem();
        String itemName = stack.getItem().getRegistryName().toString();

        if (!blackList.contains(itemName) && (whiteList.isEmpty() || whiteList.contains(itemName))) {
            int color = itemColors.getOrDefault(itemName, 0xFFFFFF);
            //Zeichne Farbrand mit der bestimmten Farbe
        }
    }
}

@SubscribeEvent
public void onRenderWorld(RenderWorldLastEvent event) {
    //Render Code hier für die Welt
    Minecraft mc = Minecraft.getMinecraft();
    EntityPlayer player = mc.player;

    double x = player.lastTickPosX + (player.posX - player.lastTickPosX) * event.getPartialTicks();
    double y = player.lastTickPosY + (player.posY - player.lastTickPosY) * event.getPartialTicks();
    double z = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * event.getPartialTicks();

    GlStateManager.pushMatrix();
    GlStateManager.translate(-x, -y, -z);

    for (Object object : mc.world.loadedEntityList) {
        if (object instanceof EntityItem) {
            EntityItem item = (EntityItem) object;
            ItemStack stack = item.getItem();
            String itemName = stack.getItem().getRegistryName().toString();

            if (!blackList.contains(itemName) && (whiteList.isEmpty() || whiteList.contains(itemName))) {
                int color = itemColors.getOrDefault(itemName, 0xFFFFFF);

                double xPos = item.posX;
                double yPos = item.posY;
                double zPos = item.posZ;

                GlStateManager.pushMatrix();
                GlStateManager.translate(xPos, yPos, zPos);

                //Zeichne Farbigen Strahl
                RenderHelper.drawGradientRect(0, 0, 0, 1, 3, color, color);

                GlStateManager.popMatrix();
            }
        }
    }

    GlStateManager.popMatrix();
}

}


Code for a config of the High of a Loom:

private static final int DEFAULT_MAX_HEIGHT = 3;
private int maxHeight;

private void loadConfig() {
maxHeight = config.getInt("maxHeight", Configuration.CATEGORY_GENERAL, DEFAULT_MAX_HEIGHT, 1, 10, "Max height of the beam");
}

private void renderOverlay(float partialTicks) {
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.player;

double x = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
double y = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
double z = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;

GlStateManager.pushMatrix();
GlStateManager.translate(-x, -y, -z);

for (Object object : mc.world.loadedEntityList) {
    if (object instanceof EntityItem) {
        EntityItem item = (EntityItem) object;
        ItemStack stack = item.getItem();
        String itemName = stack.getItem().getRegistryName().toString();

        if (!blackList.contains(itemName) && (whiteList.isEmpty() || whiteList.contains(itemName))) {
            int color = itemColors.getOrDefault(itemName, 0xFFFFFF);

            double xPos = item.posX;
            double yPos = item.posY;
            double zPos = item.posZ;

            GlStateManager.pushMatrix();
            GlStateManager.translate(xPos, yPos, zPos);

            //Zeichne Farbigen Strahl
            RenderHelper.drawGradientRect(0, 0, 0, 1, maxHeight, color, color);

            GlStateManager.popMatrix();
        }
    }
}

GlStateManager.popMatrix();

}

commented

The first line is the Name what the mod code make the other lines was the code.

commented

The first line is the Name what the mod code make the other lines was the code.

some code may not work for 1.12.2,I will try to fix and make the compatible.