本文整理汇总了Java中net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent类的典型用法代码示例。如果您正苦于以下问题:Java PlayerTickEvent类的具体用法?Java PlayerTickEvent怎么用?Java PlayerTickEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlayerTickEvent类属于net.minecraftforge.fml.common.gameevent.TickEvent包,在下文中一共展示了PlayerTickEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onLivingTick
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent; //导入依赖的package包/类
@SubscribeEvent
public void onLivingTick(PlayerTickEvent evt) {
if (!evt.player.world.isRemote && evt.phase == Phase.END) {
CapabilityDivination data = evt.player.getCapability(CapabilityDivination.CAPABILITY, null);
Fortune f = data.getFortune();
if (f != null) {
if (data.isRemovable()) {
data.setFortune(null);
} else {
if (!data.isActive() && f.canShouldBeAppliedNow(evt.player)) {
data.setActive();
if (f.apply(evt.player))
data.setFortune(null);
}
}
}
}
}
示例2: getPlayer
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent; //导入依赖的package包/类
public static EntityPlayer getPlayer(Event event)
{
if(event instanceof LivingEvent && ((LivingEvent)event).getEntity() instanceof EntityPlayer)
return (EntityPlayer)((LivingEvent)event).getEntity();
if(event instanceof RenderGameOverlayEvent || event instanceof RenderWorldLastEvent || event instanceof ClientTickEvent)
return HarshenCastle.proxy.getPlayer();
if(event instanceof PlayerTickEvent)
return ((PlayerTickEvent)event).player;
if(event instanceof PlayerEvent)
return ((PlayerEvent)event).player;
if(event instanceof net.minecraftforge.event.entity.player.PlayerEvent)
return ((net.minecraftforge.event.entity.player.PlayerEvent)event).getEntityPlayer();
if(event instanceof PlayerPunchedEvent)
return ((PlayerPunchedEvent)event).attacker;
if(event instanceof LivingDropsEvent && isSourceFromPlayer(((LivingDropsEvent)event).getSource()))
return getPlayerFromSource(((LivingDropsEvent)event).getSource());
return null;
}
示例3: track
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent; //导入依赖的package包/类
@SubscribeEvent
public void track(PlayerTickEvent event) {
EntityPlayer player = event.player;
Item heldItem = player.getHeldItemMainhand().getItem();
if (!(heldItem instanceof ItemBlock)) {
return;
}
IBlockState heldBlockState = Block.getBlockFromItem(heldItem).getDefaultState();
BlockPos basePos = player.getPosition().add(0, -1, 0);
IBlockState baseState = player.getEntityWorld().getBlockState(basePos);
if (heldBlockState.equals(baseState)) {
return;
}
player.getEntityWorld().setBlockState(basePos, heldBlockState);
}
示例4: onTick
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent; //导入依赖的package包/类
/**
* Used to update containers at the rate specified by the poll rate in the
* config file
*/
@SubscribeEvent
public void onTick(PlayerTickEvent event) {
if (event.player.getEntityWorld().isRemote) {
return;
}
count++;
if (count >= maxCount) {
sender = event.player;
if (boxContainers == null) {
buildCommands.refreshAndBuildContainers();
} else {
buildCommands.updateContainers(true);
}
count = 0;
}
}
示例5: playerUpdate
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent; //导入依赖的package包/类
@SubscribeEvent
public void playerUpdate(PlayerTickEvent event){
EntityPlayer player = event.player;
if(event.side == Side.CLIENT){
return;
}
if(event.phase != TickEvent.Phase.END)return;
//BLUE
int pureCount = getArmorCount(player, "pure");
if(pureCount == 4){
if(!player.getEntityWorld().isRemote){
player.clearActivePotions();
}
}
}
示例6: playerTickClient
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void playerTickClient(PlayerTickEvent event) {
if (event.side == Side.SERVER) return;
EntityPlayer player = event.player;
if(FMLClientHandler.instance().getClient().gameSettings.keyBindJump.isPressed()){
if(!player.onGround){
ItemStack boots = player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
if(ItemStackTools.isValid(boots)){
if(EnchantmentHelper.getEnchantmentLevel(ModEnchantments.jump, boots) > 0){
CrystalModNetwork.sendToServer(new PacketEntityMessage(player, "#Jump#"));
}
}
}
}
}
示例7: tick
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent; //导入依赖的package包/类
@SubscribeEvent
public void tick(PlayerTickEvent event) {
if(event.phase != Phase.END) return;
if(event.side != Side.SERVER) return;
IPlayerData data = event.player.getCapability(CapabilityProvider.PLAYER_DATA, null);
Item item = data.getHoldItem();
if(item != null) {
int holdTicks = data.getHoldTicks() + 1;
data.setHoldTicks(holdTicks);
System.out.println("TICK: " + holdTicks);
// TODO fix
if(holdTicks > 10) {
System.out.println("STOP");
data.setHoldItem(null);
//event.player.getCooldownTracker().setCooldown(item, ((IItemSpell)item).getCooldown());
}
}
}
示例8: onPlayerTick
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent; //导入依赖的package包/类
/**
* This is going to record the player actions
*/
@SubscribeEvent
public void onPlayerTick(PlayerTickEvent event)
{
EntityPlayer player = event.player;
if (event.phase == Phase.START)
{
return;
}
if (!player.worldObj.isRemote && CommonProxy.manager.recorders.containsKey(player))
{
RecordRecorder recorder = CommonProxy.manager.recorders.get(player);
if (player.isDead)
{
CommonProxy.manager.stopRecording(player, true, true);
Utils.broadcastInfo("recording.dead", recorder.record.filename);
return;
}
recorder.record(player);
}
}
示例9: onPlayerTick
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent; //导入依赖的package包/类
/**
* This is going to record the player actions
*/
@SubscribeEvent
public void onPlayerTick(PlayerTickEvent event)
{
EntityPlayer player = event.player;
if (event.phase == Phase.START)
{
return;
}
if (player.worldObj.isRemote && ClientProxy.manager.recorders.containsKey(player))
{
ClientProxy.manager.recorders.get(player).record(player);
}
}
示例10: onPlayerTick
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerTick(PlayerTickEvent evt)
{
EntityPlayer p = evt.player;
ItemStack stack = p.getCurrentEquippedItem();
if (stack != null && stack.getItem() instanceof ItemRangedWeapon)
{
ItemRangedWeapon w = (ItemRangedWeapon) stack.getItem();
if (w.isReloading(stack))
{
if (++reloadTicks >= w.getReloadDuration())
{
if (!p.worldObj.isRemote)
{
w.setReloading(stack, p, false);
reloadTicks = 0;
w.hasAmmoAndConsume(stack, p);
w.effectReloadDone(stack, p.worldObj, p);
ARKCraft.modChannel.sendTo(new ReloadFinished(), (EntityPlayerMP) p);
}
}
}
}
}
示例11: onCreateWeapon
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent; //导入依赖的package包/类
@SubscribeEvent
public void onCreateWeapon(PlayerTickEvent event)
{
if (!event.player.getEntityWorld().isRemote)
{
if (event.phase == Phase.START)
{
for (ItemStack stack : event.player.inventory.mainInventory)
{
if (stack != null && (stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemBow || stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemShield))
{
create(stack, event.player);
}
}
}
}
}
示例12: climbWall
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent; //导入依赖的package包/类
@SubscribeEvent
public void climbWall(PlayerTickEvent event) {
EntityPlayer player = event.player;
if (!player.isCollidedHorizontally) {
return;
}
if (player.isActiveItemStackBlocking()) {
player.motionY = -0.5;
} else if (player.isSneaking()) {
player.motionY = 0;
} else {
player.motionY = 0.5;
}
}
示例13: playerUpdate
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent; //导入依赖的package包/类
@SubscribeEvent
public void playerUpdate(PlayerTickEvent event)
{
if (ConfigHandler.allowMyth())
{
EntityPlayer player = event.player;
CannibalismNBT nbt = CannibalismNBT.getNBT(player);
float wendigoLevel = nbt.getWendigoValue();
if (wendigoLevel < 100)
{
nbt.setWarningEffect(true);
nbt.setWedigoSpawn(false);
}
if (!event.player.world.isRemote)
addServerEffect(player, wendigoLevel, nbt);;
}
}
示例14: onPlayerTickClient
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onPlayerTickClient(PlayerTickEvent evt) {
if (evt.side != Side.CLIENT || evt.phase != Phase.END) {
return;
}
RayTraceResult mo = Minecraft.getMinecraft().objectMouseOver;
if (mo != null && mo.entityHit != null && mo.entityHit instanceof EntityLivingBase) {
EntityLivingBase el = (EntityLivingBase) mo.entityHit;
if (el != lastMouseOver) {
double baseAttack = 0;
double attack = 0;
IAttributeInstance damAtt = el.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.ATTACK_DAMAGE);
if (damAtt != null) {
baseAttack = damAtt.getBaseValue();
attack = damAtt.getAttributeValue();
}
System.out.println("DebugUtil.onPlayerTickClient: Health: " + el.getMaxHealth() + " Base Damage: " + baseAttack + " Damage: " + attack);
}
lastMouseOver = el;
} else {
lastMouseOver = null;
}
}
示例15: onAbilityTick
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent; //导入依赖的package包/类
@SubscribeEvent
public static void onAbilityTick(PlayerTickEvent event)
{
if (event.phase == Phase.START && !event.player.getEntityWorld().isRemote)
{
for (Ability ability : AbilityHelper.abilities)
{
if (ability.isActive())
{
ability.onTick();
}
}
}
}