Skip to content
This repository has been archived by the owner on Mar 23, 2021. It is now read-only.

Commit

Permalink
Merge pull request #24 from Timardo/master
Browse files Browse the repository at this point in the history
Fixes #2
  • Loading branch information
Hexeption authored May 2, 2019
2 parents 0f5ecbf + fe0797e commit a8543ec
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 37 deletions.
8 changes: 4 additions & 4 deletions patches/net/minecraft/entity/EntityLiving.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@

if (!itemstack1.isEmpty() && (double)(this.rand.nextFloat() - 0.1F) < d0)
{
+ this.forceDrops = true;
+ //this.forceDrops = true;
this.entityDropItem(itemstack1, 0.0F);
+ this.forceDrops = false;
+ //this.forceDrops = false;
}

this.setItemStackToSlot(entityequipmentslot, itemstack);
Expand Down Expand Up @@ -249,9 +249,9 @@

if (!this.world.isRemote && dropLead)
{
+ this.forceDrops = true;
+ //this.forceDrops = true;
this.dropItem(Items.LEAD, 1);
+ this.forceDrops = false;
+ //this.forceDrops = false;
}

if (!this.world.isRemote && sendPacket && this.world instanceof WorldServer)
Expand Down
60 changes: 29 additions & 31 deletions patches/net/minecraft/entity/EntityLivingBase.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
+ // CraftBukkit start
+ public int expToDrop;
+ public int maxAirTicks = 300;
+ public boolean forceDrops;
+ // public boolean forceDrops; Kettle - don't use this as we use Forge's drop-capturing system that handles this properly
+ public ArrayList<org.bukkit.inventory.ItemStack> drops = new ArrayList<>();
+ public org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes;
+ public boolean collides = true;
Expand Down Expand Up @@ -530,7 +530,7 @@
}
}

@@ -1196,11 +1352,28 @@
@@ -1196,11 +1352,26 @@
boolean flag = this.recentlyHit > 0;
this.dropLoot(flag, i, cause);
}
Expand All @@ -543,14 +543,12 @@
+ // Kettle start - first allow forge to alter drops, then plugins and finally spawn items
+ if (capturedDrops.size() > 0) {
+ this.drops = new ArrayList<>();
+ // CraftBukkit start - Handle forceDrops
+ if (this instanceof EntityLiving && !((EntityLiving) this).forceDrops) {
+ // CraftBukkit end
+ for (EntityItem item : capturedDrops)
+ {
+ this.drops.add(CraftItemStack.asCraftMirror(item.getItem()));
+ }
+ // Kettle - don't use forceDrops
+ for (EntityItem item : capturedDrops)
+ {
+ this.drops.add(CraftItemStack.asCraftMirror(item.getItem()));
+ }
+
+ CraftEventFactory.callEntityDeathEvent(this, this.drops);
+ } else {
+ CraftEventFactory.callEntityDeathEvent(this);
Expand All @@ -560,7 +558,7 @@
for (EntityItem item : capturedDrops)
{
world.spawnEntity(item);
@@ -1321,8 +1494,13 @@
@@ -1321,8 +1492,13 @@

if (i > 0)
{
Expand All @@ -575,7 +573,7 @@
int j = MathHelper.floor(this.posX);
int k = MathHelper.floor(this.posY - 0.20000000298023224D);
int l = MathHelper.floor(this.posZ);
@@ -1362,7 +1540,7 @@
@@ -1362,7 +1538,7 @@
{
if (!source.isUnblockable())
{
Expand All @@ -584,7 +582,7 @@
damage = CombatRules.getDamageAfterAbsorb(damage, (float)this.getTotalArmorValue(), (float)this.getEntityAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS).getAttributeValue());
}

@@ -1377,7 +1555,8 @@
@@ -1377,7 +1553,8 @@
}
else
{
Expand All @@ -594,7 +592,7 @@
{
int i = (this.getActivePotionEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5;
int j = 25 - i;
@@ -1405,6 +1584,8 @@
@@ -1405,6 +1582,8 @@

protected void damageEntity(DamageSource damageSrc, float damageAmount)
{
Expand All @@ -603,7 +601,7 @@
if (!this.isEntityInvulnerable(damageSrc))
{
damageAmount = net.minecraftforge.common.ForgeHooks.onLivingHurt(this, damageSrc, damageAmount);
@@ -1424,8 +1605,146 @@
@@ -1424,8 +1603,146 @@
this.setAbsorptionAmount(this.getAbsorptionAmount() - damageAmount);
}
}
Expand Down Expand Up @@ -750,15 +748,15 @@
public CombatTracker getCombatTracker()
{
return this._combatTracker;
@@ -1605,6 +1924,7 @@
@@ -1605,6 +1922,7 @@
if (this.attributeMap == null)
{
this.attributeMap = new AttributeMap();
+ this.craftAttributes = new CraftAttributeMap(attributeMap); // CraftBukkit
}

return this.attributeMap;
@@ -1900,7 +2220,8 @@
@@ -1900,7 +2218,8 @@

if (this.onGround && !this.world.isRemote)
{
Expand All @@ -768,15 +766,15 @@
}
}
else
@@ -2093,6 +2414,7 @@
@@ -2093,6 +2412,7 @@
public void onUpdate()
{
if (net.minecraftforge.common.ForgeHooks.onLivingUpdate(this)) return;
+ SpigotTimings.timerEntityBaseTick.startTiming(); // Spigot
super.onUpdate();
this.updateActiveHand();

@@ -2176,7 +2498,9 @@
@@ -2176,7 +2496,9 @@
}
}

Expand All @@ -786,31 +784,31 @@
double d0 = this.posX - this.prevPosX;
double d1 = this.posZ - this.prevPosZ;
float f3 = (float)(d0 * d0 + d1 * d1);
@@ -2269,6 +2593,7 @@
@@ -2269,6 +2591,7 @@
{
this.ticksElytraFlying = 0;
}
+ SpigotTimings.timerEntityTickRest.stopTiming(); // Spigot
}

protected float updateDistance(float p_110146_1_, float p_110146_2_)
@@ -2345,6 +2670,7 @@
@@ -2345,6 +2668,7 @@
}

this.world.profiler.startSection("ai");
+ SpigotTimings.timerEntityAI.startTiming(); // Spigot

if (this.isMovementBlocked())
{
@@ -2359,6 +2685,7 @@
@@ -2359,6 +2683,7 @@
this.updateEntityActionState();
this.world.profiler.endSection();
}
+ SpigotTimings.timerEntityAI.stopTiming(); // Spigot

this.world.profiler.endSection();
this.world.profiler.startSection("jump");
@@ -2390,10 +2717,14 @@
@@ -2390,10 +2715,14 @@
this.moveForward *= 0.98F;
this.randomYawVelocity *= 0.9F;
this.updateElytra();
Expand All @@ -825,15 +823,15 @@
this.world.profiler.endSection();
}

@@ -2426,6 +2757,7 @@
@@ -2426,6 +2755,7 @@

if (!this.world.isRemote)
{
+ if (flag != this.getFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, flag).isCancelled()) // CraftBukkit
this.setFlag(7, flag);
}
}
@@ -2560,12 +2892,12 @@
@@ -2560,12 +2890,12 @@

public boolean canBeCollidedWith()
{
Expand All @@ -848,7 +846,7 @@
}

protected void markVelocityChanged()
@@ -2629,7 +2961,7 @@
@@ -2629,7 +2959,7 @@
{
PotionEffect effect = iterator.next();

Expand All @@ -857,15 +855,15 @@
{
onFinishedPotionEffect(effect);
iterator.remove();
@@ -2667,7 +2999,6 @@
@@ -2667,7 +2997,6 @@
if (this.isHandActive())
{
ItemStack itemstack = this.getHeldItem(this.getActiveHand());
- if (net.minecraftforge.common.ForgeHooks.canContinueUsing(this.activeItemStack, itemstack)) this.activeItemStack = itemstack;

if (itemstack == this.activeItemStack)
{
@@ -2786,7 +3117,24 @@
@@ -2786,7 +3115,24 @@
{
this.updateItemUse(this.activeItemStack, 16);
ItemStack activeItemStackCopy = this.activeItemStack.copy();
Expand All @@ -891,7 +889,7 @@
itemstack = net.minecraftforge.event.ForgeEventFactory.onItemUseFinish(this, activeItemStackCopy, getItemInUseCount(), itemstack);
this.setHeldItem(this.getActiveHand(), itemstack);
this.resetActiveHand();
@@ -2897,12 +3245,17 @@
@@ -2897,12 +3243,17 @@

if (flag1)
{
Expand All @@ -914,7 +912,7 @@
}
}

@@ -2936,6 +3289,11 @@
@@ -2936,6 +3287,11 @@
}
}

Expand All @@ -926,7 +924,7 @@
public boolean canBeHitWithPotion()
{
return true;
@@ -2949,7 +3307,7 @@
@@ -2949,7 +3305,7 @@
@SuppressWarnings("unchecked")
@Override
@Nullable
Expand All @@ -935,7 +933,7 @@
{
if (capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
{
@@ -2961,7 +3319,7 @@
@@ -2961,7 +3317,7 @@
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions patches/net/minecraft/entity/passive/EntitySheep.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@

for (int j = 0; j < i; ++j)
{
+ this.forceDrops = true; // CraftBukkit
+ //this.forceDrops = true; // CraftBukkit
EntityItem entityitem = this.entityDropItem(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, this.getFleeceColor().getMetadata()), 1.0F);
+ this.forceDrops = false; // CraftBukkit
+ //this.forceDrops = false; // CraftBukkit
entityitem.motionY += (double)(this.rand.nextFloat() * 0.05F);
entityitem.motionX += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
entityitem.motionZ += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,17 @@ public static ItemStack asBukkitCopy(net.minecraft.item.ItemStack original) {
if (original.isEmpty()) {
return new ItemStack(Material.AIR);
}

// Kettle start - don't use strict Bukkit stacks as we don't have Bukkit Materials for modded item stacks, create wrapper? (Cauldron)
return asCraftMirror(copyNMSStack(original, original.getCount()));
/*
ItemStack stack = new ItemStack(CraftMagicNumbers.getMaterial(original.getItem()), original.getCount(), (short) original.getMetadata());
if (hasItemMeta(original)) {
stack.setItemMeta(getItemMeta(original));
}
return stack;
*/
// Kettle end
}

public static CraftItemStack asCraftMirror(net.minecraft.item.ItemStack original) {
Expand Down

0 comments on commit a8543ec

Please sign in to comment.