Finished DispenserBehaviourStabilizedRS.
This commit is contained in:
parent
0077a1860d
commit
0735aa7722
1 changed files with 8 additions and 12 deletions
|
@ -5,32 +5,28 @@ import net.minecraft.block.BlockDispenser;
|
||||||
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
||||||
import net.minecraft.dispenser.IBlockSource;
|
import net.minecraft.dispenser.IBlockSource;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class DispenserBehaviorStabilizedRS extends BehaviorDefaultDispenseItem
|
public class DispenserBehaviorStabilizedRS extends BehaviorDefaultDispenseItem {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack dispenseStack(IBlockSource dispenser, ItemStack stack)
|
public ItemStack dispenseStack(IBlockSource dispenser, ItemStack stack) {
|
||||||
{
|
|
||||||
// Search for a non-air block up to 3 blocks in front of a dispenser.
|
// Search for a non-air block up to 3 blocks in front of a dispenser.
|
||||||
// If it's found, call ItemStabilizedRiftSignature.useFromDispenser().
|
// If it's found, call ItemStabilizedRiftSignature.useFromDispenser().
|
||||||
int x = dispenser.getXInt();
|
BlockPos pos = dispenser.getBlockPos();
|
||||||
int y = dispenser.getYInt();
|
int x = pos.getX(), y = pos.getY(), z = pos.getZ();
|
||||||
int z = dispenser.getZInt();
|
EnumFacing facing = BlockDispenser.getFacing(dispenser.getBlockMetadata());
|
||||||
EnumFacing facing = BlockDispenser.func_149937_b(dispenser.getBlockMetadata());
|
|
||||||
int dx = facing.getFrontOffsetX();
|
int dx = facing.getFrontOffsetX();
|
||||||
int dy = facing.getFrontOffsetY();
|
int dy = facing.getFrontOffsetY();
|
||||||
int dz = facing.getFrontOffsetZ();
|
int dz = facing.getFrontOffsetZ();
|
||||||
World world = dispenser.getWorld();
|
World world = dispenser.getWorld();
|
||||||
|
|
||||||
for (int k = 1; k <= 3; k++)
|
for (int k = 1; k <= 3; k++) {
|
||||||
{
|
|
||||||
x += dx;
|
x += dx;
|
||||||
y += dy;
|
y += dy;
|
||||||
z += dz;
|
z += dz;
|
||||||
if (!world.isAirBlock(x, y, z))
|
if (!world.isAirBlock(new BlockPos(x, y, z))) {
|
||||||
{
|
|
||||||
// Found a block. Activate the item.
|
// Found a block. Activate the item.
|
||||||
ItemStabilizedRiftSignature.useFromDispenser(stack, world, x, y, z);
|
ItemStabilizedRiftSignature.useFromDispenser(stack, world, x, y, z);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue