Updated for 1.7.2
This commit is contained in:
parent
cc178e1a3b
commit
29228e18fe
105 changed files with 1939 additions and 2690 deletions
|
|
@ -1,56 +1,36 @@
|
|||
package mysticworld.util;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import mysticworld.blocks.BlockHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.IScheduledTickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
|
||||
public class TickHandler implements IScheduledTickHandler {
|
||||
public class TickHandler {
|
||||
public static final Enchantment[] enchantmentsPick = { Enchantment.efficiency, Enchantment.fortune, Enchantment.silkTouch, Enchantment.unbreaking };
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "mystic world tick";
|
||||
@SubscribeEvent
|
||||
public void tickStart(TickEvent.PlayerTickEvent event) {
|
||||
if(event.phase== TickEvent.Phase.START && event.side.isServer() && event.player.worldObj.getWorldTime()%20==0)
|
||||
pillarTick(event.player, event.player.worldObj, new Random());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextTickSpacing() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TickType> ticks() {
|
||||
return EnumSet.of(TickType.PLAYER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData) {
|
||||
EntityPlayer player = (EntityPlayer) tickData[0];
|
||||
pillarTick(player, player.worldObj, player.inventory, new Random());
|
||||
}
|
||||
|
||||
private static void pillarTick(EntityPlayer player, World world, InventoryPlayer inventory, Random rand) {
|
||||
ItemStack itemStack = inventory.getCurrentItem();
|
||||
private static void pillarTick(EntityPlayer player, World world, Random rand) {
|
||||
ItemStack itemStack = player.inventory.getCurrentItem();
|
||||
int blockX = (int) player.posX - 1;
|
||||
int blockY = (int) (player.posY - 0.15D);
|
||||
int blockZ = (int) player.posZ - 1;
|
||||
int blockId = world.getBlockId(blockX, blockY, blockZ);
|
||||
Block blockId = world.getBlock(blockX, blockY, blockZ);
|
||||
int blockMeta = world.getBlockMetadata(blockX, blockY, blockZ);
|
||||
if (blockId == BlockHandler.pillarPlatform.blockID) {
|
||||
if (blockId == BlockHandler.pillarPlatform) {
|
||||
switch (blockMeta) {
|
||||
//food
|
||||
case 0:
|
||||
|
|
@ -85,8 +65,8 @@ public class TickHandler implements IScheduledTickHandler {
|
|||
//enchanter
|
||||
case 7:
|
||||
if (itemStack != null
|
||||
&& (itemStack.itemID == Item.pickaxeWood.itemID || itemStack.itemID == Item.pickaxeStone.itemID || itemStack.itemID == Item.pickaxeIron.itemID
|
||||
|| itemStack.itemID == Item.pickaxeGold.itemID || itemStack.itemID == Item.pickaxeDiamond.itemID)) {
|
||||
&& (itemStack.getItem() == Items.wooden_pickaxe || itemStack.getItem() == Items.stone_pickaxe || itemStack.getItem() == Items.iron_pickaxe
|
||||
|| itemStack.getItem() == Items.golden_pickaxe || itemStack.getItem() == Items.diamond_pickaxe)) {
|
||||
if (itemStack.isItemEnchanted() != true && player.experienceLevel >= 10) {
|
||||
player.experienceLevel -= 10;
|
||||
itemStack.addEnchantment(enchantmentsPick[rand.nextInt(3)], rand.nextInt(4) + 1);
|
||||
|
|
|
|||
Loading…
Reference in a new issue