Eternal Crystal item & model

This commit is contained in:
Aleksey 2020-11-21 23:29:45 +03:00
parent 7192df49d1
commit 3b31532fea
10 changed files with 225 additions and 19 deletions

View file

@ -8,6 +8,7 @@ public class BlockProperties {
public static final EnumProperty<TripleShape> TRIPLE_SHAPE = EnumProperty.of("shape", TripleShape.class);
public final static EnumProperty<PedestalState> PEDESTAL_STATE = EnumProperty.of("state", PedestalState.class);
public static final BooleanProperty HAS_ITEM = BooleanProperty.of("has_item");
public static final BooleanProperty HAS_LIGHT = BooleanProperty.of("has_light");
public static final BooleanProperty ACTIVATED = BooleanProperty.of("active");
public static enum TripleShape implements StringIdentifiable {

View file

@ -46,6 +46,7 @@ import ru.betterend.util.BlocksHelper;
public class BlockPedestal extends BlockBaseNotFull implements BlockEntityProvider {
public final static EnumProperty<PedestalState> STATE = BlockProperties.PEDESTAL_STATE;
public static final BooleanProperty HAS_ITEM = BlockProperties.HAS_ITEM;
public static final BooleanProperty HAS_LIGHT = BlockProperties.HAS_LIGHT;
private static final VoxelShape SHAPE_DEFAULT;
private static final VoxelShape SHAPE_COLUMN;
@ -82,8 +83,10 @@ public class BlockPedestal extends BlockBaseNotFull implements BlockEntityProvid
protected float height = 1.0F;
public BlockPedestal(Block parent) {
super(FabricBlockSettings.copyOf(parent));
this.setDefaultState(stateManager.getDefaultState().with(STATE, PedestalState.DEFAULT).with(HAS_ITEM, false));
super(FabricBlockSettings.copyOf(parent).luminance(state -> {
return state.get(HAS_LIGHT) ? 12 : 0;
}));
this.setDefaultState(stateManager.getDefaultState().with(STATE, PedestalState.DEFAULT).with(HAS_ITEM, false).with(HAS_LIGHT, false));
this.parent = parent;
}
@ -294,7 +297,7 @@ public class BlockPedestal extends BlockBaseNotFull implements BlockEntityProvid
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(STATE, HAS_ITEM);
stateManager.add(STATE, HAS_ITEM, HAS_LIGHT);
}
@Override

View file

@ -12,6 +12,7 @@ import net.minecraft.util.Tickable;
import net.minecraft.world.World;
import ru.betterend.blocks.basis.BlockPedestal;
import ru.betterend.registry.EndBlockEntities;
import ru.betterend.registry.EndItems;
public class PedestalBlockEntity extends BlockEntity implements Inventory, Tickable {
private ItemStack activeItem = ItemStack.EMPTY;
@ -70,7 +71,8 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka
}
public void removeStack(World world, BlockState state) {
world.setBlockState(pos, state.with(BlockPedestal.HAS_ITEM, false));
world.setBlockState(pos, state.with(BlockPedestal.HAS_ITEM, false)
.with(BlockPedestal.HAS_LIGHT, false));
this.removeStack(0);
}
@ -82,6 +84,11 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka
public void setStack(World world, BlockState state, ItemStack stack) {
world.setBlockState(pos, state.with(BlockPedestal.HAS_ITEM, true));
if (stack.getItem() == EndItems.ETERNAL_CRYSTAL) {
world.setBlockState(pos, state.with(BlockPedestal.HAS_LIGHT, true));
} else {
world.setBlockState(pos, state.with(BlockPedestal.HAS_LIGHT, false));
}
this.setStack(0, stack);
}

View file

@ -19,6 +19,7 @@ import net.minecraft.item.Items;
import net.minecraft.util.DyeColor;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import ru.betterend.blocks.EternalPedestal;
import ru.betterend.blocks.basis.BlockPedestal;
import ru.betterend.blocks.entities.PedestalBlockEntity;