inventories
This commit is contained in:
1 parent
7b00781312
commit
ff203a0e73
2 files changed
+178
-8
No files matched your search
@@ -8,7 +8,14 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.command.arguments.BlockArgumentParser;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.AutomaticItemPlacementContext;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
@@ -19,6 +26,14 @@ import java.util.Map;
|
||||
|
||||
public class BlockValue extends Value
|
||||
{
|
||||
public static final Map<String, Direction> DIRECTION_MAP = new HashMap<String, Direction>() {{
|
||||
put("up", Direction.UP);
|
||||
put("down", Direction.DOWN);
|
||||
put("east", Direction.EAST);
|
||||
put("west", Direction.WEST);
|
||||
put("north", Direction.NORTH);
|
||||
put("south", Direction.SOUTH);
|
||||
}};
|
||||
public static final BlockValue AIR = new BlockValue(Blocks.AIR.getDefaultState(), null, BlockPos.ORIGIN);
|
||||
public static final BlockValue NULL = new BlockValue(null, null, null);
|
||||
private BlockState blockState;
|
||||
@@ -239,4 +254,111 @@ public class BlockValue extends Value
|
||||
pitch = p;
|
||||
}
|
||||
}
|
||||
|
||||
/*public enum SpecificDirection {
|
||||
UP("up",0.5, 0.0, 0.5, Direction.UP),
|
||||
|
||||
UPNORTH ("upnorth", 0.5, 0.0, 0.4, Direction.NORTH),
|
||||
UPSOUTH ("upsouth", 0.5, 0.0, 0.6, Direction.SOUTH),
|
||||
UPEAST("upeast", 0.6, 0.0, 0.5, Direction.EAST),
|
||||
UPWEST("upwest", 0.4, 0.0, 0.5, Direction.WEST),
|
||||
|
||||
DOWN("down", 0.5, 1.0, 0.5, Direction.DOWN),
|
||||
|
||||
DOWNNORTH ("downnorth", 0.5, 0.0, 0.4, Direction.NORTH),
|
||||
DOWNSOUTH ("downsouth", 0.5, 0.0, 0.6, Direction.SOUTH),
|
||||
DOWNEAST("downeast", 0.6, 0.0, 0.5, Direction.EAST),
|
||||
DOWNWEST("downwest", 0.4, 0.0, 0.5, Direction.WEST),
|
||||
|
||||
|
||||
NORTH ("north", 0.5, 0.4, 1.0, Direction.NORTH),
|
||||
SOUTH ("south", 0.5, 0.4, 0.0, Direction.SOUTH),
|
||||
EAST("east", 0.0, 0.4, 0.5, Direction.EAST),
|
||||
WEST("west", 1.0, 0.4, 0.5, Direction.WEST),
|
||||
NORTHUP ("northup", 0.5, 0.6, 1.0, Direction.NORTH),
|
||||
SOUTHUP ("southup", 0.5, 0.6, 0.0, Direction.SOUTH),
|
||||
EASTUP("eastup", 0.0, 0.6, 0.5, Direction.EAST),
|
||||
WESTUP("westup", 1.0, 0.6, 0.5, Direction.WEST),
|
||||
|
||||
|
||||
NORTHUP (),
|
||||
SOUTHUP(),
|
||||
EASTUP(),
|
||||
WESTUP();
|
||||
|
||||
private static final Direction[] ALL = values();
|
||||
private static final Map<String, Direction> NAME_MAP = (Map)Arrays.stream(ALL).collect(Collectors.toMap(Direction::getName, (direction_1) -> {
|
||||
return direction_1;
|
||||
}));
|
||||
|
||||
private SpecificDirection(String name, double hitx, double hity, double hitz, Direction blockFacing)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class PlacementContext extends ItemPlacementContext {
|
||||
private final Direction facing;
|
||||
|
||||
public static final Map<String, Direction> DIRECTION_MAP = new HashMap<String, Direction>() {{
|
||||
put("up", Direction.UP);
|
||||
put("down", Direction.DOWN);
|
||||
put("east", Direction.EAST);
|
||||
put("west", Direction.WEST);
|
||||
put("north", Direction.NORTH);
|
||||
put("south", Direction.SOUTH);
|
||||
}};
|
||||
public
|
||||
|
||||
public PlacementContext(World world_1, BlockPos blockPos_1, Direction direction_1, ItemStack itemStack_1, Direction direction_2) {
|
||||
super(world_1, (PlayerEntity)null, Hand.MAIN_HAND, itemStack_1, new BlockHitResult(new Vec3d((double)blockPos_1.getX() + 0.5D, (double)blockPos_1.getY(), (double)blockPos_1.getZ() + 0.5D), direction_2, blockPos_1, false));
|
||||
this.facing = direction_1;
|
||||
}
|
||||
|
||||
public BlockPos getBlockPos() {
|
||||
return this.hit.getBlockPos();
|
||||
}
|
||||
|
||||
public boolean canPlace() {
|
||||
return this.world.getBlockState(this.hit.getBlockPos()).canReplace(this);
|
||||
}
|
||||
|
||||
public boolean canReplaceExisting() {
|
||||
return this.canPlace();
|
||||
}
|
||||
|
||||
public Direction getPlayerLookDirection() {
|
||||
return Direction.DOWN;
|
||||
}
|
||||
|
||||
public Direction[] getPlacementDirections() {
|
||||
switch(this.facing) {
|
||||
case DOWN:
|
||||
default:
|
||||
return new Direction[]{Direction.DOWN, Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.UP};
|
||||
case UP:
|
||||
return new Direction[]{Direction.DOWN, Direction.UP, Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST};
|
||||
case NORTH:
|
||||
return new Direction[]{Direction.DOWN, Direction.NORTH, Direction.EAST, Direction.WEST, Direction.UP, Direction.SOUTH};
|
||||
case SOUTH:
|
||||
return new Direction[]{Direction.DOWN, Direction.SOUTH, Direction.EAST, Direction.WEST, Direction.UP, Direction.NORTH};
|
||||
case WEST:
|
||||
return new Direction[]{Direction.DOWN, Direction.WEST, Direction.SOUTH, Direction.UP, Direction.NORTH, Direction.EAST};
|
||||
case EAST:
|
||||
return new Direction[]{Direction.DOWN, Direction.EAST, Direction.SOUTH, Direction.UP, Direction.NORTH, Direction.WEST};
|
||||
}
|
||||
}
|
||||
|
||||
public Direction getPlayerFacing() {
|
||||
return this.facing.getAxis() == Direction.Axis.Y ? Direction.NORTH : this.facing;
|
||||
}
|
||||
|
||||
public boolean isPlayerSneaking() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public float getPlayerYaw() {
|
||||
return (float)(this.facing.getHorizontal() * 90);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
Reference in new issue
Block a user