Skip to content

Commit

Permalink
Merge pull request #3 from unicornbloods/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
unicornbloods authored Apr 20, 2024
2 parents bfee643 + 473e36c commit a7f2cc5
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 1 deletion.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Thaumic Mixins

A mod to add more configuration to Thaumcraft 4. Possibly bugfixes as well.

# Required Dependencies

* [Thaumcraft](https://www.curseforge.com/minecraft/mc-mods/thaumcraft/files/2227552) (of course)

# Current Features

* Toggle for each individual structure
* Config for structure rarity
* Toggle for Rare crates/urns in Mound structure
* Toggle for champion mobs dropping loot bags
* Config for max loot bag rarity from champions

# Planned Features

* Toggle for village structure spawns
* Fix the maze generation
* Whitelist config for adding more possible champion mobs

# Credits

* Unicorn Blood - Main Dev
* GTNH + jss2a98aj - Helping me with random bugs
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
*/
dependencies {
runtimeOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.5.4-GTNH:dev")
api 'com.github.GTNewHorizons:Baubles:1.0.4:dev'
api ('com.github.GTNewHorizons:Baubles:1.0.4:dev')
api ('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ public class ThaumicMixinsConfig {

//Category names
static final String categoryStructures = "structures";
static final String categoryLoot = "loot";

// Structure
public static boolean moundEnabled = true;
public static int moundFrequency = 150;
public static boolean stoneRingEnabled = true;
Expand All @@ -20,9 +22,14 @@ public class ThaumicMixinsConfig {

public static boolean moundRareLootEnabled = true;

// Loot
public static boolean championLootBagEnabled = true;
public static int championLootBagRarityMax = 2;

public static void synchronizeConfiguration(File configFile) {
Configuration configuration = new Configuration(configFile);

// Structures
moundEnabled = configuration.getBoolean("Mound Enabled", categoryStructures, moundEnabled, "");
moundFrequency = configuration.getInt("Mound Frequency", categoryStructures, moundFrequency, 0, 999999, "Higher is less common");
stoneRingEnabled = configuration.getBoolean("Eldritch Obelisk Enabled", categoryStructures, stoneRingEnabled, "");
Expand All @@ -34,6 +41,10 @@ public static void synchronizeConfiguration(File configFile) {

moundRareLootEnabled = configuration.getBoolean("Mound Rare Loot Enabled", categoryStructures, moundRareLootEnabled,"Remove Rare Urns and Crates from the mounds");

// Loot
championLootBagEnabled = configuration.getBoolean("Champion Loot Bag Drop Enabled", categoryLoot, championLootBagEnabled,"Toggle champion mobs dropping loot bags");
championLootBagRarityMax = configuration.getInt("Max Champion Loot Bag Rarity", categoryLoot, championLootBagRarityMax, 0, 2, "Set max rarity for champion mob loot bags [0 = common, 1 = uncommon, 2 = rare]");

if (configuration.hasChanged()) {
configuration.save();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public List<String> getMixins(Set<String> loadedMods) {
List<String> mixins = new ArrayList<>();
mixins.add("MixinThaumcraftWorldGenerator");
mixins.add("MixinWorldGenMound");
mixins.add("MixinEventHandlerEntity");
return mixins;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package xyz.uniblood.thaumicmixins.mixins.late;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.damagesource.DamageSourceThaumcraft;
import thaumcraft.common.config.ConfigItems;
import thaumcraft.common.entities.monster.EntityBrainyZombie;
import thaumcraft.common.entities.monster.boss.EntityThaumcraftBoss;
import thaumcraft.common.items.ItemCrystalEssence;
import thaumcraft.common.lib.events.EventHandlerEntity;
import thaumcraft.common.lib.research.ScanManager;
import thaumcraft.common.lib.utils.EntityUtils;

import static xyz.uniblood.thaumicmixins.config.ThaumicMixinsConfig.championLootBagEnabled;
import static xyz.uniblood.thaumicmixins.config.ThaumicMixinsConfig.championLootBagRarityMax;

@Mixin(value = EventHandlerEntity.class, remap = false)
public abstract class MixinEventHandlerEntity {

@Overwrite
@SubscribeEvent
public void livingDrops(LivingDropsEvent event) {
boolean fakeplayer = event.source.getEntity() != null && event.source.getEntity() instanceof FakePlayer;
if(!event.entity.worldObj.isRemote && event.recentlyHit && !fakeplayer && event.entity instanceof EntityMob && !(event.entity instanceof EntityThaumcraftBoss) && ((EntityMob)event.entity).getEntityAttribute(EntityUtils.CHAMPION_MOD).getAttributeValue() >= 0.0D) {
int i = 5 + event.entity.worldObj.rand.nextInt(3);

while(i > 0) {
int j = EntityXPOrb.getXPSplit(i);
i -= j;
event.entity.worldObj.spawnEntityInWorld(new EntityXPOrb(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, j));
}

if (championLootBagEnabled) {
int lb = Math.min(championLootBagRarityMax, MathHelper.floor_float((float)(event.entity.worldObj.rand.nextInt(9) + event.lootingLevel) / 5.0F));
event.drops.add(new EntityItem(event.entity.worldObj, event.entityLiving.posX, event.entityLiving.posY + (double)event.entityLiving.getEyeHeight(), event.entityLiving.posZ, new ItemStack(ConfigItems.itemLootbag, 1, lb)));
}

}

if(event.entityLiving instanceof EntityZombie && !(event.entityLiving instanceof EntityBrainyZombie) && event.recentlyHit && event.entity.worldObj.rand.nextInt(10) - event.lootingLevel < 1) {
event.drops.add(new EntityItem(event.entity.worldObj, event.entityLiving.posX, event.entityLiving.posY + (double)event.entityLiving.getEyeHeight(), event.entityLiving.posZ, new ItemStack(ConfigItems.itemZombieBrain)));
}

if(event.entityLiving instanceof EntityVillager && event.entity.worldObj.rand.nextInt(10) - event.lootingLevel < 1) {
event.drops.add(new EntityItem(event.entity.worldObj, event.entityLiving.posX, event.entityLiving.posY + (double)event.entityLiving.getEyeHeight(), event.entityLiving.posZ, new ItemStack(ConfigItems.itemResource, 1, 18)));
}

if(event.source == DamageSourceThaumcraft.dissolve) {
AspectList aspects = ScanManager.generateEntityAspects(event.entityLiving);
if(aspects != null && aspects.size() > 0) {
for(Aspect aspect : aspects.getAspects()) {
if(!event.entity.worldObj.rand.nextBoolean()) {
int size = 1 + event.entity.worldObj.rand.nextInt(aspects.getAmount(aspect));
size = Math.max(1, size / 2);
ItemStack stack = new ItemStack(ConfigItems.itemCrystalEssence, size, 0);
((ItemCrystalEssence)stack.getItem()).setAspects(stack, (new AspectList()).add(aspect, 1));
event.drops.add(new EntityItem(event.entity.worldObj, event.entityLiving.posX, event.entityLiving.posY + (double)event.entityLiving.getEyeHeight(), event.entityLiving.posZ, stack));
}
}
}
}

}
}

0 comments on commit a7f2cc5

Please sign in to comment.