Warping Fertilizer changes

This commit is contained in:
John Yorke committed 2020-10-29 12:27:08 -03:00
1 parent 0004b83e9c
commit fbe6e91ef7
4 files changed
+82 -94

No files matched your search

@@ -1,7 +1,5 @@
package taintedmagic.common.handler;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.UUID;
@@ -11,14 +9,11 @@ import baubles.api.BaublesApi;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -28,12 +23,9 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import taintedmagic.common.items.ItemMaterial;
import taintedmagic.common.items.equipment.ItemLumosRing;
import taintedmagic.common.items.tools.ItemHollowDagger;
import taintedmagic.common.items.wand.foci.ItemFocusMageMace;
@@ -43,12 +35,8 @@ import thaumcraft.api.ThaumcraftApiHelper;
import thaumcraft.api.wands.ItemFocusBasic;
import thaumcraft.api.wands.StaffRod;
import thaumcraft.api.wands.WandRod;
import thaumcraft.client.fx.ParticleEngine;
import thaumcraft.client.fx.particles.FXSparkle;
import thaumcraft.common.Thaumcraft;
import thaumcraft.common.blocks.BlockCustomPlant;
import thaumcraft.common.config.Config;
import thaumcraft.common.config.ConfigBlocks;
import thaumcraft.common.items.ItemEssence;
import thaumcraft.common.items.wands.ItemWandCasting;
import thaumcraft.common.lib.network.playerdata.PacketResearchComplete;
@@ -68,9 +56,6 @@ public class TMEventHandler
createLumos(player);
modifyAttackDamage(player);
for (int i = 0; i < saps.size(); i++)
saps.get(i).doWarpSap(player.worldObj, i);
// DELETE THIS UPON RELEASE
if (Keyboard.getEventKey() == Keyboard.KEY_T && Keyboard.isKeyDown(Keyboard.KEY_DELETE))
Minecraft.getMinecraft().refreshResources();
@@ -87,9 +72,7 @@ public class TMEventHandler
ItemStack stack = player.inventory.getStackInSlot(i);
if (!player.worldObj.isRemote && stack != null && stack.stackTagCompound != null
&& stack.stackTagCompound.getBoolean("voidtouched") && stack.isItemDamaged())
{
if (player.ticksExisted % 20 == 0) stack.setItemDamage(stack.getItemDamage() - 1);
}
}
}
@@ -100,7 +83,7 @@ public class TMEventHandler
public void createLumos (EntityPlayer player)
{
int x = (int) Math.floor(player.posX);
int y = (int) Math.floor(player.posY + 1);
int y = (int) Math.floor(player.posY) + 1;
int z = (int) Math.floor(player.posZ);
if (player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemWandCasting)
@@ -109,14 +92,14 @@ public class TMEventHandler
ItemWandCasting wand = (ItemWandCasting) held.getItem();
if (wand.getFocus(held) != null && wand.getFocus(held) == ItemRegistry.ItemFocusLumos && !player.worldObj.isRemote
&& player.worldObj.getBlock(x, y, z) == Blocks.air)
&& player.worldObj.isAirBlock(x, y, z))
player.worldObj.setBlock(x, y, z, BlockRegistry.BlockLumos, 1, 3);
}
IInventory baub = BaublesApi.getBaubles(player);
if ( (baub.getStackInSlot(1) != null && baub.getStackInSlot(1).getItem() instanceof ItemLumosRing)
|| (baub.getStackInSlot(2) != null && baub.getStackInSlot(2).getItem() instanceof ItemLumosRing)
&& player.worldObj.getBlock(x, y, z) == Blocks.air)
&& !player.worldObj.isRemote && player.worldObj.isAirBlock(x, y, z))
player.worldObj.setBlock(x, y, z, BlockRegistry.BlockLumos, 2, 3);
}
@@ -207,77 +190,6 @@ public class TMEventHandler
}
}
/**
* Turn Silverwood Saplings into Warpwood Saplings using Warping Fertilizer
*/
@SubscribeEvent
public void createWarpSap (PlayerInteractEvent event)
{
EntityPlayer player = event.entityPlayer;
if (player != null)
{
if (player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemMaterial
&& player.getHeldItem().getItemDamage() == 12 && event.action == event.action.RIGHT_CLICK_BLOCK
&& event.world.getBlock(event.x, event.y, event.z) instanceof BlockCustomPlant
&& event.world.getBlockMetadata(event.x, event.y, event.z) == 1)
{
if (player.worldObj.isRemote) player.swingItem();
player.inventory.decrStackSize(player.inventory.currentItem, 1);
event.world.playSoundAtEntity(player, "thaumcraft:roots", 2.0F, 1.0F);
saps.add(new WarpSapHandler(event.x, event.y, event.z));
}
}
}
List<WarpSapHandler> saps = new ArrayList<WarpSapHandler>();
private class WarpSapHandler
{
int time = 0;
int sapX, sapY, sapZ;
public WarpSapHandler (int x, int y, int z)
{
sapX = x;
sapY = y;
sapZ = z;
}
public void doWarpSap (World world, int index)
{
if (world.getBlock(sapX, sapY, sapZ) == ConfigBlocks.blockCustomPlant
&& world.getBlockMetadata(sapX, sapY, sapZ) == 1)
{
time++;
if (world.isRemote && world.rand.nextBoolean())
warpSapParticles(world, sapX, sapY, sapZ, world.rand.nextInt(2) + 1);
if (time == 100)
{
warpSapParticles(world, sapX, sapY, sapZ, 25);
world.setBlock(sapX, sapY, sapZ, BlockRegistry.BlockWarpwoodSapling);
time = 0;
saps.remove(index);
}
}
else saps.remove(index);
}
@SideOnly (Side.CLIENT)
public void warpSapParticles (World world, int x, int y, int z, int count)
{
for (int i = 0; i < count; i++)
{
FXSparkle fx = new FXSparkle(world, x + world.rand.nextFloat(), y + world.rand.nextFloat(),
z + world.rand.nextFloat(), 1.75F, 5, 3 + world.rand.nextInt(3));
fx.setGravity(0.1F);
ParticleEngine.instance.addEffect(world, fx);
}
}
}
@SubscribeEvent
public void entityAttacked (LivingAttackEvent event)
{
@@ -0,0 +1,71 @@
package taintedmagic.common.items;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import taintedmagic.common.TaintedMagic;
import taintedmagic.common.registry.BlockRegistry;
import thaumcraft.client.fx.ParticleEngine;
import thaumcraft.client.fx.particles.FXWisp;
import thaumcraft.common.blocks.BlockCustomPlant;
public class ItemWarpFertilizer extends Item
{
public ItemWarpFertilizer ()
{
this.setCreativeTab(TaintedMagic.tabTaintedMagic);
this.setUnlocalizedName("ItemWarpFertilizer");
this.setTextureName("taintedmagic:ItemWarpFertilizer");
FMLCommonHandler.instance().bus().register(this);
}
public EnumRarity getRarity (ItemStack stack)
{
return EnumRarity.uncommon;
}
/**
* Turn Silverwood Saplings into Warpwood Saplings
*/
@Override
public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX,
float hitY, float hitZ)
{
super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ);
if (world.getBlock(x, y, z) instanceof BlockCustomPlant && world.getBlockMetadata(x, y, z) == 1)
{
if (world.isRemote) particles(world, x, y, z, 10 + world.rand.nextInt(11));
world.playSound((double) x, (double) y, (double) z, "thaumcraft:roots", 1.0F, 1.0F, false);
world.setBlock(x, y, z, BlockRegistry.BlockWarpwoodSapling, 0, 1 | 2);
stack.stackSize--;
return true;
}
else return false;
}
@SideOnly (Side.CLIENT)
public void particles (World world, int x, int y, int z, int count)
{
for (int i = 0; i < count; i++)
{
FXWisp fx = new FXWisp(world, x + 0.5D + (Math.random() - Math.random()) * 0.5D,
y + 0.5D + (Math.random() - Math.random()) * 0.5D, z + 0.5D + (Math.random() - Math.random()) * 0.5D,
0.25F + (float) Math.random() * 0.25F, 5);
fx.setGravity(0.01F);
ParticleEngine.instance.addEffect(world, fx);
fx.motionX = (fx.posX - x - 0.5D) * 0.025D;
fx.motionZ = (fx.posZ - z - 0.5D) * 0.025D;
}
}
}
@@ -18,6 +18,7 @@ import taintedmagic.common.items.ItemMaterial;
import taintedmagic.common.items.ItemNightshadeBerries;
import taintedmagic.common.items.ItemSalis;
import taintedmagic.common.items.ItemVoidBlood;
import taintedmagic.common.items.ItemWarpFertilizer;
import taintedmagic.common.items.equipment.ItemLumosRing;
import taintedmagic.common.items.equipment.ItemShadowFortressArmor;
import taintedmagic.common.items.equipment.ItemVoidFortressArmor;
@@ -58,6 +59,7 @@ public class ItemRegistry
public static Item ItemFlyteCharm;
public static Item ItemSalis;
public static Item ItemGateKey;
public static Item ItemWarpFertilizer;
// Wand
public static Item ItemWandRod;
@@ -137,6 +139,9 @@ public class ItemRegistry
ItemGateKey = new ItemGateKey();
GameRegistry.registerItem(ItemGateKey, "ItemGateKey");
ItemWarpFertilizer = new ItemWarpFertilizer();
GameRegistry.registerItem(ItemWarpFertilizer, "ItemWarpFertilizer");
// Armor and Baubles
ItemWarpedGoggles = new ItemWarpedGoggles(LibMaterials.armorMatWarped, 4, 0);
GameRegistry.registerItem(ItemWarpedGoggles, "ItemWarpedGoggles");
@@ -85,12 +85,12 @@ public class ResearchRegistry
r = new TMResearchItem("UNBALANCEDSHARDS", new AspectList().add(Aspect.CRYSTAL, 4).add(Aspect.DARKNESS, 4), 4, -1,
new ItemStack(ItemRegistry.ItemMaterial, 1, 4), 0, 1);
r.setPages(new ResearchPage("1"), cruciblePage("ItemMaterial:3"), cruciblePage("ItemMaterial:4"));
r.setPages(new ResearchPage("1"), cruciblePage("ItemMaterial:4"), cruciblePage("ItemMaterial:3"));
r.setParents("TAINTEDMAGIC").setConcealed().setSecondary().registerResearchItem();
r = new TMResearchItem("WARPTREE", new AspectList().add(Aspect.MAGIC, 4).add(Aspect.DARKNESS, 4).add(Aspect.TREE, 4), 6,
-2, new ItemStack(ItemRegistry.ItemMaterial, 1, 12), 3, 2);
r.setPages(new ResearchPage("1"), arcanePage("ItemMaterial:12"), recipePage("BlockWarpwoodPlanks"));
-2, new ItemStack(ItemRegistry.ItemWarpFertilizer), 3, 2);
r.setPages(new ResearchPage("1"), arcanePage("ItemWarpFertilizer"));
r.setParents("UNBALANCEDSHARDS").setConcealed().registerResearchItem();
r = new TMResearchItem("CRIMSONROBES",