-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes some usable effects not working
# Fixes: - nature items should work now - z-moves should have crit chance 0 now - gigant shard works
- Loading branch information
Showing
6 changed files
with
77 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/main/java/pokecube/legends/init/function/UsableItemGigantShard.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package pokecube.legends.init.function; | ||
|
||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.ActionResult; | ||
import net.minecraft.util.ActionResultType; | ||
import net.minecraft.util.ResourceLocation; | ||
import net.minecraftforge.event.AttachCapabilitiesEvent; | ||
import pokecube.core.database.Database; | ||
import pokecube.core.database.PokedexEntry; | ||
import pokecube.core.interfaces.IPokemob; | ||
import pokecube.core.interfaces.pokemob.ai.CombatStates; | ||
import pokecube.core.items.UsableItemEffects.BaseUseable; | ||
import pokecube.legends.Reference; | ||
import pokecube.legends.init.ItemInit; | ||
|
||
public class UsableItemGigantShard | ||
{ | ||
public static class GigantShardUsable extends BaseUseable | ||
{ | ||
/** | ||
* Called when this item is "used". Normally this means via right | ||
* clicking the pokemob with the itemstack. It can also be called via | ||
* onTick or onMoveTick, in which case user will be pokemob.getEntity() | ||
* | ||
* @param user | ||
* @param pokemob | ||
* @param stack | ||
* @return something happened | ||
*/ | ||
@Override | ||
public ActionResult<ItemStack> onUse(final IPokemob pokemob, final ItemStack stack, final LivingEntity user) | ||
{ | ||
System.out.println(user + " " + pokemob.getOwner()); | ||
if (user != pokemob.getOwner()) return new ActionResult<>(ActionResultType.FAIL, stack); | ||
boolean gigant = pokemob.getCombatState(CombatStates.GIGANTAMAX); | ||
// Already able to gigantamax, no effect. | ||
if (gigant) return super.onUse(pokemob, stack, user); | ||
final PokedexEntry entry = pokemob.getPokedexEntry(); | ||
gigant = Database.getEntry(entry.getTrimmedName() + "_gigantamax") != null; | ||
// No gigantamax form for this pokemob, no effect. | ||
if (!gigant) return super.onUse(pokemob, stack, user); | ||
pokemob.setCombatState(CombatStates.GIGANTAMAX, true); | ||
stack.split(1); | ||
return new ActionResult<>(ActionResultType.SUCCESS, stack); | ||
} | ||
} | ||
|
||
public static final ResourceLocation USABLE = new ResourceLocation(Reference.ID, "usables"); | ||
|
||
public static void registerCapabilities(final AttachCapabilitiesEvent<ItemStack> event) | ||
{ | ||
if (event.getCapabilities().containsKey(UsableItemGigantShard.USABLE)) return; | ||
final Item item = event.getObject().getItem(); | ||
if (item == ItemInit.GIGANTIC_SHARD.get()) event.addCapability(UsableItemGigantShard.USABLE, | ||
new GigantShardUsable()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters