Fixed a crash when the Constructor tries to place a block when a multipart is attached to it, fixes #1648
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
- Fixed Disk Manipulator being stuck on unemptiable, non-empty disks (ineternet)
|
||||
- Fixed orientations of the Portable Grid (TeamSpen210)
|
||||
- Fixed crafting event in Crafting Grid being fired twice (raoulvdberge)
|
||||
- Fixed a crash when the Constructor tries to place a block when a multipart is attached to it (raoulvdberge)
|
||||
- Attempted to fix FPS drop on Grid sorting (raoulvdberge)
|
||||
- Disk Manipulator in fluid mode will now extract a bucket at a time instead of 1 mB (or 64 buckets at a time with a Stack Upgrade instead of 64 mB) (raoulvdberge)
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ import com.mojang.authlib.GameProfile;
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.SlotFilter;
|
||||
import com.raoulvdberge.refinedstorage.integration.mcmp.IntegrationMCMP;
|
||||
import com.raoulvdberge.refinedstorage.integration.mcmp.RSMCMPAddon;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
|
||||
@@ -132,8 +134,18 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
|
||||
}
|
||||
}
|
||||
|
||||
private WorldServer getWorldServer() {
|
||||
World world = this.world;
|
||||
|
||||
if (IntegrationMCMP.isLoaded()) {
|
||||
world = RSMCMPAddon.unwrapWorld(world);
|
||||
}
|
||||
|
||||
return (WorldServer) world;
|
||||
}
|
||||
|
||||
private boolean canPlace(BlockPos pos, IBlockState state) {
|
||||
BlockEvent.PlaceEvent e = new BlockEvent.PlaceEvent(new BlockSnapshot(world, pos, state), world.getBlockState(pos), FakePlayerFactory.getMinecraft((WorldServer) world), EnumHand.MAIN_HAND);
|
||||
BlockEvent.PlaceEvent e = new BlockEvent.PlaceEvent(new BlockSnapshot(world, pos, state), world.getBlockState(pos), FakePlayerFactory.getMinecraft(getWorldServer()), EnumHand.MAIN_HAND);
|
||||
|
||||
return !MinecraftForge.EVENT_BUS.post(e);
|
||||
}
|
||||
@@ -149,7 +161,7 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
|
||||
IBlockState state = SlotFilter.getBlockState(world, front, took);
|
||||
|
||||
if (state != null && world.isAirBlock(front) && state.getBlock().canPlaceBlockAt(world, front)) {
|
||||
state = state.getBlock().getStateForPlacement(world, front, getDirection(), 0.5F, 0.5F, 0.5F, took.getMetadata(), FakePlayerFactory.getMinecraft((WorldServer) world), EnumHand.MAIN_HAND);
|
||||
state = state.getBlock().getStateForPlacement(world, front, getDirection(), 0.5F, 0.5F, 0.5F, took.getMetadata(), FakePlayerFactory.getMinecraft(getWorldServer()), EnumHand.MAIN_HAND);
|
||||
|
||||
if (!canPlace(front, state)) {
|
||||
return;
|
||||
@@ -161,7 +173,7 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
|
||||
if (item.getItem() instanceof ItemBlock) {
|
||||
((ItemBlock) item.getItem()).placeBlockAt(
|
||||
took,
|
||||
FakePlayerFactory.getMinecraft((WorldServer) world),
|
||||
FakePlayerFactory.getMinecraft(getWorldServer()),
|
||||
world,
|
||||
front,
|
||||
getDirection(),
|
||||
@@ -173,7 +185,7 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
|
||||
} else {
|
||||
world.setBlockState(front, state, 1 | 2);
|
||||
|
||||
state.getBlock().onBlockPlacedBy(world, front, state, FakePlayerFactory.getMinecraft((WorldServer) world), took);
|
||||
state.getBlock().onBlockPlacedBy(world, front, state, FakePlayerFactory.getMinecraft(getWorldServer()), took);
|
||||
}
|
||||
|
||||
// From ItemBlock#onItemUse
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.raoulvdberge.refinedstorage.apiimpl.network.node;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.integration.mcmp.IntegrationMCMP;
|
||||
import com.raoulvdberge.refinedstorage.integration.mcmp.RSMCMPAddon;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
|
||||
@@ -72,6 +74,16 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
|
||||
return RS.INSTANCE.config.destructorUsage + upgrades.getEnergyUsage();
|
||||
}
|
||||
|
||||
private WorldServer getWorldServer() {
|
||||
World world = this.world;
|
||||
|
||||
if (IntegrationMCMP.isLoaded()) {
|
||||
world = RSMCMPAddon.unwrapWorld(world);
|
||||
}
|
||||
|
||||
return (WorldServer) world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
@@ -130,7 +142,7 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
|
||||
}
|
||||
}
|
||||
|
||||
BlockEvent.BreakEvent e = new BlockEvent.BreakEvent(world, front, frontBlockState, FakePlayerFactory.getMinecraft((WorldServer) world));
|
||||
BlockEvent.BreakEvent e = new BlockEvent.BreakEvent(world, front, frontBlockState, FakePlayerFactory.getMinecraft(getWorldServer()));
|
||||
|
||||
if (!MinecraftForge.EVENT_BUS.post(e)) {
|
||||
world.playEvent(null, 2001, front, Block.getStateId(frontBlockState));
|
||||
|
||||
@@ -14,6 +14,7 @@ import mcmultipart.api.ref.MCMPCapabilities;
|
||||
import mcmultipart.api.slot.EnumCenterSlot;
|
||||
import mcmultipart.block.BlockMultipartContainer;
|
||||
import mcmultipart.block.TileMultipartContainer;
|
||||
import mcmultipart.util.MCMPWorldWrapper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -23,6 +24,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
@@ -136,6 +138,14 @@ public class RSMCMPAddon implements IMCMPAddon {
|
||||
return tile;
|
||||
}
|
||||
|
||||
public static World unwrapWorld(World world) {
|
||||
if (world instanceof MCMPWorldWrapper) {
|
||||
return ((MCMPWorldWrapper) world).getActualWorld();
|
||||
}
|
||||
|
||||
return world;
|
||||
}
|
||||
|
||||
public static Block unwrapBlock(IBlockAccess world, BlockPos pos) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user