Skip to content

Commit

Permalink
Timings v2 implemented! It still has some bugs but it is functional. …
Browse files Browse the repository at this point in the history
…Updated a small part of the bukkit api.
  • Loading branch information
juanmuscaria committed Feb 28, 2020
1 parent 0937a40 commit 8049288
Show file tree
Hide file tree
Showing 45 changed files with 881 additions and 612 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def gitInfo(String key) {
ext.mcVersion = "1.7.10"
ext.forgeVersion = "1614"
ext.revision = "1.0.7"
version = "${mcVersion}-${forgeVersion}.${revision}"
ext.crucibleVersion = "3.0"
version = "${mcVersion}-${crucibleVersion}"

launch4j {
jreMinVersion = '1.8.0'
Expand Down
66 changes: 66 additions & 0 deletions patches/cpw/mods/fml/common/eventhandler/EventBus.java.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
--- ../src-base/minecraft/cpw/mods/fml/common/eventhandler/EventBus.java
+++ ../src-work/minecraft/cpw/mods/fml/common/eventhandler/EventBus.java
@@ -9,6 +9,9 @@

import javax.annotation.Nonnull;

+import co.aikar.timings.Timing;
+import io.github.crucible.CrucibleTimings;
+import net.minecraft.server.MinecraftServer;
import org.apache.logging.log4j.Level;

import com.google.common.base.Preconditions;
@@ -131,19 +134,43 @@

public boolean post(Event event)
{
- IEventListener[] listeners = event.getListenerList().getListeners(busID);
- int index = 0;
- try
- {
- for (; index < listeners.length; index++)
+ if (MinecraftServer.serverStarted) { //Only use timings after the startup.
+ Timing eventTiming = CrucibleTimings.getEventTiming(event); //Crucible
+ eventTiming.startTiming(); //Crucible
+ IEventListener[] listeners = event.getListenerList().getListeners(busID);
+ int index = 0;
+ try
{
- listeners[index].invoke(event);
+ for (; index < listeners.length; index++)
+ {
+ Timing listenerTimings = CrucibleTimings.getListenerTiming(listeners[index],eventTiming); //Crucible
+ listenerTimings.startTiming(); //Crucible
+ listeners[index].invoke(event);
+ listenerTimings.stopTiming(); //Crucible
+ }
}
+ catch (Throwable throwable)
+ {
+ exceptionHandler.handleException(this, event, listeners, index, throwable);
+ Throwables.propagate(throwable);
+ }
+ eventTiming.stopTiming(); //Crucible
}
- catch (Throwable throwable)
- {
- exceptionHandler.handleException(this, event, listeners, index, throwable);
- Throwables.propagate(throwable);
+ else { //Original code.
+ IEventListener[] listeners = event.getListenerList().getListeners(busID);
+ int index = 0;
+ try
+ {
+ for (; index < listeners.length; index++)
+ {
+ listeners[index].invoke(event);
+ }
+ }
+ catch (Throwable throwable)
+ {
+ exceptionHandler.handleException(this, event, listeners, index, throwable);
+ Throwables.propagate(throwable);
+ }
}
return (event.isCancelable() ? event.isCanceled() : false);
}
23 changes: 18 additions & 5 deletions patches/net/minecraft/block/Block.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,28 @@
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.common.util.RotationHelper;
@@ -122,6 +124,7 @@
@@ -118,10 +120,20 @@
public Block.SoundType stepSound;
public float blockParticleGravity;
protected final Material blockMaterial;
+ // Paper start
+ public co.aikar.timings.Timing timing;
+ public co.aikar.timings.Timing getTiming() {
+ if (timing == null) {
+ timing = co.aikar.timings.MinecraftTimings.getBlockTiming(this);
+ }
+ return timing;
+ }
+ // Paper end
public float slipperiness;
private String unlocalizedName;
@SideOnly(Side.CLIENT)
protected IIcon blockIcon;
+ public boolean isForgeBlock; // Cauldron
private static final String __OBFID = "CL_00000199";

public final cpw.mods.fml.common.registry.RegistryDelegate<Block> delegate =
@@ -133,6 +136,8 @@
@@ -133,6 +145,8 @@

public static Block getBlockById(int p_149729_0_)
{
Expand All @@ -33,7 +46,7 @@
Block ret = (Block)blockRegistry.getObjectById(p_149729_0_);
return ret == null ? Blocks.air : ret;
}
@@ -564,6 +569,10 @@
@@ -564,6 +578,10 @@

public void addCollisionBoxesToList(World p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_)
{
Expand All @@ -44,7 +57,7 @@
AxisAlignedBB axisalignedbb1 = this.getCollisionBoundingBoxFromPool(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_);

if (axisalignedbb1 != null && p_149743_5_.intersectsWith(axisalignedbb1))
@@ -954,13 +963,18 @@
@@ -954,13 +972,18 @@
if (this.canSilkHarvest(p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_) && EnchantmentHelper.getSilkTouchModifier(p_149636_2_))
{
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
Expand All @@ -67,7 +80,7 @@
ForgeEventFactory.fireBlockHarvesting(items, p_149636_1_, this, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_, 0, 1.0f, true, p_149636_2_);
for (ItemStack is : items)
{
@@ -1131,6 +1145,23 @@
@@ -1131,6 +1154,23 @@
return this;
}

Expand Down
Loading

0 comments on commit 8049288

Please sign in to comment.