Skip to content

Commit

Permalink
release v1.3
Browse files Browse the repository at this point in the history
New Features:
-the button to go into the baubles gui is now accessible via the creative inventory!
-improve algorithm used when determining which elytra to select (armor or bauble of both are equipped)

Baubles Mod Bug Fixes:
-baubles item drops are now added to the player.capturedDrops list when a player dies (can now be manipulated by mods using PlayerDropsEvent)
-baubles now drop the same way as all items when a player dies (same math & logic vanilla uses for normal items)
-all baubles are now properly effected by curse of binding
-all baubles are now properly effected by curse of vanishing

Baubles Mod Compat Fixes:
-cofhcore soulbound now works on items in the baubles slots
-tombstone soulbound now works on items in the baubles slots
  • Loading branch information
jbredwards committed Feb 6, 2023
1 parent 9e97b0c commit 90eea60
Show file tree
Hide file tree
Showing 7 changed files with 276 additions and 78 deletions.
21 changes: 0 additions & 21 deletions LICENSE.md

This file was deleted.

12 changes: 9 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'maven-publish'

version = 'v1.2b-mc1.12.2'
version = 'v1.3-mc1.12.2'
group = 'git.jbredwards.baubleye'
archivesBaseName = 'Baubley-Elytra'
sourceCompatibility = targetCompatibility = '1.8'
Expand All @@ -24,13 +24,19 @@ minecraft {
}

dependencies {
//baubles
deobfCompile "com.github.jbredwards:Baubles:${baubles_version}"

//cofhcore soulbound baubles fix
deobfProvided "cofh:CoFHCore:1.12.2-${cofh_core_version}:universal"
deobfProvided "mezz.jei:jei_1.12.2:${jei_version}"
}

repositories {
//baubles
maven { url 'https://jitpack.io' }

//cofhcore soulbound baubles fix
maven { url 'https://maven.covers1624.net' }
maven { url 'https://dvs1.progwml6.com/files/maven' }
}

processResources {
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
baubles_version=f16bdec7d2
cofh_core_version=4.6.0.+
jei_version=4.15.0.268
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
190 changes: 137 additions & 53 deletions src/main/java/git/jbredwards/baubleye/BaubleyElytra.java

Large diffs are not rendered by default.

125 changes: 125 additions & 0 deletions src/main/java/git/jbredwards/baubleye/EventBaubleFixer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
package git.jbredwards.baubleye;

import baubles.api.BaublesApi;
import baubles.api.cap.IBaublesItemHandler;
import baubles.client.gui.GuiBaublesButton;
import cofh.core.enchantment.EnchantmentSoulbound;
import cofh.core.util.helpers.ItemHelper;
import cofh.core.util.helpers.MathHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainerCreative;
import net.minecraft.client.resources.I18n;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import javax.annotation.Nonnull;

/**
* Fixes the following baubles bugs:
* -baubles item drops are now added to the player.capturedDrops list when a player dies (can now be manipulated by mods using PlayerDropsEvent)
* -baubles now drop the same way as all items when a player dies (same math & logic vanilla uses for normal items)
* -baubles with curse of vanishing now properly disappear when a player dies
* -cofhcore soulbound now works on items in baubles slots
* -tombstone soulbound now works on items in baubles slots
* -baubles gui button now renders for the creative inventory
*
* @author jbred
*
*/
@Mod.EventBusSubscriber(modid = "baubleye")
public final class EventBaubleFixer
{
@GameRegistry.ObjectHolder("cofhcore:soulbound") public static Enchantment COFH_SOULBOUND = null;
@GameRegistry.ObjectHolder("tombstone:soulbound") public static Enchantment TOMBSTONE_SOULBOUND = null;

//properly handle the bauble items dropped when a player dies
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void handleBaublesDeathDrops(@Nonnull PlayerDropsEvent event) {
final EntityPlayer player = event.getEntityPlayer();
if(player.world.getGameRules().getBoolean("keepInventory")) return;

player.captureDrops = true;
final IBaublesItemHandler baublesInventory = BaublesApi.getBaublesHandler(player);
for(int slot = 0; slot < baublesInventory.getSlots(); slot++) {
final ItemStack bauble = baublesInventory.getStackInSlot(slot);
final boolean hasVanishingCurse = EnchantmentHelper.hasVanishingCurse(bauble);
final boolean hasAnySoulbound = EnchantmentHelper.getEnchantmentLevel(COFH_SOULBOUND, bauble) > 0
|| EnchantmentHelper.getEnchantmentLevel(TOMBSTONE_SOULBOUND, bauble) > 0;

if(!hasVanishingCurse && (player instanceof FakePlayer || !hasAnySoulbound))
player.dropItem(bauble, true, false);

if(hasVanishingCurse || player instanceof FakePlayer || !hasAnySoulbound)
baublesInventory.setStackInSlot(slot, ItemStack.EMPTY);
}

player.captureDrops = false;
}

//special code for cofh soulbound to decrease the enchantment level each time it gets used
@SubscribeEvent(priority = EventPriority.HIGH)
public static void keepBaubleSoulboundOnDeath(@Nonnull PlayerEvent.Clone event) {
if(event.isWasDeath() && COFH_SOULBOUND != null) {
final EntityPlayer newPlayer = event.getEntityPlayer();
if(newPlayer instanceof FakePlayer || newPlayer.world.getGameRules().getBoolean("keepInventory")) return;

final IBaublesItemHandler oldBaubleInventory = BaublesApi.getBaublesHandler(event.getOriginal());
for(int slot = 0; slot < oldBaubleInventory.getSlots(); slot++) {
final ItemStack bauble = oldBaubleInventory.getStackInSlot(slot);
final int level = EnchantmentHelper.getEnchantmentLevel(COFH_SOULBOUND, bauble);

if(level > 0) {
CoFHCoreHelper.handleSoulboundEnchantment(bauble, level);
oldBaubleInventory.setStackInSlot(slot, bauble);
}
}
}
}

//add the baubles button to the creative player inventory
@SideOnly(Side.CLIENT)
@SubscribeEvent(priority = EventPriority.NORMAL)
static void addCreativeBaublesButton(@Nonnull GuiScreenEvent.InitGuiEvent.Post event) {
if(BaubleyElytra.ConfigHandler.creativeAccessibility && event.getGui() instanceof GuiContainerCreative) {
final GuiContainerCreative gui = (GuiContainerCreative)event.getGui();
event.getButtonList().add(new GuiBaublesButton(55, gui, 95, 6, 10, 10, I18n.format("button.baubles")) {
@Override
public void drawButton(@Nonnull Minecraft mc, int mouseX, int mouseY, float partialTicks) {
visible = gui.getSelectedTabIndex() == CreativeTabs.INVENTORY.getIndex();
super.drawButton(mc, mouseX, mouseY, partialTicks);
}
});
}
}

//separate from class to prevent issues while CoFHCore isn't installed
static final class CoFHCoreHelper
{
static void handleSoulboundEnchantment(@Nonnull ItemStack stack, int level) {
if(EnchantmentSoulbound.permanent) {
if(level > 1) {
ItemHelper.removeEnchantment(stack, COFH_SOULBOUND);
ItemHelper.addEnchantment(stack, COFH_SOULBOUND, 1);
}
}

else if(MathHelper.RANDOM.nextInt(level + 1) == 0) {
ItemHelper.removeEnchantment(stack, COFH_SOULBOUND);
if(level > 1) ItemHelper.addEnchantment(stack, COFH_SOULBOUND, level - 1);
}
}
}
}
2 changes: 2 additions & 0 deletions src/main/resources/assets/baubleye/lang/en_us.lang
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
config.baubleye.creativeAccessibility=Creative Baubles Accessibility
config.baubleye.creativeAccessibility.tooltip=True if the Baubles inventory button should be added to the creative inventory.
config.baubleye.slot=Elytra Bauble Slot
config.baubleye.slot.tooltip=Possible values: AMULET, RING, BELT, TRINKET, HEAD, BODY, CHARM.

0 comments on commit 90eea60

Please sign in to comment.