God, please let this be last non-pull request contribution
This commit is contained in:
parent
38446def2e
commit
82df488245
275 changed files with 13578 additions and 79 deletions
|
@ -2,12 +2,18 @@ package su.a71.new_soviet.blocks;
|
|||
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.piston.PistonBehavior;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.AirBlockItem;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
|
@ -25,16 +31,17 @@ import su.a71.new_soviet.util.Shapes;
|
|||
public class WMachineBlock extends HorizontalFacingBlock {
|
||||
|
||||
private final Shapes.HorizontalShape blockShape;
|
||||
public static final BooleanProperty PAPER = BooleanProperty.of("paper");
|
||||
|
||||
public WMachineBlock(Settings settings, Shapes.HorizontalShape blockShape) {
|
||||
super(settings.notSolid().nonOpaque().noBlockBreakParticles().pistonBehavior(PistonBehavior.DESTROY).strength(0.1f, 2f));
|
||||
setDefaultState(getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH));
|
||||
setDefaultState(getDefaultState().with(PAPER, false).with(Properties.HORIZONTAL_FACING, Direction.NORTH));
|
||||
this.blockShape = blockShape;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
builder.add(Properties.HORIZONTAL_FACING);
|
||||
builder.add(Properties.HORIZONTAL_FACING, PAPER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,15 +57,30 @@ public class WMachineBlock extends HorizontalFacingBlock {
|
|||
|
||||
@Override
|
||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||
float pitch = (float) NewSoviet.RANDOM.nextBetween(8, 12) / 10;
|
||||
float volume = (float) NewSoviet.RANDOM.nextBetween(5, 7) / 10;
|
||||
world.playSound(null, pos, NSE_Sounds.W_MACHINE_BUTTON_PRESS, SoundCategory.BLOCKS, volume, pitch);
|
||||
if (state.get(PAPER) && player.isSneaking() && player.getInventory().getMainHandStack().getItem() == Blocks.AIR.asItem()) {
|
||||
player.equipStack(EquipmentSlot.MAINHAND, new ItemStack(Items.PAPER));
|
||||
BlockState updatedBlockState = state
|
||||
.with(PAPER, false);
|
||||
world.setBlockState(pos, updatedBlockState);
|
||||
}
|
||||
else if ((!state.get(PAPER) && player.getInventory().getMainHandStack().getItem() == Items.PAPER)) {
|
||||
if (!player.isCreative())
|
||||
player.getInventory().getMainHandStack().decrement(1);
|
||||
BlockState updatedBlockState = state
|
||||
.with(PAPER, true);
|
||||
world.setBlockState(pos, updatedBlockState);
|
||||
}
|
||||
else {
|
||||
float pitch = (float) NewSoviet.RANDOM.nextBetween(8, 12) / 10;
|
||||
float volume = (float) NewSoviet.RANDOM.nextBetween(5, 7) / 10;
|
||||
world.playSound(null, pos, NSE_Sounds.W_MACHINE_BUTTON_PRESS, SoundCategory.BLOCKS, volume, pitch);
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||
return super.getPlacementState(ctx).with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite());
|
||||
return super.getPlacementState(ctx).with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite()).with(PAPER, false);
|
||||
}
|
||||
|
||||
protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package su.a71.new_soviet.blocks;
|
|||
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.enums.DoorHinge;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||
|
@ -404,4 +405,13 @@ public class WindowBlock extends HorizontalFacingBlock {
|
|||
FRAME_SHAPE_LEFT = new Shapes.HorizontalShape(List.of(List.of(14.0, 0.0, 13.0, 16.0, 16.0, 15.99)));
|
||||
PANE_FRAME_SHAPE = new Shapes.HorizontalShape(List.of(List.of(2.0, 7.0, 13.5, 14.0, 8.0, 15.5)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendTooltip(ItemStack stack, @Nullable BlockView world, List<Text> tooltip, TooltipContext options) {
|
||||
boolean broken = stack.getOrCreateNbt().getBoolean("broken");
|
||||
if (broken) {
|
||||
tooltip.add(Text.translatable("item.new_soviet.window.tooltip"));
|
||||
super.appendTooltip(stack, world, tooltip, options);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package su.a71.new_soviet.blocks.lamps;
|
||||
|
||||
import su.a71.new_soviet.util.Shapes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DevTableLampBlock extends GoldenTableLampBlock {
|
||||
|
||||
public DevTableLampBlock(Settings settings) {
|
||||
super(settings);
|
||||
SHAPE = new Shapes.HorizontalShapeLegacy(List.of(
|
||||
List.of(5.0, 0.0, 5.0, 11.0, 2.0, 11.0),
|
||||
List.of(7.0, 2.0, 7.0, 9.0, 4.0, 9.0),
|
||||
List.of(6.0, 4.0, 6.0, 10.0, 5.0, 10.0),
|
||||
List.of(3.0, 9.0, 3.0, 13.0, 13.0, 7.0)));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue