Most of ItemInWorldManager reject, various small error fixes.

This commit is contained in:
RainWarrior committed 2016-03-08 23:33:28 +03:00
1 parent 4b4146bbed
commit befbb45522
11 files changed
+233 -225

No files matched your search

@@ -13,7 +13,7 @@
public void handleChat(SPacketChat packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
+ net.minecraft.util.IChatComponent message = net.minecraftforge.event.ForgeEventFactory.onClientChat(packetIn.getType(), packetIn.getChatComponent());
+ net.minecraft.util.text.ITextComponent message = net.minecraftforge.event.ForgeEventFactory.onClientChat(packetIn.getType(), packetIn.getChatComponent());
+ if (message == null) return;
if (packetIn.getType() == 2)
@@ -40,17 +40,17 @@
EntityTracker.func_187254_a(entitylivingbase, d0, d1, d2);
entitylivingbase.renderYawOffset = entitylivingbase.rotationYawHead = (float)(packetIn.getHeadPitch() * 360) / 256.0F;
Entity[] aentity = entitylivingbase.getParts();
@@ -1082,6 +1089,10 @@
@@ -1179,6 +1186,10 @@
{
entityplayer.openContainer.putStackInSlot(packetIn.func_149173_d(), packetIn.func_149174_e());
tileentity.readFromNBT(packetIn.getNbtCompound());
}
+ else
+ {
+ tileentity.onDataPacket(netManager, packetIn);
+ }
}
}
if (flag && this.gameController.currentScreen instanceof GuiCommandBlock)
{
@@ -1378,7 +1389,7 @@
if (entity instanceof EntityLivingBase)
@@ -132,7 +132,7 @@
public void func_184609_a(EnumHand p_184609_1_)
{
+ ItemStack stack = this.getHeldItem();
+ ItemStack stack = this.func_184586_b(p_184609_1_);
+ if (stack != null && stack.getItem() != null)
+ {
+ if (stack.getItem().onEntitySwing(this, stack)) return;
@@ -60,7 +60,7 @@
public Entity func_184204_a(int p_184204_1_)
{
+ if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_184204_1_)) return;
+ if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_184204_1_)) return this;
this.field_184851_cj = true;
if (this.dimension == 1 && p_184204_1_ == 1)
@@ -360,7 +360,7 @@
+ * @param type The subtype, can be null or "overlay"
+ * @return Path of texture to bind, or null to use default
+ */
+ public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
+ public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type)
+ {
+ return null;
+ }
@@ -383,12 +383,12 @@
+ *
+ * @param entityLiving The entity wearing the armor
+ * @param itemStack The itemStack to render the model of
+ * @param armorSlot 0=head, 1=torso, 2=legs, 3=feet
+ * @param armorSlot The slot the armor is in
+ * @param _default Original armor model. Will have attributes set.
+ * @return A ModelBiped to render instead of the default
+ */
+ @SideOnly(Side.CLIENT)
+ public net.minecraft.client.model.ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot, net.minecraft.client.model.ModelBiped _default)
+ public net.minecraft.client.model.ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, net.minecraft.client.model.ModelBiped _default)
+ {
+ return null;
+ }
@@ -0,0 +1,213 @@
--- ../src-base/minecraft/net/minecraft/server/management/PlayerInteractionManager.java
+++ ../src-work/minecraft/net/minecraft/server/management/PlayerInteractionManager.java
@@ -27,6 +27,8 @@
public class PlayerInteractionManager
{
+ /** Forge reach distance */
+ private double blockReachDistance = 5.0d;
public World theWorld;
public EntityPlayerMP thisPlayerMP;
private WorldSettings.GameType gameType = WorldSettings.GameType.NOT_SET;
@@ -88,7 +90,7 @@
IBlockState iblockstate = this.theWorld.getBlockState(this.field_180241_i);
Block block = iblockstate.getBlock();
- if (iblockstate.func_185904_a() == Material.air)
+ if (block.isAir(iblockstate, theWorld, field_180241_i))
{
this.receivedFinishDiggingPacket = false;
}
@@ -115,7 +117,7 @@
IBlockState iblockstate1 = this.theWorld.getBlockState(this.field_180240_f);
Block block1 = iblockstate1.getBlock();
- if (iblockstate1.func_185904_a() == Material.air)
+ if (block1.isAir(iblockstate1, theWorld, field_180240_f))
{
this.theWorld.sendBlockBreakProgress(this.thisPlayerMP.getEntityId(), this.field_180240_f, -1);
this.durabilityRemainingOnBlock = -1;
@@ -124,7 +126,7 @@
else
{
int k = this.curblockDamage - this.initialDamage;
- float f1 = iblockstate1.func_185903_a(this.thisPlayerMP, this.thisPlayerMP.worldObj, this.field_180241_i) * (float)(k + 1);
+ float f1 = iblockstate1.func_185903_a(this.thisPlayerMP, this.thisPlayerMP.worldObj, this.field_180240_f) * (float)(k + 1); // Forge: Fix network break progress using wrong position
int l = (int)(f1 * 10.0F);
if (l != this.durabilityRemainingOnBlock)
@@ -138,6 +140,14 @@
public void onBlockClicked(BlockPos pos, EnumFacing side)
{
+ net.minecraftforge.event.entity.player.PlayerInteractEvent event = net.minecraftforge.event.ForgeEventFactory.onPlayerInteract(thisPlayerMP,
+ net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.LEFT_CLICK_BLOCK, theWorld, pos, side, net.minecraftforge.common.ForgeHooks.rayTraceEyeHitVec(thisPlayerMP, getBlockReachDistance() + 1));
+ if (event.isCanceled())
+ {
+ thisPlayerMP.playerNetServerHandler.sendPacket(new SPacketBlockChange(theWorld, pos));
+ return;
+ }
+
if (this.isCreative())
{
if (!this.theWorld.extinguishFire((EntityPlayer)null, pos, side))
@@ -173,17 +183,32 @@
}
}
- this.theWorld.extinguishFire((EntityPlayer)null, pos, side);
this.initialDamage = this.curblockDamage;
float f = 1.0F;
- if (iblockstate.func_185904_a() != Material.air)
+ if (!iblockstate.getBlock().isAir(iblockstate, theWorld, pos))
{
- block.onBlockClicked(this.theWorld, pos, this.thisPlayerMP);
+ if (event.useBlock != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY)
+ {
+ block.onBlockClicked(this.theWorld, pos, this.thisPlayerMP);
+ this.theWorld.extinguishFire((EntityPlayer)null, pos, side);
+ }
+ else
+ {
+ thisPlayerMP.playerNetServerHandler.sendPacket(new SPacketBlockChange(theWorld, pos));
+ }
f = iblockstate.func_185903_a(this.thisPlayerMP, this.thisPlayerMP.worldObj, pos);
}
+ if (event.useItem == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY)
+ {
+ if (f >= 1.0F)
+ {
+ thisPlayerMP.playerNetServerHandler.sendPacket(new SPacketBlockChange(theWorld, pos));
+ }
+ return;
+ }
- if (iblockstate.func_185904_a() != Material.air && f >= 1.0F)
+ if (iblockstate.getBlock().isAir(iblockstate, theWorld, pos) && f >= 1.0F)
{
this.tryHarvestBlock(pos);
}
@@ -205,7 +230,7 @@
int i = this.curblockDamage - this.initialDamage;
IBlockState iblockstate = this.theWorld.getBlockState(pos);
- if (iblockstate.func_185904_a() != Material.air)
+ if (iblockstate.getBlock().isAir(iblockstate, theWorld, pos))
{
float f = iblockstate.func_185903_a(this.thisPlayerMP, this.thisPlayerMP.worldObj, pos) * (float)(i + 1);
@@ -234,9 +259,14 @@
private boolean removeBlock(BlockPos pos)
{
+ return removeBlock(pos, false);
+ }
+
+ private boolean removeBlock(BlockPos pos, boolean canHarvest)
+ {
IBlockState iblockstate = this.theWorld.getBlockState(pos);
iblockstate.getBlock().onBlockHarvested(this.theWorld, pos, iblockstate, this.thisPlayerMP);
- boolean flag = this.theWorld.setBlockToAir(pos);
+ boolean flag = iblockstate.getBlock().removedByPlayer(iblockstate, theWorld, pos, thisPlayerMP, canHarvest);
if (flag)
{
@@ -248,7 +278,8 @@
public boolean tryHarvestBlock(BlockPos pos)
{
- if (this.gameType.isCreative() && this.thisPlayerMP.func_184614_ca() != null && this.thisPlayerMP.func_184614_ca().getItem() instanceof ItemSword)
+ int exp = net.minecraftforge.common.ForgeHooks.onBlockBreakEvent(theWorld, gameType, thisPlayerMP, pos);
+ if (exp == -1)
{
return false;
}
@@ -264,41 +295,22 @@
}
else
{
- if (this.gameType.isAdventure())
- {
- if (this.gameType == WorldSettings.GameType.SPECTATOR)
- {
- return false;
- }
+ ItemStack stack = thisPlayerMP.func_184614_ca();
+ if (stack != null && stack.getItem().onBlockStartBreak(stack, pos, thisPlayerMP)) return false;
- if (!this.thisPlayerMP.isAllowEdit())
- {
- ItemStack itemstack = this.thisPlayerMP.func_184614_ca();
-
- if (itemstack == null)
- {
- return false;
- }
-
- if (!itemstack.canDestroy(iblockstate.getBlock()))
- {
- return false;
- }
- }
- }
-
this.theWorld.playAuxSFXAtEntity(this.thisPlayerMP, 2001, pos, Block.getStateId(iblockstate));
- boolean flag1 = this.removeBlock(pos);
+ boolean flag1 = false;
if (this.isCreative())
{
+ flag1 = this.removeBlock(pos);
this.thisPlayerMP.playerNetServerHandler.sendPacket(new SPacketBlockChange(this.theWorld, pos));
}
else
{
ItemStack itemstack1 = this.thisPlayerMP.func_184614_ca();
ItemStack itemstack2 = itemstack1 == null ? null : itemstack1.copy();
- boolean flag = this.thisPlayerMP.func_184823_b(iblockstate);
+ boolean flag = iblockstate.getBlock().canHarvestBlock(theWorld, pos, thisPlayerMP);
if (itemstack1 != null)
{
@@ -310,12 +322,18 @@
}
}
+ flag1 = this.removeBlock(pos, flag);
if (flag1 && flag)
{
iblockstate.getBlock().harvestBlock(this.theWorld, this.thisPlayerMP, pos, iblockstate, tileentity, itemstack2);
}
}
+ // Drop experience
+ if (!this.isCreative() && flag1 && exp > 0)
+ {
+ iblockstate.getBlock().dropXpOnBlockBreak(theWorld, pos, exp);
+ }
return flag1;
}
}
@@ -359,6 +377,7 @@
if (itemstack.stackSize == 0)
{
p_187250_1_.func_184611_a(p_187250_4_, (ItemStack)null);
+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(p_187250_1_, itemstack, p_187250_4_);
}
if (!p_187250_1_.func_184587_cr())
@@ -445,4 +464,13 @@
{
this.theWorld = serverWorld;
}
+
+ public double getBlockReachDistance()
+ {
+ return blockReachDistance;
+ }
+ public void setBlockReachDistance(double distance)
+ {
+ blockReachDistance = distance;
+ }
}
@@ -1,193 +1,3 @@
++++ REJECTED PATCH 1
public class ItemInWorldManager
{
+ /** Forge reach distance */
+ private double blockReachDistance = 5.0d;
public World theWorld;
public EntityPlayerMP thisPlayerMP;
private WorldSettings.GameType gameType = WorldSettings.GameType.NOT_SET;
++++ END PATCH
++++ REJECTED PATCH 2
else
{
int k = this.curblockDamage - this.initialDamage;
- float f1 = block1.getPlayerRelativeBlockHardness(this.thisPlayerMP, this.thisPlayerMP.worldObj, this.field_180241_i) * (float)(k + 1);
+ float f1 = block1.getPlayerRelativeBlockHardness(this.thisPlayerMP, this.thisPlayerMP.worldObj, this.field_180240_f) * (float)(k + 1); //Forge: Fix network break progress using wrong position
int l = (int)(f1 * 10.0F);
if (l != this.durabilityRemainingOnBlock)
++++ END PATCH
++++ REJECTED PATCH 3
public void onBlockClicked(BlockPos pos, EnumFacing side)
{
+ net.minecraftforge.event.entity.player.PlayerInteractEvent event = net.minecraftforge.event.ForgeEventFactory.onPlayerInteract(thisPlayerMP,
+ net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.LEFT_CLICK_BLOCK, theWorld, pos, side, net.minecraftforge.common.ForgeHooks.rayTraceEyeHitVec(thisPlayerMP, getBlockReachDistance() + 1));
+ if (event.isCanceled())
+ {
+ thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(theWorld, pos));
+ return;
+ }
+
if (this.isCreative())
{
if (!this.theWorld.extinguishFire((EntityPlayer)null, pos, side))
++++ END PATCH
++++ REJECTED PATCH 4
}
}
- this.theWorld.extinguishFire((EntityPlayer)null, pos, side);
+ //
this.initialDamage = this.curblockDamage;
float f = 1.0F;
- if (block.getMaterial() != Material.air)
+ if (!block.isAir(theWorld, pos))
{
- block.onBlockClicked(this.theWorld, pos, this.thisPlayerMP);
+ if (event.useBlock != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY)
+ {
+ block.onBlockClicked(this.theWorld, pos, this.thisPlayerMP);
+ this.theWorld.extinguishFire((EntityPlayer)null, pos, side);
+ }
+ else
+ {
+ thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(theWorld, pos));
+ }
f = block.getPlayerRelativeBlockHardness(this.thisPlayerMP, this.thisPlayerMP.worldObj, pos);
}
- if (block.getMaterial() != Material.air && f >= 1.0F)
+ if (event.useItem == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY)
{
+ if (f >= 1.0F)
+ {
+ thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(theWorld, pos));
+ }
+ return;
+ }
+
+ if (!block.isAir(theWorld, pos) && f >= 1.0F)
+ {
this.tryHarvestBlock(pos);
}
else
++++ END PATCH
++++ REJECTED PATCH 5
int i = this.curblockDamage - this.initialDamage;
Block block = this.theWorld.getBlockState(pos).getBlock();
- if (block.getMaterial() != Material.air)
+ if (!block.isAir(theWorld, pos))
{
float f = block.getPlayerRelativeBlockHardness(this.thisPlayerMP, this.thisPlayerMP.worldObj, pos) * (float)(i + 1);
++++ END PATCH
++++ REJECTED PATCH 6
private boolean removeBlock(BlockPos pos)
{
+ return removeBlock(pos, false);
+ }
+ private boolean removeBlock(BlockPos pos, boolean canHarvest)
+ {
IBlockState iblockstate = this.theWorld.getBlockState(pos);
iblockstate.getBlock().onBlockHarvested(this.theWorld, pos, iblockstate, this.thisPlayerMP);
- boolean flag = this.theWorld.setBlockToAir(pos);
+ boolean flag = iblockstate.getBlock().removedByPlayer(theWorld, pos, thisPlayerMP, canHarvest);
if (flag)
{
++++ END PATCH
++++ REJECTED PATCH 7
public boolean tryHarvestBlock(BlockPos pos)
{
- if (this.gameType.isCreative() && this.thisPlayerMP.getHeldItem() != null && this.thisPlayerMP.getHeldItem().getItem() instanceof ItemSword)
+ int exp = net.minecraftforge.common.ForgeHooks.onBlockBreakEvent(theWorld, gameType, thisPlayerMP, pos);
+ if (exp == -1)
{
return false;
}
++++ END PATCH
++++ REJECTED PATCH 8
IBlockState iblockstate = this.theWorld.getBlockState(pos);
TileEntity tileentity = this.theWorld.getTileEntity(pos);
- if (this.gameType.isAdventure())
- {
- if (this.gameType == WorldSettings.GameType.SPECTATOR)
- {
- return false;
- }
+ ItemStack stack = thisPlayerMP.getCurrentEquippedItem();
+ if (stack != null && stack.getItem().onBlockStartBreak(stack, pos, thisPlayerMP)) return false;
- if (!this.thisPlayerMP.isAllowEdit())
- {
- ItemStack itemstack = this.thisPlayerMP.getCurrentEquippedItem();
-
- if (itemstack == null)
- {
- return false;
- }
-
- if (!itemstack.canDestroy(iblockstate.getBlock()))
- {
- return false;
- }
- }
- }
-
this.theWorld.playAuxSFXAtEntity(this.thisPlayerMP, 2001, pos, Block.getStateId(iblockstate));
- boolean flag1 = this.removeBlock(pos);
+ boolean flag1 = false;
if (this.isCreative())
{
+ flag1 = this.removeBlock(pos);
this.thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(this.theWorld, pos));
}
else
{
ItemStack itemstack1 = this.thisPlayerMP.getCurrentEquippedItem();
- boolean flag = this.thisPlayerMP.canHarvestBlock(iblockstate.getBlock());
+ boolean flag = iblockstate.getBlock().canHarvestBlock(theWorld, pos, thisPlayerMP);
if (itemstack1 != null)
{
++++ END PATCH
++++ REJECTED PATCH 9
}
}
+ flag1 = this.removeBlock(pos, flag);
if (flag1 && flag)
{
iblockstate.getBlock().harvestBlock(this.theWorld, this.thisPlayerMP, pos, iblockstate, tileentity);
}
}
+ // Drop experiance
+ if (!this.isCreative() && flag1 && exp > 0)
+ {
+ iblockstate.getBlock().dropXpOnBlockBreak(theWorld, pos, exp);
+ }
return flag1;
}
}
++++ END PATCH
++++ REJECTED PATCH 10
if (itemstack.stackSize == 0)
{
player.inventory.mainInventory[player.inventory.currentItem] = null;
+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, itemstack);
}
if (!player.isUsingItem())
++++ END PATCH
++++ REJECTED PATCH 11
}
else
@@ -259,18 +69,3 @@
}
++++ END PATCH
++++ REJECTED PATCH 12
{
this.theWorld = serverWorld;
}
+
+ public double getBlockReachDistance()
+ {
+ return blockReachDistance;
+ }
+ public void setBlockReachDistance(double distance)
+ {
+ blockReachDistance = distance;
+ }
}
++++ END PATCH
@@ -137,24 +137,24 @@ public class ForgeHooks
public static boolean canHarvestBlock(Block block, EntityPlayer player, IBlockAccess world, BlockPos pos)
{
if (block.getMaterial().isToolNotRequired())
IBlockState state = world.getBlockState(pos);
state = state.getBlock().getActualState(state, world, pos);
if (state.func_185904_a().isToolNotRequired())
{
return true;
}
ItemStack stack = player.inventory.getCurrentItem();
IBlockState state = world.getBlockState(pos);
state = state.getBlock().getActualState(state, world, pos);
String tool = block.getHarvestTool(state);
if (stack == null || tool == null)
{
return player.canHarvestBlock(block);
return player.func_184823_b(state);
}
int toolLevel = stack.getItem().getHarvestLevel(stack, tool);
if (toolLevel < 0)
{
return player.canHarvestBlock(block);
return player.func_184823_b(state);
}
return toolLevel >= block.getHarvestLevel(state);
@@ -50,7 +50,7 @@ public class WorldSpecificSaveHandler implements ISaveHandler
dataDir.mkdirs();
}
File file = new File(dataDir, name + ".dat");
if (!file.exists() && name.equalsIgnoreCase("FORTRESS") && world.provider.getDimensionId() == -1) //Only copy over the fortress.dat for the vanilla nether.
if (!file.exists() && name.equalsIgnoreCase("FORTRESS") && world.provider.getDimension() == -1) //Only copy over the fortress.dat for the vanilla nether.
{
File parentFile = parent.getMapFileFromName(name);
if (parentFile.exists())
@@ -43,7 +43,7 @@ class QueuedChunk {
result.append(" z: " + z + NEW_LINE);
result.append(" loader: " + loader + NEW_LINE );
result.append(" world: " + world.getWorldInfo().getWorldName() + NEW_LINE);
result.append(" dimension: " + world.provider.getDimensionId() + NEW_LINE);
result.append(" dimension: " + world.provider.getDimension() + NEW_LINE);
result.append(" provider: " + world.provider.getClass().getName() + NEW_LINE);
result.append("}");
@@ -35,7 +35,7 @@ public class BlockSnapshot implements Serializable
public BlockSnapshot(World world, BlockPos pos, IBlockState state)
{
this.world = world;
this.dimId = world.provider.getDimensionId();
this.dimId = world.provider.getDimension();
this.pos = pos;
this.replacedBlock = state;
this.blockIdentifier = GameRegistry.findUniqueIdentifierFor(state.getBlock());
@@ -57,7 +57,7 @@ public class BlockSnapshot implements Serializable
public BlockSnapshot(World world, BlockPos pos, IBlockState state, NBTTagCompound nbt)
{
this.world = world;
this.dimId = world.provider.getDimensionId();
this.dimId = world.provider.getDimension();
this.pos = pos.getImmutable();
this.replacedBlock = state;
this.blockIdentifier = GameRegistry.findUniqueIdentifierFor(state.getBlock());
+1 -1
View File
@@ -17,7 +17,7 @@ public net.minecraft.block.Block func_149715_a(F)Lnet.minecraft.block.Block; #se
public net.minecraft.block.Block func_149722_s()Lnet.minecraft.block.Block; #setBlockUnbreakable
public net.minecraft.block.Block func_149675_a(Z)Lnet.minecraft.block.Block; #setTickRandomly
#public net.minecraft.block.Block func_149676_a(FFFFFF)V #setBlockBounds
#public net.minecraft.block.Block func_180637_b(Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;I)V # dropXpOnBlockBreak
public net.minecraft.block.Block func_180637_b(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;I)V # dropXpOnBlockBreak
# BlockFire
public net.minecraft.block.BlockFire func_176532_c(Lnet/minecraft/block/Block;)I # getFireSpreadSpeed
public net.minecraft.block.BlockFire func_176534_d(Lnet/minecraft/block/Block;)I # getFireSpreadSpeed