Keep TVs broken in item form
This commit is contained in:
parent
60c43b93da
commit
0f7b1616e1
8 changed files with 33 additions and 64 deletions
|
@ -1,20 +0,0 @@
|
||||||
{
|
|
||||||
"type": "minecraft:block",
|
|
||||||
"pools": [
|
|
||||||
{
|
|
||||||
"bonus_rolls": 0.0,
|
|
||||||
"conditions": [
|
|
||||||
{
|
|
||||||
"condition": "minecraft:survives_explosion"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"entries": [
|
|
||||||
{
|
|
||||||
"type": "minecraft:item",
|
|
||||||
"name": "new_soviet:brown_tv"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"rolls": 1.0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
{
|
|
||||||
"type": "minecraft:block",
|
|
||||||
"pools": [
|
|
||||||
{
|
|
||||||
"bonus_rolls": 0.0,
|
|
||||||
"conditions": [
|
|
||||||
{
|
|
||||||
"condition": "minecraft:survives_explosion"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"entries": [
|
|
||||||
{
|
|
||||||
"type": "minecraft:item",
|
|
||||||
"name": "new_soviet:red_tv"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"rolls": 1.0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
{
|
|
||||||
"type": "minecraft:block",
|
|
||||||
"pools": [
|
|
||||||
{
|
|
||||||
"bonus_rolls": 0.0,
|
|
||||||
"conditions": [
|
|
||||||
{
|
|
||||||
"condition": "minecraft:survives_explosion"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"entries": [
|
|
||||||
{
|
|
||||||
"type": "minecraft:item",
|
|
||||||
"name": "new_soviet:tv"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"rolls": 1.0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -3,11 +3,14 @@ package su.a71.new_soviet.blocks;
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.block.piston.PistonBehavior;
|
import net.minecraft.block.piston.PistonBehavior;
|
||||||
|
import net.minecraft.client.item.TooltipContext;
|
||||||
|
import net.minecraft.entity.ItemEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.projectile.ProjectileEntity;
|
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||||
import net.minecraft.fluid.FluidState;
|
import net.minecraft.fluid.FluidState;
|
||||||
import net.minecraft.fluid.Fluids;
|
import net.minecraft.fluid.Fluids;
|
||||||
import net.minecraft.item.ItemPlacementContext;
|
import net.minecraft.item.ItemPlacementContext;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.sound.BlockSoundGroup;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sound.SoundCategory;
|
||||||
|
@ -15,7 +18,9 @@ import net.minecraft.sound.SoundEvents;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.state.StateManager;
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
import net.minecraft.state.property.Properties;
|
import net.minecraft.state.property.Properties;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
|
import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -27,6 +32,7 @@ import net.minecraft.world.BlockView;
|
||||||
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.WorldAccess;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import su.a71.new_soviet.entities.TVBlockEntity;
|
import su.a71.new_soviet.entities.TVBlockEntity;
|
||||||
import su.a71.new_soviet.registration.NSE_Sounds;
|
import su.a71.new_soviet.registration.NSE_Sounds;
|
||||||
import su.a71.new_soviet.util.Shapes;
|
import su.a71.new_soviet.util.Shapes;
|
||||||
|
@ -78,12 +84,13 @@ public class TVBlock extends HorizontalFacingBlock implements BlockEntityProvide
|
||||||
@Override
|
@Override
|
||||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||||
FluidState fluidState = ctx.getWorld().getFluidState(ctx.getBlockPos());
|
FluidState fluidState = ctx.getWorld().getFluidState(ctx.getBlockPos());
|
||||||
|
boolean broken = ctx.getStack().getOrCreateNbt().getBoolean("broken");
|
||||||
return super.getPlacementState(ctx)
|
return super.getPlacementState(ctx)
|
||||||
.with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite())
|
.with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite())
|
||||||
.with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER)
|
.with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER)
|
||||||
.with(ON, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos()))
|
.with(ON, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos()))
|
||||||
.with(INVERTED, false)
|
.with(INVERTED, false)
|
||||||
.with(BROKEN, false);
|
.with(BROKEN, broken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -152,6 +159,28 @@ public class TVBlock extends HorizontalFacingBlock implements BlockEntityProvide
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
|
||||||
|
this.spawnBreakParticles(world, player, pos, state);
|
||||||
|
if (!world.isClient && !player.isCreative()) {
|
||||||
|
super.onBreak(world, pos, state, player);
|
||||||
|
|
||||||
|
ItemStack itemStack = new ItemStack(this);
|
||||||
|
itemStack.getOrCreateNbt().putBoolean("broken", state.get(BROKEN));
|
||||||
|
|
||||||
|
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), itemStack));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void appendTooltip(ItemStack stack, @Nullable BlockView world, List<Text> tooltip, TooltipContext options) {
|
||||||
|
if (stack.getOrCreateNbt().getBoolean("broken")) {
|
||||||
|
tooltip.add(Text.translatable("block.new_soviet.tv.broken").formatted(Formatting.ITALIC, Formatting.GRAY));
|
||||||
|
}
|
||||||
|
|
||||||
|
super.appendTooltip(stack, world, tooltip, options);
|
||||||
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
SHAPE = new Shapes.HorizontalShapeLegacy(List.of(
|
SHAPE = new Shapes.HorizontalShapeLegacy(List.of(
|
||||||
List.of(0.0, 0.0, 2.0, 16.0, 13.0, 13.0),
|
List.of(0.0, 0.0, 2.0, 16.0, 13.0, 13.0),
|
||||||
|
|
|
@ -317,9 +317,6 @@ public class BlockLootTables extends FabricBlockLootTableProvider {
|
||||||
addDrop(NSE_Custom.BLACK_BISHOP);
|
addDrop(NSE_Custom.BLACK_BISHOP);
|
||||||
addDrop(NSE_Custom.BLACK_ROOK);
|
addDrop(NSE_Custom.BLACK_ROOK);
|
||||||
|
|
||||||
addDrop(NSE_Custom.TV);
|
|
||||||
addDrop(NSE_Custom.RED_TV);
|
|
||||||
addDrop(NSE_Custom.BROWN_TV);
|
|
||||||
addDrop(NSE_Custom.RADIO_RECEIVER);
|
addDrop(NSE_Custom.RADIO_RECEIVER);
|
||||||
addDrop(NSE_Custom.SIREN);
|
addDrop(NSE_Custom.SIREN);
|
||||||
addDrop(NSE_Custom.TABLE_LAMP);
|
addDrop(NSE_Custom.TABLE_LAMP);
|
||||||
|
|
|
@ -150,6 +150,7 @@
|
||||||
"block.new_soviet.red_tv": "Red TV",
|
"block.new_soviet.red_tv": "Red TV",
|
||||||
"block.new_soviet.brown_tv": "Brown TV",
|
"block.new_soviet.brown_tv": "Brown TV",
|
||||||
"block.new_soviet.green_tv": "Green TV",
|
"block.new_soviet.green_tv": "Green TV",
|
||||||
|
"block.new_soviet.tv.broken": "Broken",
|
||||||
"block.new_soviet.radio_receiver": "Radio",
|
"block.new_soviet.radio_receiver": "Radio",
|
||||||
"block.new_soviet.table_lamp": "Table Lamp",
|
"block.new_soviet.table_lamp": "Table Lamp",
|
||||||
"block.new_soviet.ceiling_fan": "Ceiling Fan",
|
"block.new_soviet.ceiling_fan": "Ceiling Fan",
|
||||||
|
|
|
@ -150,6 +150,7 @@
|
||||||
"block.new_soviet.red_tv": "Червонный тѣлѣвизоръ «Рѣкордъ В-312»",
|
"block.new_soviet.red_tv": "Червонный тѣлѣвизоръ «Рѣкордъ В-312»",
|
||||||
"block.new_soviet.brown_tv": "Корiчнѣвый тѣлѣвизоръ «Рѣкордъ В-312»",
|
"block.new_soviet.brown_tv": "Корiчнѣвый тѣлѣвизоръ «Рѣкордъ В-312»",
|
||||||
"block.new_soviet.green_tv": "Зѣлёный тѣлѣвизоръ «Рѣкордъ В-312»",
|
"block.new_soviet.green_tv": "Зѣлёный тѣлѣвизоръ «Рѣкордъ В-312»",
|
||||||
|
"block.new_soviet.tv.broken": "Сломанъ",
|
||||||
"block.new_soviet.radio_receiver": "Радiопрiямнiкъ «Альпинiст»",
|
"block.new_soviet.radio_receiver": "Радiопрiямнiкъ «Альпинiст»",
|
||||||
"block.new_soviet.table_lamp": "Настольныя лампа",
|
"block.new_soviet.table_lamp": "Настольныя лампа",
|
||||||
"block.new_soviet.ceiling_fan": "Потолочный вѣнтилятор",
|
"block.new_soviet.ceiling_fan": "Потолочный вѣнтилятор",
|
||||||
|
|
|
@ -150,6 +150,7 @@
|
||||||
"block.new_soviet.red_tv": "Красный телевизор «Рекорд В-312»",
|
"block.new_soviet.red_tv": "Красный телевизор «Рекорд В-312»",
|
||||||
"block.new_soviet.brown_tv": "Коричневый телевизор «Рекорд В-312»",
|
"block.new_soviet.brown_tv": "Коричневый телевизор «Рекорд В-312»",
|
||||||
"block.new_soviet.green_tv": "Зелёный телевизор «Рекорд В-312»",
|
"block.new_soviet.green_tv": "Зелёный телевизор «Рекорд В-312»",
|
||||||
|
"block.new_soviet.tv.broken": "Сломан",
|
||||||
"block.new_soviet.radio_receiver": "Радиоприёмник «Альпинист»",
|
"block.new_soviet.radio_receiver": "Радиоприёмник «Альпинист»",
|
||||||
"block.new_soviet.table_lamp": "Настольная лампа",
|
"block.new_soviet.table_lamp": "Настольная лампа",
|
||||||
"block.new_soviet.ceiling_fan": "Потолочный вентилятор",
|
"block.new_soviet.ceiling_fan": "Потолочный вентилятор",
|
||||||
|
|
Loading…
Reference in a new issue