Jump to content

Forge hooks for Structure loot.


fabricator77

Recommended Posts

I've looked at the Forge hooks for Dungeon loot, and would like something like it for the various other map generated loot chests. Yes there are a lot of them. Basically I want to add items from Forge mods to chests, which is easy without Forge until Bukkit is involved.

 

The idea I have is to modify StructureComponent.class so the StructurePieceTreasure[] part is removed/ignored, and a class parameter used instead to determine what set of loot to generate (eg ComponentStrongholdLibrary.class). This way when Mojang add yet another structure with chest loots in it, the API doesn't need yet more changes.

 

I don't mind doing most/all of the code changes, just want to hear what others think of the implementation. Also should I go with 1.2.5 or is it likely to be a wasted effort ?

Link to comment
Share on other sites

Dont make anything for 1.2.5 anymore. As as soon as major mods update, nobody will use 1.2.5 anymore

As for the the Structure loot, I have planned for a while to expand this to any world gen chest loot, but that is a future feature, we are currently in the 'fix bugs' stage of Forge, not the 'Add new things'

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

I've added a few lines of code to StructureComponent so it can determine its called class, eg: ComponentMineshaftCorridor.class and use that name to store each set of loot. This way any structure created gets its own unique loot set, even ones added by modders. Still need to write a data structure to store it all, then look at the pull request.

 

StructureComponent.class contains:

func_74879_a

Loot chests

 

func_74869_a

Dispensers

 

So I might at well tap into the Dispenser code, so mean people can put fire arrows in them or something.

Link to comment
Share on other sites

  • 5 weeks later...
  • 3 weeks later...

Got enchanted dungeon loot thanks to the recent changes in Forge (4.2.x)

Thanks for that LexManos!

I had to brush up on sub-classes and such to get it going but I'll put what I found here (if that's ok)

 

The override class:

 

 

package net.minecraft.src;

import net.minecraft.client.Minecraft;

import net.minecraftforge.common.DungeonHooks;

import net.minecraftforge.common.DungeonHooks.DungeonLoot;

import net.minecraft.src.EnchantmentHelper;

import net.minecraft.src.EnchantmentData;

import java.util.*;

 

public class enchantedLoot extends DungeonHooks.DungeonLoot

{

        private ItemStack itemStack;

        private int minCount = 1;

        private int maxCount = 1;

        private int minEnchantLevel = 1;

        private int maxEnchantLevel = 1;

        private int enchantChance = 0;

 

public enchantedLoot(ItemStack item, int weight, int min, int max, int ench)

{

super(weight, item, 1, 1);

this.itemStack = item;

minEnchantLevel = min;

maxEnchantLevel = max;

if (max < min)

{

maxEnchantLevel = min;

}

enchantChance = ench;

 

// Enchantable items should never be stackable

minCount = 1;

maxCount = 1;

}

 

public ItemStack generateStack(Random rand)

{

ItemStack ret = this.itemStack.copy();

 

ret.stackSize = minCount + (rand.nextInt(maxCount - minCount + 1));

if (enchantChance > 0)

{

int i = rand.nextInt(100);

if (i < enchantChance)

{

int level = minEnchantLevel + (rand.nextInt(maxEnchantLevel - minEnchantLevel + 1));

ret.stackSize = 1;

List list = EnchantmentHelper.buildEnchantmentList(rand, ret, level);

if(list != null)

{

EnchantmentData enchantmentdata;

for(Iterator iterator = list.iterator(); iterator.hasNext(); ret.addEnchantment(enchantmentdata.enchantmentobj, enchantmentdata.enchantmentLevel))

{

enchantmentdata = (EnchantmentData)iterator.next();

}

}

}

}

            return ret;

        }

}

 

 

 

Then to reference it, add a method to your code:

 

 

private void addEnchantedLoot(ItemStack item, int weight, int min, int max, int ench)

{

DungeonHooks newLoot = new DungeonHooks();

newLoot.addDungeonLoot((DungeonHooks.DungeonLoot)new enchantedLoot(item, weight, min, max, ench));

}

 

 

 

Then if you want to add, for instance, randomly enchanted bows, you could use:

addEnchantedLoot(new ItemStack(Item.bow),100, 1,30, 10);

where 100 is the weight (chance it will be in loot)

1 is the minimum enchantment level

30 is the maximum enchantment level

10 is the percent chance the item will have any enchantment

Link to comment
Share on other sites

  • 3 months later...

::)

Yeah yeah. Copy-paste heaven and structure sucks. It's been like 10 years since I had a college course in Java. I'll learn better coding skills if/when I get a full time job writing code.

The main reason for this reply is because with the deprication of DungeonHooks, this all changes. The only way I can think of doing the same thing now is to either add one of every possible enchantment of every possible tool/armor/weapon or to create some kind of new fake item which replaces itself with an enchanted item when created. Not even sure if that would work.

So with the current structure, is it still possible to add dungeon loot that will have a random enchantment applied when generated? If so, any hints?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • DAFTAR DAN LOGIN DISINI   Hantogel atau handogel adalah bentuk pengumpulan duka uang yang populer di dunia judi online, khususnya dalam permainan slot gacor. Banyak situs judi online yang menawarkan handogel slot gacor, dan sebagai pemain, penting untuk mengetahui cara memilih dan mengakses situs tersebut dengan aman dan amanah. Dalam artikel ini, kami akan membahas cara memilih situs slot gacor online yang berkualitas dan tahu cara mengakses handogelnya.
    • DAFTAR & LOGIN SIRITOGEL Siritogel adalah kumpulan kata yang mungkin baru saja dikenal oleh masyarakat, namun dengan perkembangan teknologi dan banyaknya informasi yang tersedia di internet, kalau kita siritogel (mencari informasi dengan cara yang cermat dan rinci) tentang situs slot gacor online, maka kita akan menemukan banyak hal yang menarik dan membahayakan sama sekali. Dalam artikel ini, kita akan mencoba menjelaskan apa itu situs slot gacor online dan bagaimana cara mengatasi dampaknya yang negatif.
    • This honestly might just work for you @SubscribeEvent public static void onScreenRender(ScreenEvent.Render.Post event) { final var player = Minecraft.getInstance().player; final var options = Minecraft.getInstance().options; if(!hasMyEffect(player)) return; // TODO: You provide hasMyEffect float f = Mth.lerp(event.getPartialTick(), player.oSpinningEffectIntensity, player.spinningEffectIntensity); float f1 = ((Double)options.screenEffectScale().get()).floatValue(); if(f <= 0F || f1 >= 1F) return; float p_282656_ = f * (1.0F - f1); final var p_282460_ = event.getGuiGraphics(); int i = p_282460_.guiWidth(); int j = p_282460_.guiHeight(); p_282460_.pose().pushPose(); float f5 = Mth.lerp(p_282656_, 2.0F, 1.0F); p_282460_.pose().translate((float)i / 2.0F, (float)j / 2.0F, 0.0F); p_282460_.pose().scale(f5, f5, f5); p_282460_.pose().translate((float)(-i) / 2.0F, (float)(-j) / 2.0F, 0.0F); float f4 = 0.2F * p_282656_; float f2 = 0.4F * p_282656_; float f3 = 0.2F * p_282656_; RenderSystem.disableDepthTest(); RenderSystem.depthMask(false); RenderSystem.enableBlend(); RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE); p_282460_.setColor(f4, f2, f3, 1.0F); p_282460_.blit(new ResourceLocation("textures/misc/nausea.png"), 0, 0, -90, 0.0F, 0.0F, i, j, i, j); p_282460_.setColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.defaultBlendFunc(); RenderSystem.disableBlend(); RenderSystem.depthMask(true); RenderSystem.enableDepthTest(); p_282460_.pose().popPose(); }   Note: Most of this is directly copied from GameRenderer as you pointed out you found. The only thing you'll have to likely do is update the `oSpinningEffectIntensity` + `spinningEffectIntensity` variables on the player when your effect is applied. Which values should be there? Not 100% sure, might be a game of guess and check, but `handleNetherPortalClient` in LocalPlayer has some hard coded you might be able to start with.
    • Dalam dunia perjudian online yang berkembang pesat, mencari platform yang dapat memberikan kemenangan maksimal dan hasil terbaik adalah impian setiap penjudi. OLXTOTO, dengan bangga, mempersembahkan dirinya sebagai jawaban atas pencarian itu. Sebagai platform terbesar untuk kemenangan maksimal dan hasil optimal, OLXTOTO telah menciptakan gelombang besar di komunitas perjudian online. Satu dari banyak keunggulan yang dimiliki OLXTOTO adalah koleksi permainan yang luas dan beragam. Dari togel hingga slot online, dari live casino hingga permainan kartu klasik, OLXTOTO memiliki sesuatu untuk setiap pemain. Dibangun dengan teknologi terkini dan dikembangkan oleh para ahli industri, setiap permainan di platform ini dirancang untuk memberikan pengalaman yang tak tertandingi bagi para penjudi. Namun, keunggulan OLXTOTO tidak hanya terletak pada variasi permainan yang mereka tawarkan. Mereka juga menonjol karena komitmen mereka terhadap keamanan dan keadilan. Dengan sistem keamanan tingkat tinggi dan proses audit yang ketat, OLXTOTO memastikan bahwa setiap putaran permainan berjalan dengan adil dan transparan. Para pemain dapat merasa aman dan yakin bahwa pengalaman berjudi mereka di OLXTOTO tidak akan terganggu oleh masalah keamanan atau keadilan. Tak hanya itu, OLXTOTO juga terkenal karena layanan pelanggan yang luar biasa. Tim dukungan mereka selalu siap sedia untuk membantu para pemain dengan segala pertanyaan atau masalah yang mereka hadapi. Dengan respon cepat dan solusi yang efisien, OLXTOTO memastikan bahwa pengalaman berjudi para pemain tetap mulus dan menyenangkan. Dengan semua fitur dan keunggulan yang ditawarkannya, tidak mengherankan bahwa OLXTOTO telah menjadi pilihan utama bagi jutaan penjudi online di seluruh dunia. Jika Anda mencari platform yang dapat memberikan kemenangan maksimal dan hasil optimal, tidak perlu mencari lebih jauh dari OLXTOTO. Bergabunglah dengan OLXTOTO hari ini dan mulailah petualangan Anda menuju kemenangan besar dan hasil terbaik!
    • Selamat datang di OLXTOTO, situs slot gacor terpanas yang sedang booming di industri perjudian online. Jika Anda mencari pengalaman bermain yang luar biasa, maka OLXTOTO adalah tempat yang tepat untuk Anda. Dapatkan sensasi tidak biasa dengan variasi slot online terlengkap dan peluang memenangkan jackpot slot maxwin yang sering. Di sini, Anda akan merasakan keseruan yang luar biasa dalam bermain judi slot. DAFTAR OLXTOTO DISINI LOGIN OLXTOTO DISINI AKUN PRO OLXTOTO DISINI   Jackpot Slot Maxwin Sering Untuk Peluang Besar Di OLXTOTO, kami tidak hanya memberikan hadiah slot biasa, tapi juga memberikan kesempatan kepada pemain untuk memenangkan jackpot slot maxwin yang sering. Dengan demikian, Anda dapat meraih keberuntungan besar dan memenangkan ribuan rupiah sebagai hadiah jackpot slot maxwin kami. Jackpot slot maxwin merupakan peluang besar bagi para pemain judi slot untuk meraih keuntungan yang lebih besar. Dalam permainan kami, Anda tidak harus terpaku pada kemenangan biasa saja. Kami hadir dengan jackpot slot maxwin yang sering, sehingga Anda memiliki peluang yang lebih besar untuk meraih kemenangan besar dengan hadiah yang menggiurkan. Dalam permainan judi slot, pengalaman bermain bukan hanya tentang keseruan dan hiburan semata. Kami memahami bahwa para pemain juga menginginkan kesempatan untuk meraih keberuntungan besar. Oleh karena itu, OLXTOTO hadir dengan jackpot slot maxwin yang sering untuk memberikan peluang besar kepada para pemain kami. Peluang Besar Menang Jackpot Slot Maxwin Peluang menang jackpot slot maxwin di OLXTOTO sangatlah besar. Anda tidak perlu khawatir tentang batasan atau pembatasan dalam meraih jackpot tersebut. Kami ingin memberikan kesempatan kepada semua pemain kami untuk merasakan sensasi menang dalam jumlah yang luar biasa. Jackpot slot maxwin kami dibuka untuk semua pemain judi slot di OLXTOTO. Anda memiliki peluang yang sama dengan pemain lainnya untuk memenangkan hadiah jackpot yang besar. Kami percaya bahwa semua orang memiliki kesempatan untuk meraih keberuntungan besar, dan itulah mengapa kami menyediakan jackpot slot maxwin yang sering untuk memenuhi harapan dan keinginan Anda.   Kesimpulan OLXTOTO adalah situs slot gacor terbaik yang memberikan pengalaman bermain judi slot online yang tak terlupakan. Dengan variasi slot online terlengkap dan peluang memenangkan jackpot slot maxwin yang sering, OLXTOTO menjadi pilihan terbaik bagi para pemain yang mencari kesenangan dan kemenangan besar dalam perjudian online. Di samping itu, OLXTOTO juga menawarkan layanan pelanggan yang ramah dan responsif, siap membantu setiap pemain dalam mengatasi masalah teknis atau pertanyaan seputar perjudian online. Kami menjaga integritas game dan memberikan lingkungan bermain yang adil serta menjalankan kebijakan perlindungan pelanggan yang cermat. Bergabunglah dengan OLXTOTO sekarang dan nikmati pengalaman bermain slot online yang luar biasa. Jadilah bagian dari komunitas perjudian yang mengagumkan ini dan raih kesempatan untuk meraih kemenangan besar. Dapatkan akses mudah dan praktis ke situs OLXTOTO dan rasakan sensasi bermain judi slot yang tak terlupakan.  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.