Placers can now place Redstone

This commit is contained in:
Ellpeck 2015-12-23 23:09:50 +01:00
parent a961870cac
commit 732da75c9f
2 changed files with 18 additions and 11 deletions

View file

@ -29,7 +29,7 @@ public class FakePlayerUtil{
public static FakePlayer getFakePlayer(World world){ public static FakePlayer getFakePlayer(World world){
if(world instanceof WorldServer){ if(world instanceof WorldServer){
if(theFakePlayer == null){ if(theFakePlayer == null || theFakePlayer.worldObj != world){
theFakePlayer = new FakePlayer((WorldServer)world, FAKE_PROFILE); theFakePlayer = new FakePlayer((WorldServer)world, FAKE_PROFILE);
} }
return theFakePlayer; return theFakePlayer;

View file

@ -20,6 +20,7 @@ import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -137,16 +138,21 @@ public class WorldUtil{
} }
} }
//Redstone
else if(stack.getItem() == Items.redstone){
world.setBlock(x+side.offsetX, y+side.offsetY, z+side.offsetZ, Blocks.redstone_wire);
stack.stackSize--;
}
//Plants //Plants
if(stack.getItem() instanceof IPlantable){ else if(stack.getItem() instanceof IPlantable){
if(((IPlantable)stack.getItem()).getPlant(world, x, y, z).canPlaceBlockAt(world, x+side.offsetX, y+side.offsetY, z+side.offsetZ)){ if(((IPlantable)stack.getItem()).getPlant(world, x, y, z).canPlaceBlockAt(world, x+side.offsetX, y+side.offsetY, z+side.offsetZ)){
if(world.setBlock(x+side.offsetX, y+side.offsetY, z+side.offsetZ, ((IPlantable)stack.getItem()).getPlant(world, x, y, z))){ if(world.setBlock(x+side.offsetX, y+side.offsetY, z+side.offsetZ, ((IPlantable)stack.getItem()).getPlant(world, x, y, z))){
stack.stackSize--; stack.stackSize--;
return stack;
} }
} }
} }
else{
try{ try{
//Blocks //Blocks
stack.tryPlaceItemIntoWorld(FakePlayerUtil.getFakePlayer(world), world, x, y, z, side == ForgeDirection.UNKNOWN ? 0 : side.ordinal(), 0, 0, 0); stack.tryPlaceItemIntoWorld(FakePlayerUtil.getFakePlayer(world), world, x, y, z, side == ForgeDirection.UNKNOWN ? 0 : side.ordinal(), 0, 0, 0);
@ -156,6 +162,7 @@ public class WorldUtil{
ModUtil.LOGGER.error("Something that places Blocks at "+x+", "+y+", "+z+" in World "+world.provider.dimensionId+" threw an Exception! Don't let that happen again!"); ModUtil.LOGGER.error("Something that places Blocks at "+x+", "+y+", "+z+" in World "+world.provider.dimensionId+" threw an Exception! Don't let that happen again!");
} }
} }
}
return stack; return stack;
} }