mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
Placers can now place Redstone
This commit is contained in:
parent
a961870cac
commit
732da75c9f
2 changed files with 18 additions and 11 deletions
|
@ -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;
|
||||||
|
|
|
@ -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,23 +138,29 @@ 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);
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
catch(Exception e){
|
catch(Exception e){
|
||||||
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;
|
||||||
|
|
Loading…
Reference in a new issue