本文整理汇总了Java中net.minecraftforge.fml.common.gameevent.TickEvent.Phase.END属性的典型用法代码示例。如果您正苦于以下问题:Java Phase.END属性的具体用法?Java Phase.END怎么用?Java Phase.END使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.minecraftforge.fml.common.gameevent.TickEvent.Phase
的用法示例。
在下文中一共展示了Phase.END属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onLivingTick
@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: renderTick
@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;
}
}
示例3: onServerTick
@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
}
}
示例4: onServerTick
@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();
}
示例5: tick
@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());
}
}
}
示例6: ClientTickEnd
/**
* This is used to increment the ticks in game value.
* @param event The event object.
*/
@SubscribeEvent
public static void ClientTickEnd(ClientTickEvent event)
{
if (event.phase == Phase.END)
{
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
if (gui == null || !gui.doesGuiPauseGame())
{
// Reset the ticks in game if we are getting close to the maximum value of an integer.
if (Integer.MAX_VALUE - 100 == ClientEventHandler.ticksInGame)
{
ClientEventHandler.ticksInGame = 1;
}
ClientEventHandler.ticksInGame++;
}
}
}
示例7: tickEvent
/**
* 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);
}
示例8: tick
@Override
public void tick(TickEvent event) {
super.tick(event);
if(event instanceof ClientTickEvent) {
while(!clientTickQeue.isEmpty())
clientTickQeue.poll().run();
}
if(event instanceof RenderTickEvent) {
RenderTickEvent revt = (RenderTickEvent) event;
// Pre-Scene Render
if(revt.phase == Phase.START) {
clientRenderer.on_render_world_terrain_pre(revt);
} else
// Post-World >> Pre-HUD Render
if(revt.phase == Phase.END) {
clientRenderer.on_render_world_terrain_post(revt);
}
}
}
示例9: onPlayerTickClient
@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;
}
}
示例10: serverTick
@SubscribeEvent
public void serverTick(WorldTickEvent event) {
if (!event.world.isRemote) {
if (event.phase == Phase.END) {
RedstoneEther.server().tick(event.world);
} else {
RedstoneEtherAddons.server().processSMPMaps(event.world);
}
}
}
示例11: worldTick
@SubscribeEvent
public static void worldTick(WorldTickEvent event){
// I only want to tick on the server
if(event.world.isRemote){return;}
// If I don't have this code everything runs twice per tick
if(event.phase == Phase.END){return;}
if(Math.floorMod(event.world.getTotalWorldTime(), tickSpeed) != 0){return;}
TickTracker tickTracker = getTickTrackerForDimension(event.world.provider.getDimension());
if(!tickTracker.trackedWorldHasPlayers()){
if(tickTracker.worldToTick == nextWorldToTick){
tickTracker.hasTicked = true;
findNextWorldToTick();
}
return;
}
if(!tickTracker.hasTicked && tickTracker.worldToTick == nextWorldToTick && event.world.getTotalWorldTime() > lastTickProcessed){
if(dimensionsToTick.contains(tickTracker.worldToTick)){
if(ConfigHandler.LOGGING)LogManager.getLogger().log(Level.INFO, "We're ticking in this dimension: " + tickTracker.worldToTick);
if(tickTracker.trackedWorldHasPlayers() && tickTracker.playerToTick < event.world.playerEntities.size()){
SpawnHandler.attemptSpawnNearPlayer(event.world.playerEntities.get(tickTracker.playerToTick), event.world);
tickTracker.setNextPlayerToTick(event.world);
}
}
tickTracker.hasTicked = true;
findNextWorldToTick();
lastTickProcessed = event.world.getTotalWorldTime();
return;
}
// if we get to this point, a world has probably unloaded and eaten our tick tracker, so find a new world to tick on
if(DimensionManager.getWorld(nextWorldToTick) == null){
if(ConfigHandler.LOGGING)LogManager.getLogger().log(Level.WARN, "Tracker lost, generating new tracker.");
findNextWorldToTick();
}
}
示例12: onClientTick
@Override
public void onClientTick(TickEvent.ClientTickEvent ev)
{
// Check to see whether anything has caused us to abort - if so, go to the abort state.
if (inAbortState())
episodeHasCompleted(ClientState.MISSION_ABORTED);
// We need to make sure that both the client and server have paused,
// otherwise we are still susceptible to the "Holder Lookups" hang.
// Since the server sets its pause state in response to the client's pause state,
// and it only performs this check once, at the top of its tick method,
// to be sure that the server has had time to set the flag correctly we need to make sure
// that at least one server tick method has *started* since the flag was set.
// We can't do this by catching the onServerTick events, since we don't receive them when the game is paused.
// The following code makes use of the fact that the server both locks and empties the server's futureQueue,
// every time through the server tick method.
// This locking means that if the client - which needs to wait on the lock -
// tries to add an event to the queue in response to an event on the queue being executed,
// the newly added event will have to happen in a subsequent tick.
if (Minecraft.getMinecraft().isGamePaused() && ev != null && ev.phase == Phase.END && this.clientTickCount == this.serverTickCount && this.clientTickCount <= 2)
{
this.clientTickCount++; // Increment our count, and wait for the server to catch up.
Minecraft.getMinecraft().getIntegratedServer().addScheduledTask(new Runnable()
{
public void run()
{
// Increment the server count.
PauseOldServerEpisode.this.serverTickCount++;
}
});
}
if (this.serverTickCount > 2)
episodeHasCompleted(ClientState.CLOSING_OLD_SERVER);
}
示例13: onWorldTick
@SubscribeEvent
public void onWorldTick(TickEvent.WorldTickEvent evt)
{
if (evt.world.hasCapability(ExPWorldCapability.worldCap, null) && evt.phase == Phase.END && evt.world.provider.getDimension() == 0)
{
IExPWorld.of(evt.world).onTick();
if (evt.world.isRaining() && evt.world instanceof WorldServer)
{
WeatherUtils.handleServerTick((WorldServer) evt.world);
}
}
}
示例14: playerTick
@SubscribeEvent
public void playerTick(TickEvent.PlayerTickEvent event)
{
if (event.player.hasCapability(ExPPlayerCapability.playerCap, null) && event.phase == Phase.END)
{
IExPPlayer.of(event.player).onTick();
}
}
示例15: onWorldTick
@SubscribeEvent
public void onWorldTick(WorldTickEvent event)
{
if (event.phase != Phase.END) { return; } // Only doing it once
if (event.side == Side.CLIENT) { return; }
upkeepTick += 1;
if (upkeepTick >= Main.getConsumeUpkeepTick())
{
TerritoryHandler.consumeUpkeep(event.world);
upkeepTick = 0; // Reset
}
}