fix keyboard model, fix upgrade stacking&serialization, fix keyboard collision shape

This commit is contained in:
GiantLuigi4 2023-06-02 23:19:13 -04:00
parent 5d3426706f
commit e2f6ac39a5
8 changed files with 17 additions and 486 deletions

View File

@ -9,7 +9,7 @@ yarn_mappings=1.19.2+build.28
loader_version=0.14.14 loader_version=0.14.14
# Mod Properties # Mod Properties
mod_version = 1.3.2 mod_version = 1.3.3
maven_group = net.montoyo.wd maven_group = net.montoyo.wd
archives_base_name = webdisplays archives_base_name = webdisplays

View File

@ -40,6 +40,13 @@ public class BlockKeyboardLeft extends BlockPeripheral {
public static final DirectionProperty FACING = DirectionProperty.create("facing", Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST); public static final DirectionProperty FACING = DirectionProperty.create("facing", Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST);
// public static final DirectionProperty HALF = DirectionProperty.create("facing", Direction.EAST, Direction.WEST); // public static final DirectionProperty HALF = DirectionProperty.create("facing", Direction.EAST, Direction.WEST);
public static final VoxelShape[] KEYBOARD_AABBS = new VoxelShape[]{
Shapes.box(0.0, 0.0, 3.0 / 16, 1.0, 1.0 / 16.0, 1.0),
Shapes.box(0.0, 0.0, 0.0, 1.0, 1.0 / 16.0, 13 / 16.0),
Shapes.box(3.0 / 16, 0.0, 0.0, 1.0, 1.0 / 16.0, 1.0),
Shapes.box(0.0, 0.0, 0.0, 13 / 16.0, 1.0 / 16.0, 1.0),
};
private static final Property<?>[] properties = new Property<?>[] {TYPE, FACING}; private static final Property<?>[] properties = new Property<?>[] {TYPE, FACING};
public BlockKeyboardLeft() { public BlockKeyboardLeft() {
@ -110,7 +117,7 @@ public class BlockKeyboardLeft extends BlockPeripheral {
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
return state.getValue(TYPE) == DefaultPeripheral.KEYBOARD ? BlockKeyboardRight.KEYBOARD_AABB : Shapes.block(); return KEYBOARD_AABBS[state.getValue(FACING).ordinal() - 2];
} }
@Override @Override

View File

@ -32,11 +32,12 @@ import net.montoyo.wd.utilities.BlockSide;
import net.montoyo.wd.utilities.Vector3i; import net.montoyo.wd.utilities.Vector3i;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import static net.montoyo.wd.block.BlockKeyboardLeft.KEYBOARD_AABBS;
// TODO: merge into KeyboardLeft // TODO: merge into KeyboardLeft
public class BlockKeyboardRight extends Block implements IPeripheral { public class BlockKeyboardRight extends Block implements IPeripheral {
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
public static final VoxelShape KEYBOARD_AABB = Shapes.box(0.0, 0.0, 0.0, 1.0, 1.0 / 16.0, 1.0);
public BlockKeyboardRight() { public BlockKeyboardRight() {
super(Properties.of(Material.STONE) super(Properties.of(Material.STONE)
@ -80,7 +81,7 @@ public class BlockKeyboardRight extends Block implements IPeripheral {
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
return KEYBOARD_AABB; return KEYBOARD_AABBS[state.getValue(FACING).ordinal() - 2];
} }
@Override @Override

View File

@ -102,7 +102,7 @@ public class BlockPeripheral extends WDBlockContainer {
@Override @Override
public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
return state.getValue(type) == DefaultPeripheral.KEYBOARD ? BlockKeyboardRight.KEYBOARD_AABB : Shapes.block(); return Shapes.block();
} }
@Override @Override

View File

@ -18,7 +18,6 @@ import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
@ -126,7 +125,7 @@ public class TileEntityScreen extends BlockEntity {
ret.upgrades = new ArrayList<>(); ret.upgrades = new ArrayList<>();
for (int i = 0; i < upgrades.size(); i++) for (int i = 0; i < upgrades.size(); i++)
ret.upgrades.add(new ItemStack((ItemLike) upgrades.getCompound(i))); ret.upgrades.add(ItemStack.of(upgrades.getCompound(i)));
if (tag.contains("AutoVolume")) if (tag.contains("AutoVolume"))
ret.autoVolume = tag.getBoolean("AutoVolume"); ret.autoVolume = tag.getBoolean("AutoVolume");

View File

@ -36,7 +36,7 @@ public class ItemUpgrade extends ItemMulti implements IUpgrade, WDItem {
@Override @Override
public boolean isSameUpgrade(@Nonnull ItemStack myStack, @Nonnull ItemStack otherStack) { public boolean isSameUpgrade(@Nonnull ItemStack myStack, @Nonnull ItemStack otherStack) {
return otherStack.getItem() == this && otherStack == myStack; return otherStack.getItem() == this;
} }
@Override @Override

View File

@ -10,7 +10,7 @@ issueTrackerURL="" #optional
modId="webdisplays" #mandatory modId="webdisplays" #mandatory
version="1.3.2" #mandatory version="1.3.3" #mandatory
displayName="WebDisplays" #mandatory displayName="WebDisplays" #mandatory

File diff suppressed because one or more lines are too long