本文整理汇总了Java中net.minecraftforge.fml.common.gameevent.TickEvent.Phase类的典型用法代码示例。如果您正苦于以下问题:Java Phase类的具体用法?Java Phase怎么用?Java Phase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Phase类属于net.minecraftforge.fml.common.gameevent.TickEvent包,在下文中一共展示了Phase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onClientTick
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; //导入依赖的package包/类
@SubscribeEvent
public static void onClientTick(ClientTickEvent event) throws Throwable {
if (event.phase == Phase.START && (!Configs.creativeOnly || Minecraft.getMinecraft().player.isCreative())) {
int timer = (int) getDelayTimer.invoke(Minecraft.getMinecraft());
RayTraceResult hover = Minecraft.getMinecraft().objectMouseOver;
if (hover != null && hover.typeOfHit == Type.BLOCK) {
BlockPos pos = hover.getBlockPos();
if (timer > 0 && !pos.equals(lastTargetPos) && (lastTargetPos == null || !pos.equals(lastTargetPos.offset(lastTargetSide)))) {
setDelayTimer.invoke(Minecraft.getMinecraft(), 0);
} else if (Configs.forceNewLoc && timer == 0 && pos.equals(lastTargetPos) && hover.sideHit == lastTargetSide) {
setDelayTimer.invoke(Minecraft.getMinecraft(), 4);
}
lastTargetPos = pos.toImmutable();
lastTargetSide = hover.sideHit;
}
}
}
示例2: onLivingTick
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; //导入依赖的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);
}
}
}
}
}
示例3: onClientTick
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; //导入依赖的package包/类
/** Tick event called on the Client.<br>
* Used to simulate pressing and releasing of our additional keys.<br>
* This is about as close as we can (easily) get in the call stack to the point when Minecraft does the equivalent code for its own keys.
* @param ev ClientTickEvent for this tick.
*/
@SubscribeEvent
public void onClientTick(TickEvent.ClientTickEvent ev)
{
if (ev != null && ev.phase == Phase.START)
{
for (InternalKey binding : this.additionalKeys)
{
if (binding.isKeyDown())
{
binding.onKeyDown();
}
if (binding.isPressed())
{
binding.onPressed();
}
}
}
}
示例4: onRenderTick
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; //导入依赖的package包/类
/** Called for each screen redraw - approximately three times as often as the other tick events,
* under normal conditions.<br>
* This is where we want to update our yaw/pitch, in order to get smooth panning etc
* (which is how Minecraft itself does it).
* The speed of the render ticks is not guaranteed, and can vary from machine to machine, so
* we try to account for this in the calculations.
* @param ev the RenderTickEvent object for this tick
*/
@SubscribeEvent
public void onRenderTick(TickEvent.RenderTickEvent ev)
{
if (ev.phase == Phase.START)
{
if (this.isOverriding())
{
EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
if (player != null)
{
updateYawAndPitch();
player.rotationPitch = this.mCameraPitch;
player.rotationYaw = this.mYaw;
}
}
}
}
示例5: tickEvent
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void tickEvent(TickEvent.ClientTickEvent event) {
if(event.phase==Phase.START){
EntityPlayer player=Minecraft.getMinecraft().player;
if(player != null && player.getDataManager().get(SPIN_TIME) && !player.getHeldItemMainhand().isEmpty()){
player.getEntityData().setInteger("SpinTime", player.getEntityData().getInteger("SpinTime")-1);
if(player.getEntityData().getInteger("SpinTime")<=0)
player.getEntityData().setInteger("SpinTime", this.getDuration(player.getHeldItemMainhand(), player));
if(Minecraft.getMinecraft().gameSettings.thirdPersonView==0 ){
Minecraft.getMinecraft().gameSettings.thirdPersonView=1;
player.getEntityData().setBoolean("SetFirstpersonAfter", true);
}
}
if(player != null && !player.getDataManager().get(SPIN_TIME) && player.getEntityData().getBoolean("SetFirstpersonAfter")){
Minecraft.getMinecraft().gameSettings.thirdPersonView=0;
player.getEntityData().setBoolean("SetFirstpersonAfter",false);
}
}
}
示例6: renderTick
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; //导入依赖的package包/类
@SubscribeEvent
public void renderTick(TickEvent.RenderTickEvent event) {
tickTime = event.renderTickTime;
Minecraft minecraft = Minecraft.getMinecraft();
if (event.phase == Phase.END)
if (minecraft.player != null && minecraft.player.getHeldItemMainhand() != null)
if (minecraft.player.getHeldItemMainhand().getItem() instanceof ItemUsable) {
Mouse.poll();
minecraft.player.rotationYawHead = minecraft.player.rotationYaw;
moveEntities = true;
keyPressUpdate(Mouse.isButtonDown(minecraft.gameSettings.keyBindAttack.getKeyCode() + 100),
Mouse.isButtonDown(minecraft.gameSettings.keyBindUseItem.getKeyCode() + 100));
moveEntities = false;
}
}
示例7: onServerTick
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; //导入依赖的package包/类
@SubscribeEvent
public void onServerTick(ServerTickEvent event)
{
if (event.phase != Phase.END) { return; } // Only doing it once
if (event.side == Side.CLIENT) { return; }
dayTick += 1; // Ticking up
if (dayTick >= Main.getControlRefreshTick()) // A day has passed. Refreshing faction chunk health now
{
TerritoryHandler.refreshChunkControl();
dayTick = 0; // Reset
}
saveTick += 1;
if (saveTick >= Main.getSaveTick()) // Autosave
{
SaveHandler.saveFactionsToFile();
saveTick = 0; // Reset
}
}
示例8: onServerTick
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; //导入依赖的package包/类
@SubscribeEvent
public void onServerTick(ServerTickEvent event)
{
if (event.phase != Phase.END) { return; } // Only doing it once
if (event.side == Side.CLIENT) { return; }
// Chunk upkeep
if (Main.shouldCheckUpkeep())
{
TerritoryHandler.checkUpkeep();
}
// Chunk control regeneration
TerritoryHandler.checkChunkControl();
// Autosave
Main.checkAutoSave();
Main.checkDisplayTick();
}
示例9: onPlayerTick
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerTick(TickEvent.PlayerTickEvent event){
if(event.phase == Phase.END){
EntityPlayer player = event.player;
ExtendedPlayer playerEx = ExtendedPlayerProvider.getExtendedPlayer(player);
float width = 0.6F;
float height = 1.8F;
float stepSize = 0.5F;
float eyeHeight = player.getDefaultEyeHeight();
boolean doFunc = false;
if(playerEx.isMini()){
width /= 2F;
height /= 3F;
eyeHeight/=3;
stepSize/=2;
doFunc = true;
}
if(doFunc && (player.width !=width || player.height !=height)){
EntityUtil.setSize(player, width, height, stepSize, eyeHeight, false);
}
}
}
示例10: tick
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; //导入依赖的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());
}
}
}
示例11: playerTick
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; //导入依赖的package包/类
@SubscribeEvent
public void playerTick(final TickEvent.PlayerTickEvent event) {
if (event.side == Side.SERVER || event.phase == Phase.END || Minecraft.getMinecraft().isGamePaused())
return;
if (event.player == null || event.player.world == null)
return;
if (event.player != Minecraft.getMinecraft().player)
return;
final int tickRef = EnvironState.getTickCounter();
for (int i = 0; i < this.overlays.size(); i++)
this.overlays.get(i).doTick(tickRef);
}
示例12: tickEvent
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; //导入依赖的package包/类
@SubscribeEvent
public void tickEvent(@Nonnull final TickEvent.PlayerTickEvent event) {
if (event.phase == Phase.END && event.side == Side.SERVER) {
final EntityPlayer player = event.player;
final VillageCollection villageCollection = player.getEntityWorld().getVillageCollection();
boolean inVillage = false;
if (villageCollection != null) {
final List<Village> villages = villageCollection.getVillageList();
if (villages != null && villages.size() > 0) {
final BlockPos pos = player.getPosition();
for (final Village v : villages)
if (v.isBlockPosWithinSqVillageRadius(pos)) {
inVillage = true;
break;
}
}
}
final PacketEnvironment packet = new PacketEnvironment(inVillage);
Network.sendToPlayer((EntityPlayerMP) player, packet);
}
}
示例13: tickEvent
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; //导入依赖的package包/类
/**
* Collect tick performance data for the loaded dimensions and broadcast to
* attached players.
*
* @param event
*/
@SubscribeEvent
public void tickEvent(@Nonnull final TickEvent.ServerTickEvent event) {
if (!ModOptions.reportServerStats || event.phase != Phase.END)
return;
// Spam once a second
if ((++tpsCount % 20) != 0)
return;
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
final TIntDoubleHashMap map = new TIntDoubleHashMap();
for (Integer dim : DimensionManager.getIDs()) {
map.put(dim.intValue(), mean((long[]) server.worldTickTimes.get(dim)) / 1000000D);
}
final double meanTickTime = mean(server.tickTimeArray) / 1000000D;
final int total = (int) (Runtime.getRuntime().totalMemory() / 1024L / 1024L);
final int max = (int) (Runtime.getRuntime().maxMemory() / 1024L / 1024L);
final int free = (int) (Runtime.getRuntime().freeMemory() / 1024L / 1024L);
final PacketServerData packet = new PacketServerData(map, meanTickTime, free, total, max);
Network.sendToAll(packet);
}
示例14: onRenderTick
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; //导入依赖的package包/类
/** Called for each screen redraw - approximately three times as often as the other tick events,
* under normal conditions.<br>
* This is where we want to update our yaw/pitch, in order to get smooth panning etc
* (which is how Minecraft itself does it).
* The speed of the render ticks is not guaranteed, and can vary from machine to machine, so
* we try to account for this in the calculations.
* @param ev the RenderTickEvent object for this tick
*/
@SubscribeEvent
public void onRenderTick(TickEvent.RenderTickEvent ev)
{
if (ev.phase == Phase.START)
{
if (this.isOverriding())
{
EntityPlayerSP player = Minecraft.getMinecraft().player;
if (player != null)
{
updateYawAndPitch();
player.rotationPitch = this.mCameraPitch;
player.rotationYaw = this.mYaw;
}
}
}
}
示例15: onPlayerTick
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; //导入依赖的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);
}
}