mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-19 03:49:33 +00:00
fixed drawer being ghost block when broken
This commit is contained in:
1 parent
a5070f8ed8
commit
c47aa7dfe1
3 files changed
+31
-22
No files matched your search
+1
-19
@@ -396,27 +396,9 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe
|
||||
downgraded = state;
|
||||
}
|
||||
|
||||
public void onClick(BlockDrawers block, EntityPlayer player, int x, int y, int z, int face, World world) {
|
||||
public void onClick(BlockDrawers block, EntityPlayer player, int x, int y, int z, int face, World world, float hitX, float hitY, float hitZ, boolean invertShift) {
|
||||
int dir = getDirection();
|
||||
if (dir == face) {
|
||||
final int reach = 5;
|
||||
double eyeX = player.posX;
|
||||
double eyeY = player.posY + player.getEyeHeight();
|
||||
double eyeZ = player.posZ;
|
||||
|
||||
Vec3 look = player.getLookVec();
|
||||
|
||||
Vec3 end = Vec3.createVectorHelper(
|
||||
eyeX + look.xCoord * reach,
|
||||
eyeY + look.yCoord * reach,
|
||||
eyeZ + look.zCoord * reach);
|
||||
|
||||
MovingObjectPosition mop = world.rayTraceBlocks(Vec3.createVectorHelper(eyeX, eyeY, eyeZ), end);
|
||||
float hitX = (float) (mop.hitVec.xCoord - mop.blockX);
|
||||
float hitY = (float) (mop.hitVec.yCoord - mop.blockY);
|
||||
float hitZ = (float) (mop.hitVec.zCoord - mop.blockZ);
|
||||
boolean invertShift = StorageDrawers.config.cache.invertShift;
|
||||
|
||||
int slot = block.getDrawerSlot(face, hitX, hitY, hitZ);
|
||||
IDrawer drawer = getDrawer(slot);
|
||||
if (drawer == null) return;
|
||||
|
||||
@@ -11,10 +11,15 @@ public class ForgeEventHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void playerInteracts(PlayerInteractEvent event) {
|
||||
if (event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK) {
|
||||
if (event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK
|
||||
&& event.entityPlayer.capabilities.isCreativeMode) {
|
||||
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
|
||||
if (tile instanceof TileEntityDrawers) {
|
||||
event.setCanceled(true);
|
||||
int dir = ((TileEntityDrawers) tile).getDirection();
|
||||
if (dir == event.face) {
|
||||
event.setCanceled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+23
-1
@@ -1,8 +1,12 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.mixins.early;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.network.BlockClickMessage;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -27,7 +31,25 @@ public abstract class MixinPlayerControllerMP {
|
||||
if (mc.theWorld.getTileEntity(x, y, z) instanceof TileEntityDrawers ted
|
||||
&& mc.theWorld.getBlock(x, y, z) instanceof BlockDrawers bd) {
|
||||
if (ted.getDirection() == side) {
|
||||
ted.onClick(bd, mc.thePlayer, x, y, z, side, mc.theWorld);
|
||||
final int reach = 5;
|
||||
double eyeX = mc.thePlayer.posX;
|
||||
double eyeY = mc.thePlayer.posY + mc.thePlayer.getEyeHeight();
|
||||
double eyeZ = mc.thePlayer.posZ;
|
||||
|
||||
Vec3 look = mc.thePlayer.getLookVec();
|
||||
|
||||
Vec3 end = Vec3.createVectorHelper(
|
||||
eyeX + look.xCoord * reach,
|
||||
eyeY + look.yCoord * reach,
|
||||
eyeZ + look.zCoord * reach);
|
||||
|
||||
MovingObjectPosition mop = mc.theWorld.rayTraceBlocks(Vec3.createVectorHelper(eyeX, eyeY, eyeZ), end);
|
||||
float hitX = (float) (mop.hitVec.xCoord - mop.blockX);
|
||||
float hitY = (float) (mop.hitVec.yCoord - mop.blockY);
|
||||
float hitZ = (float) (mop.hitVec.zCoord - mop.blockZ);
|
||||
boolean invertShift=StorageDrawers.config.cache.invertShift;
|
||||
StorageDrawers.network.sendToServer(new BlockClickMessage(x,y,z,side,hitX,hitY,hitZ,invertShift));
|
||||
ted.onClick(bd, mc.thePlayer, x, y, z, side, mc.theWorld, hitX, hitY, hitZ,invertShift);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user