Skip to content

Commit

Permalink
✨ Optmize and Update Some Recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
H2Sxxa committed Oct 14, 2023
1 parent e39a510 commit 4b1e902
Show file tree
Hide file tree
Showing 13 changed files with 179 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import io.github.teamgensouspark.grimoireofpatchouli.creativetabs.GoPTabs;
import io.github.teamgensouspark.grimoireofpatchouli.libs.vanilia.ModItems;
import io.github.teamgensouspark.grimoireofpatchouli.utils.ModCompat;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.Item;
Expand All @@ -30,14 +31,16 @@ public ItemBase(String name) {
ModItems.ITEMS.add(this);
}

public ItemBase(String name, boolean isGoA) {
public ItemBase(String name, ModCompat compat) {
setTranslationKey(name);
setRegistryName(name);
setCreativeTab(GoPTabs.GOPTAB);

this.name = name;
this.tooltipKey = String.format("item.%s.tooltip", name);
ModItems.GOA_ITEMS.add(this);
if (compat == ModCompat.GOA) {
ModItems.GOA_ITEMS.add(this);
}
}

@SideOnly(Side.CLIENT)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.teamgensouspark.grimoireofpatchouli.item;

import arekkuusu.grimoireofalice.api.recipes.MoonPhase;
import io.github.teamgensouspark.grimoireofpatchouli.utils.ModCompat;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
Expand All @@ -12,7 +13,9 @@
public class ItemMoonPhaser extends ItemBase {

public ItemMoonPhaser(String name) {
super(name, true);
super(name, ModCompat.GOA);

setMaxStackSize(1);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import io.github.teamgensouspark.grimoireofpatchouli.creativetabs.GoPTabs;
import io.github.teamgensouspark.grimoireofpatchouli.libs.vanilia.ModItems;
import io.github.teamgensouspark.grimoireofpatchouli.utils.ModCompat;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
Expand All @@ -31,6 +32,19 @@ public ItemSwordBase(String name, ToolMaterial material) {
ModItems.ITEMS.add(this);
}

public ItemSwordBase(String name, ToolMaterial material, ModCompat compat) {
super(material);
setTranslationKey(name);
setRegistryName(name);
setCreativeTab(GoPTabs.GOPTAB);

this.name = name;
this.tooltipKey = String.format("item.%s.tooltip", name);
if (compat == ModCompat.GOA) {
ModItems.GOA_ITEMS.add(this);
}
}

@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import javax.annotation.Nullable;

import io.github.teamgensouspark.grimoireofpatchouli.intf.IHasTouhouCharacter;
import io.github.teamgensouspark.grimoireofpatchouli.utils.IHasTouhouCharacter;
import net.katsstuff.teamnightclipse.danmakucore.entity.living.TouhouCharacter;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

import javax.annotation.Nullable;

import io.github.teamgensouspark.grimoireofpatchouli.intf.IHasTouhouCharacter;
import io.github.teamgensouspark.grimoireofpatchouli.libs.vanilia.ModItems;
import io.github.teamgensouspark.grimoireofpatchouli.utils.IHasTouhouCharacter;
import io.github.teamgensouspark.grimoireofpatchouli.utils.ModCompat;
import net.katsstuff.teamnightclipse.danmakucore.entity.living.TouhouCharacter;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
Expand All @@ -21,6 +22,11 @@ public TouhouSword(String name, TouhouCharacter character) {
this.character = character;
}

public TouhouSword(String name, TouhouCharacter character, ModCompat compat) {
super(name, ModItems.TOUHOU_TOOLS,compat);
this.character = character;
}

@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.github.teamgensouspark.grimoireofpatchouli.item.touhou;

import org.lwjgl.input.Keyboard;

import io.github.teamgensouspark.grimoireofpatchouli.item.TouhouSword;
import io.github.teamgensouspark.kekkai.color.AtomColors;
import io.github.teamgensouspark.kekkai.danmaku.DanmakuBuilder;
Expand All @@ -8,11 +10,15 @@
import net.katsstuff.teamnightclipse.danmakucore.lib.data.LibShotData;
import net.katsstuff.teamnightclipse.danmakucore.lib.data.LibSubEntities;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;

Expand All @@ -22,6 +28,11 @@ public BlackSakura(String name) {
super(name, TouhouCharacter.YOUMU_KONPAKU);
}

@Override
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
}

@Override
public float getAttackDamage() {
return 9.9f;
Expand All @@ -41,12 +52,45 @@ public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity en

@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
KekkaiDanmakuCreationHelper.createWideShot(DanmakuBuilder.getBuilderWithEntity(playerIn)
.setShot(LibShotData.SHOT_FIRE.setMainColor(AtomColors.ATOM_COLOR_WHITE)
.setSubEntity(LibSubEntities.FIRE).setDamage(4))
.build(), 5, 40f, 10f, 1.3d);
playerIn.getCooldownTracker().setCooldown(this, 200);
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
KekkaiDanmakuCreationHelper.createWideShot(DanmakuBuilder.getBuilderWithEntity(playerIn)
.setShot(LibShotData.SHOT_FIRE.setMainColor(AtomColors.ATOM_COLOR_WHITE)
.setSubEntity(LibSubEntities.FIRE).setDamage(4))
.setMovementData(1.4)
.build(), 5, 40f, 10f, 1.3d);
playerIn.getCooldownTracker().setCooldown(this, 180);
} else {
ItemStack stack = playerIn.getHeldItem(handIn);
playerIn.setActiveHand(handIn);
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
return super.onItemRightClick(worldIn, playerIn, handIn);
}

@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entityLiving, int timeLeft) {
if (entityLiving instanceof EntityPlayer && ((EntityPlayer) entityLiving).onGround) {
EntityPlayer player = (EntityPlayer) entityLiving;
int timeUsed = getMaxItemUseDuration(stack) - timeLeft;
if (timeUsed > 30) {
timeUsed = 30;
}
double speed = timeUsed * 0.3;
player.motionX = -Math.sin(Math.toRadians(player.rotationYaw)) * speed;
player.motionZ = Math.cos(Math.toRadians(player.rotationYaw)) * speed;
if (!player.capabilities.isCreativeMode) {
player.addExhaustion(1.5F);
}
}
}

@Override
public EnumAction getItemUseAction(ItemStack stack) {
return EnumAction.BOW;
}

@Override
public int getMaxItemUseDuration(ItemStack stack) {
return 7000;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
import io.github.teamgensouspark.grimoireofpatchouli.spellcard.entitiy.PearlDarkCast;
import io.github.teamgensouspark.grimoireofpatchouli.spellcard.entitiy.WaveAndParticle;
import io.github.teamgensouspark.grimoireofpatchouli.spellcard.entitiy.WonderGodWind;
import io.github.teamgensouspark.grimoireofpatchouli.utils.ModCompat;
import net.katsstuff.teamnightclipse.danmakucore.entity.living.TouhouCharacter;
import net.katsstuff.teamnightclipse.danmakucore.entity.spellcard.Spellcard;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

Expand Down Expand Up @@ -56,8 +56,6 @@ public static void initSpellCard() {
@SubscribeEvent
public static void onSpellCardRegister(RegistryEvent.Register<Spellcard> event) {
event.getRegistry().registerAll(SPELL_CARDS.toArray(new Spellcard[0]));
if (Loader.isModLoaded("grimoireofalice")) {
event.getRegistry().registerAll(GOA_SPELL_CARDS.toArray(new Spellcard[0]));
}
ModCompat.GOA.loadedThen(() -> event.getRegistry().registerAll(GOA_SPELL_CARDS.toArray(new Spellcard[0])));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import io.github.teamgensouspark.grimoireofpatchouli.Patchouli;
import io.github.teamgensouspark.grimoireofpatchouli.item.*;
import io.github.teamgensouspark.grimoireofpatchouli.item.touhou.*;
import io.github.teamgensouspark.grimoireofpatchouli.utils.ModCompat;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSword;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

Expand All @@ -33,16 +33,12 @@ public class ModItems {
@SubscribeEvent
public static void onItemModelReg(ModelRegistryEvent event) {
ITEMS.forEach(item -> Patchouli.proxy.regCommonVaniliaIRR(item));
if (Loader.isModLoaded("grimoireofalice")) {
GOA_ITEMS.forEach(item -> Patchouli.proxy.regCommonVaniliaIRR(item));
}
ModCompat.GOA.loadedThen(() -> GOA_ITEMS.forEach(item -> Patchouli.proxy.regCommonVaniliaIRR(item)));
}

@SubscribeEvent
public static void onItemReg(RegistryEvent.Register<Item> event) {
event.getRegistry().registerAll(ITEMS.toArray(new Item[0]));
if (Loader.isModLoaded("grimoireofalice")) {
event.getRegistry().registerAll(GOA_ITEMS.toArray(new Item[0]));
}
ModCompat.GOA.loadedThen(() -> event.getRegistry().registerAll(GOA_ITEMS.toArray(new Item[0])));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package io.github.teamgensouspark.grimoireofpatchouli.recepies;

import arekkuusu.grimoireofalice.common.item.ModItems;
import io.github.teamgensouspark.grimoireofpatchouli.PatchouliModInfo;
import io.github.teamgensouspark.grimoireofpatchouli.utils.ModCompat;
import net.minecraft.init.Enchantments;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.AnvilUpdateEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@EventBusSubscriber(modid = PatchouliModInfo.MODID)
public class AnvilReceipe {
@SubscribeEvent
public static void onAnvilUpdate(AnvilUpdateEvent event) {
if (ModCompat.GOA.isLoaded()) {
if (event.getLeft().getItem() == ModItems.HAKUROUKEN && event.getRight().getItem() == ModItems.ROUKANKEN) {
ItemStack output = new ItemStack(
io.github.teamgensouspark.grimoireofpatchouli.libs.vanilia.ModItems.BLACK_SAKURA);
output.addEnchantment(Enchantments.SMITE, 10);
event.setOutput(output);
event.setCost(30);

}
} else {
if (event.getLeft().getItem() == Items.DIAMOND_SWORD && event.getRight().getItem() == Items.NETHER_STAR) {
ItemStack output = new ItemStack(
io.github.teamgensouspark.grimoireofpatchouli.libs.vanilia.ModItems.BLACK_SAKURA);
output.addEnchantment(Enchantments.SMITE, 10);
event.setOutput(output);
event.setCost(30);

}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.teamgensouspark.grimoireofpatchouli.intf;
package io.github.teamgensouspark.grimoireofpatchouli.utils;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.github.teamgensouspark.grimoireofpatchouli.utils;

import net.minecraftforge.fml.common.Loader;

public class ModCompat {
private String modid;
public static final ModCompat GOA = new ModCompat("grimoireofalice");

public ModCompat(String modid) {
this.modid = modid;
}

public String getModid() {
return modid;
}

public boolean isLoaded() {
return Loader.isModLoaded(modid);
}

public void loadedThen(Runnable F) {
if (isLoaded()) {
F.run();
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "danmakucore:item/danmaku/spellcard/spellcard_base",
"textures": {
"1": "grimoireofpatchouli:items/spellcard/dream_seal"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"type": "minecraft:crafting_shapeless",
"group": "grimoireofpatchouli:item",
"result": {
"item": "grimoireofpatchouli:moon_phaser",
"count": 1
},
"ingredients": [
{
"item": "minecraft:dye",
"data": 4
},
{
"item": "minecraft:redstone"
},
{
"item": "minecraft:redstone"
},
{
"item": "minecraft:clock"
}
]
}

0 comments on commit 4b1e902

Please sign in to comment.