Skip to content

Commit

Permalink
Refactored CraftBukkit to Support NMS
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexeption committed Aug 24, 2019
1 parent 649dd62 commit cc62a7b
Show file tree
Hide file tree
Showing 478 changed files with 2,262 additions and 1,834 deletions.
20 changes: 14 additions & 6 deletions patches/net/minecraft/advancements/Advancement.java.patch
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
--- ../src-base/minecraft/net/minecraft/advancements/Advancement.java
+++ ../src-work/minecraft/net/minecraft/advancements/Advancement.java
@@ -32,6 +32,7 @@
@@ -21,6 +21,7 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.ArrayUtils;
+import org.bukkit.craftbukkit.v1_12_R1.advancement.CraftAdvancement;

public class Advancement
{
@@ -32,6 +33,7 @@
private final String[][] requirements;
private final Set<Advancement> children = Sets.<Advancement>newLinkedHashSet();
private final ITextComponent displayText;
+ public final org.bukkit.advancement.Advancement bukkit = new org.bukkit.craftbukkit.advancement.CraftAdvancement(this); // CraftBukkit
+ public final org.bukkit.advancement.Advancement bukkit = new CraftAdvancement(this); // CraftBukkit

public Advancement(ResourceLocation id, @Nullable Advancement parentIn, @Nullable DisplayInfo displayIn, AdvancementRewards rewardsIn, Map<String, Criterion> criteriaIn, String[][] requirementsIn)
{
@@ -68,9 +69,9 @@
@@ -68,9 +70,9 @@
}
}

Expand All @@ -20,7 +28,7 @@
}

@Nullable
@@ -230,7 +231,7 @@
@@ -230,7 +232,7 @@
return "Task Advancement{parentId=" + this.parentId + ", display=" + this.display + ", rewards=" + this.rewards + ", criteria=" + this.criteria + ", requirements=" + Arrays.deepToString(this.requirements) + '}';
}

Expand All @@ -29,7 +37,7 @@
{
ResourceLocation resourcelocation = json.has("parent") ? new ResourceLocation(JsonUtils.getString(json, "parent")) : null;
DisplayInfo displayinfo = json.has("display") ? DisplayInfo.deserialize(JsonUtils.getJsonObject(json, "display"), context) : null;
@@ -303,11 +304,11 @@
@@ -303,11 +305,11 @@
}
}

Expand All @@ -43,7 +51,7 @@
{
ResourceLocation resourcelocation = buf.readBoolean() ? buf.readResourceLocation() : null;
DisplayInfo displayinfo = buf.readBoolean() ? DisplayInfo.read(buf) : null;
@@ -324,7 +325,7 @@
@@ -324,7 +326,7 @@
}
}

Expand Down
20 changes: 14 additions & 6 deletions patches/net/minecraft/advancements/FunctionManager.java.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
--- ../src-base/minecraft/net/minecraft/advancements/FunctionManager.java
+++ ../src-work/minecraft/net/minecraft/advancements/FunctionManager.java
@@ -27,10 +27,13 @@
@@ -18,6 +18,7 @@
import org.apache.commons.io.FilenameUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.bukkit.craftbukkit.v1_12_R1.command.CraftFunctionCommandSender;

public class FunctionManager implements ITickable
{
@@ -27,10 +28,13 @@
private final Map<ResourceLocation, FunctionObject> functions = Maps.<ResourceLocation, FunctionObject>newHashMap();
private String currentGameLoopFunctionId = "-";
private FunctionObject gameLoopFunction;
Expand All @@ -13,11 +21,11 @@
+
+ public class CustomFunctionListener implements ICommandSender {
+
+ public org.bukkit.command.CommandSender sender = new org.bukkit.craftbukkit.command.CraftFunctionCommandSender(this);
+ public org.bukkit.command.CommandSender sender = new CraftFunctionCommandSender(this);
public String getName()
{
return FunctionManager.this.currentGameLoopFunctionId;
@@ -39,6 +42,11 @@
@@ -39,6 +43,11 @@
{
return permLevel <= 2;
}
Expand All @@ -29,7 +37,7 @@
public World getEntityWorld()
{
return FunctionManager.this.server.worlds[0];
@@ -101,7 +109,7 @@
@@ -101,7 +110,7 @@
{
if (this.commandQueue.size() < i)
{
Expand All @@ -38,7 +46,7 @@
}

return 0;
@@ -118,7 +126,7 @@
@@ -118,7 +127,7 @@

for (int k = afunctionobject$entry.length - 1; k >= 0; --k)
{
Expand All @@ -47,7 +55,7 @@
}

while (true)
@@ -192,26 +200,26 @@
@@ -192,26 +201,26 @@
}

public static class QueuedCommand
Expand Down
16 changes: 12 additions & 4 deletions patches/net/minecraft/block/BlockBush.java.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
--- ../src-base/minecraft/net/minecraft/block/BlockBush.java
+++ ../src-work/minecraft/net/minecraft/block/BlockBush.java
@@ -41,7 +41,7 @@
@@ -16,6 +16,7 @@
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
+import org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory;

public class BlockBush extends Block implements net.minecraftforge.common.IPlantable
{
@@ -41,7 +42,7 @@
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
IBlockState soil = worldIn.getBlockState(pos.down());
Expand All @@ -9,17 +17,17 @@
}

protected boolean canSustainBush(IBlockState state)
@@ -64,6 +64,9 @@
@@ -64,6 +65,9 @@
{
if (!this.canBlockStay(worldIn, pos, state))
{
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(worldIn, pos).isCancelled()) {
+ if (CraftEventFactory.callBlockPhysicsEvent(worldIn, pos).isCancelled()) {
+ return;
+ }
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 3);
}
@@ -74,7 +77,7 @@
@@ -74,7 +78,7 @@
if (state.getBlock() == this) //Forge: This function is called during world gen and placement, before this block is set, so if we are not 'here' then assume it's the pre-check.
{
IBlockState soil = worldIn.getBlockState(pos.down());
Expand Down
16 changes: 12 additions & 4 deletions patches/net/minecraft/block/BlockCactus.java.patch
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
--- ../src-base/minecraft/net/minecraft/block/BlockCactus.java
+++ ../src-work/minecraft/net/minecraft/block/BlockCactus.java
@@ -19,6 +19,7 @@
@@ -9,7 +9,6 @@
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
-import net.minecraft.init.Blocks;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumFacing;
@@ -19,6 +18,7 @@
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory;

public class BlockCactus extends Block implements net.minecraftforge.common.IPlantable
{
@@ -54,10 +55,11 @@
@@ -54,10 +54,11 @@

if(net.minecraftforge.common.ForgeHooks.onCropsGrowPre(worldIn, blockpos, state, true))
{
Expand All @@ -22,7 +30,7 @@
worldIn.setBlockState(pos, iblockstate, 4);
iblockstate.neighborChanged(worldIn, blockpos, this, pos);
}
@@ -123,7 +125,9 @@
@@ -123,7 +124,9 @@

public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
{
Expand Down
12 changes: 10 additions & 2 deletions patches/net/minecraft/block/BlockCake.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,23 @@
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -71,7 +72,17 @@
@@ -21,6 +22,7 @@
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
+import org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory;

public class BlockCake extends Block
{
@@ -71,7 +73,17 @@
else
{
player.addStat(StatList.CAKE_SLICES_EATEN);
+ // Magma Restore CraftBukkit changes for AppleCore recognition
player.getFoodStats().addStats(2, 0.1F);
+ int oldFoodLevel = player.getFoodStats().foodLevel;
+
+ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(player, 2 + oldFoodLevel);
+ org.bukkit.event.entity.FoodLevelChangeEvent event = CraftEventFactory.callFoodLevelChangeEvent(player, 2 + oldFoodLevel);
+
+ if (!event.isCancelled()) {
+ player.getFoodStats().addStats(event.getFoodLevel() - oldFoodLevel, 0.1F);
Expand Down
2 changes: 1 addition & 1 deletion patches/net/minecraft/block/BlockChorusFlower.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory;

public class BlockChorusFlower extends Block
{
Expand Down
2 changes: 1 addition & 1 deletion patches/net/minecraft/block/BlockCocoa.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory;

public class BlockCocoa extends BlockHorizontal implements IGrowable
{
Expand Down
16 changes: 12 additions & 4 deletions patches/net/minecraft/block/BlockConcretePowder.java.patch
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
--- ../src-base/minecraft/net/minecraft/block/BlockConcretePowder.java
+++ ../src-work/minecraft/net/minecraft/block/BlockConcretePowder.java
@@ -29,9 +29,8 @@
@@ -15,6 +15,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+import org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory;

public class BlockConcretePowder extends BlockFalling
{
@@ -29,9 +30,8 @@

public void onEndFalling(World worldIn, BlockPos pos, IBlockState p_176502_3_, IBlockState p_176502_4_)
{
- if (p_176502_4_.getMaterial().isLiquid())
- {
- worldIn.setBlockState(pos, Blocks.CONCRETE.getDefaultState().withProperty(BlockColored.COLOR, p_176502_3_.getValue(COLOR)), 3);
+ if (p_176502_4_.getMaterial().isLiquid() && worldIn.getBlockState(pos).getBlock() != Blocks.CONCRETE) { // CraftBukkit - don't double concrete
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(worldIn, pos, Blocks.CONCRETE.getDefaultState().withProperty(BlockColored.COLOR, p_176502_3_.getValue(BlockConcretePowder.COLOR)), null); // CraftBukkit
+ CraftEventFactory.handleBlockFormEvent(worldIn, pos, Blocks.CONCRETE.getDefaultState().withProperty(BlockColored.COLOR, p_176502_3_.getValue(BlockConcretePowder.COLOR)), null); // CraftBukkit
}
}

@@ -55,7 +54,7 @@
@@ -55,7 +55,7 @@

if (flag)
{
- worldIn.setBlockState(pos, Blocks.CONCRETE.getDefaultState().withProperty(BlockColored.COLOR, state.getValue(COLOR)), 3);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(worldIn, pos, Blocks.CONCRETE.getDefaultState().withProperty(BlockColored.COLOR, state.getValue(BlockConcretePowder.COLOR)), null);
+ CraftEventFactory.handleBlockFormEvent(worldIn, pos, Blocks.CONCRETE.getDefaultState().withProperty(BlockColored.COLOR, state.getValue(BlockConcretePowder.COLOR)), null);
}

return flag;
2 changes: 1 addition & 1 deletion patches/net/minecraft/block/BlockCrops.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory;

public class BlockCrops extends BlockBush implements IGrowable
{
Expand Down
12 changes: 10 additions & 2 deletions patches/net/minecraft/block/BlockDaylightDetector.java.patch
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
--- ../src-base/minecraft/net/minecraft/block/BlockDaylightDetector.java
+++ ../src-work/minecraft/net/minecraft/block/BlockDaylightDetector.java
@@ -76,6 +76,7 @@
@@ -24,6 +24,7 @@
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+import org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory;

public class BlockDaylightDetector extends BlockContainer
{
@@ -76,6 +77,7 @@

if (((Integer)iblockstate.getValue(POWER)).intValue() != i)
{
+ i = org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(worldIn, pos.getX(), pos.getY(), pos.getZ(), iblockstate.getValue(POWER), i).getNewCurrent();
+ i = CraftEventFactory.callRedstoneChange(worldIn, pos.getX(), pos.getY(), pos.getZ(), iblockstate.getValue(POWER), i).getNewCurrent();
worldIn.setBlockState(pos, iblockstate.withProperty(POWER, Integer.valueOf(i)), 3);
}
}
4 changes: 2 additions & 2 deletions patches/net/minecraft/block/BlockDoublePlant.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

+import net.minecraft.block.Block.EnumOffsetType;
+import org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory;
+
public class BlockDoublePlant extends BlockBush implements IGrowable, net.minecraftforge.common.IShearable
{
Expand Down Expand Up @@ -58,7 +58,7 @@
if (!this.canBlockStay(worldIn, pos, state))
{
- boolean flag = state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER;
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(worldIn, pos).isCancelled()) {
+ if (CraftEventFactory.callBlockPhysicsEvent(worldIn, pos).isCancelled()) {
+ return;
+ }
+ boolean flag = state.getValue(HALF) == EnumBlockHalf.UPPER;
Expand Down
11 changes: 6 additions & 5 deletions patches/net/minecraft/block/BlockDropper.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityDispenser;
@@ -11,6 +12,8 @@
@@ -11,6 +12,9 @@
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftInventoryDoubleChest;
+import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
+import org.bukkit.event.inventory.InventoryMoveItemEvent;

public class BlockDropper extends BlockDispenser
{
@@ -26,7 +29,7 @@
@@ -26,7 +30,7 @@
return new TileEntityDropper();
}

Expand All @@ -26,7 +27,7 @@
{
BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos);
TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();
@@ -56,9 +59,22 @@
@@ -56,9 +60,22 @@
}
else
{
Expand All @@ -35,7 +36,7 @@
+ org.bukkit.inventory.Inventory destinationInventory;
+ // Have to special case large chests as they work oddly
+ if (iinventory instanceof InventoryLargeChest) {
+ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
+ destinationInventory = new CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
+ } else {
+ destinationInventory = iinventory.getOwner().getInventory();
+ }
Expand Down
Loading

0 comments on commit cc62a7b

Please sign in to comment.