diff --git a/TODO.md b/TODO.md index d6c2a35..f827560 100644 --- a/TODO.md +++ b/TODO.md @@ -6,12 +6,5 @@ * Concrete plate - missing * Po-2 wall and crate...? - missing * Rusty blue iron bars - missing -* Most wallpaper - missing -* Nutrient block - missing -* Chess & Checkers figurines - missing -#### Whitewash -Works like rake -* Concrete block -> Whitewash/slightly cracked -* Whitewash fixed by layer -* Birch door into whitewash birch door -* Any window into whitewash window \ No newline at end of file +* Nutrient block - missing by design +* Chess & Checkers figurines - missing \ No newline at end of file diff --git a/src/main/java/su/a71/new_soviet/blocks/WindowBlock.java b/src/main/java/su/a71/new_soviet/blocks/WindowBlock.java index 0a5a073..b07f07c 100644 --- a/src/main/java/su/a71/new_soviet/blocks/WindowBlock.java +++ b/src/main/java/su/a71/new_soviet/blocks/WindowBlock.java @@ -71,6 +71,10 @@ public class WindowBlock extends HorizontalFacingBlock { builder.add(Properties.HORIZONTAL_FACING, WINDOW_TYPE, Properties.CRACKED, WATERLOGGED, HINGE, BROKEN_GLASS_TYPE, CLOSED); } + public boolean getPane() { + return this.pane; + } + public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { if (state.get(BROKEN)) { if (player.getInventory().getMainHandStack().getItem() == Blocks.GLASS_PANE.asItem() && !player.getItemCooldownManager().isCoolingDown(Blocks.GLASS_PANE.asItem())) { diff --git a/src/main/java/su/a71/new_soviet/items/WhitewashedBrushItem.java b/src/main/java/su/a71/new_soviet/items/WhitewashedBrushItem.java new file mode 100644 index 0000000..874a4eb --- /dev/null +++ b/src/main/java/su/a71/new_soviet/items/WhitewashedBrushItem.java @@ -0,0 +1,146 @@ +package su.a71.new_soviet.items; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.DoorBlock; +import net.minecraft.block.HorizontalFacingBlock; +import net.minecraft.block.enums.DoorHinge; +import net.minecraft.block.enums.DoubleBlockHalf; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.*; +import net.minecraft.sound.SoundCategory; +import net.minecraft.stat.Stats; +import net.minecraft.util.ActionResult; +import net.minecraft.util.UseAction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.world.World; +import su.a71.new_soviet.NewSoviet; +import su.a71.new_soviet.blocks.WindowBlock; +import su.a71.new_soviet.registration.NSE_Blocks; +import su.a71.new_soviet.registration.NSE_Sounds; + +public class WhitewashedBrushItem extends Item { + + public WhitewashedBrushItem(Settings settings) { + super(settings); + } + + public UseAction getUseAction(ItemStack stack) { + return UseAction.BRUSH; + } + + public void remove_whitewash(PlayerEntity player) { + player.getItemCooldownManager().set(this, 5); + player.incrementStat(Stats.USED.getOrCreateStat(this)); + if (!player.isCreative()) { + player.getInventory().setStack(player.getInventory().selectedSlot, Items.BRUSH.getDefaultStack()); + } + } + + public void particles(World world, BlockPos pos) { + world.addBlockBreakParticles(pos, NSE_Blocks.WHITEWASH.getDefaultState()); + } + + public void paint_sound(World world, BlockPos pos, Entity entity) { + world.playSound(entity, pos, NSE_Sounds.BRUSH_PAINTING_SOUND, SoundCategory.PLAYERS, 1, (float) NewSoviet.RANDOM.nextBetween(8, 12) / 10f); + } + + @Override + public ActionResult useOnBlock(ItemUsageContext context) { + World world = context.getWorld(); + BlockPos pos = context.getBlockPos(); + BlockState state = world.getBlockState(pos); + Block block = state.getBlock(); + PlayerEntity player = context.getPlayer(); + + if (block == NSE_Blocks.CONCRETE) { + if (NewSoviet.RANDOM.nextBetween(1, 4) != 4) { + world.setBlockState(pos, NSE_Blocks.WHITEWASH.getDefaultState()); + } else { + world.setBlockState(pos, NSE_Blocks.CRACKED_WHITEWASH.getDefaultState()); + } + particles(world, pos); + paint_sound(world, pos, player); + remove_whitewash(player); + return ActionResult.SUCCESS; + } + if (block == NSE_Blocks.CRACKED_WHITEWASH) { + world.setBlockState(pos, NSE_Blocks.WHITEWASH.getDefaultState()); + particles(world, pos); + paint_sound(world, pos, player); + remove_whitewash(player); + return ActionResult.SUCCESS; + } + if (block == NSE_Blocks.VERY_CRACKED_WHITEWASH) { + if (NewSoviet.RANDOM.nextBetween(1, 4) != 4) { + world.setBlockState(pos, NSE_Blocks.CRACKED_WHITEWASH.getDefaultState()); + } else { + world.setBlockState(pos, NSE_Blocks.WHITEWASH.getDefaultState()); + } + particles(world, pos); + paint_sound(world, pos, player); + remove_whitewash(player); + return ActionResult.SUCCESS; + } + + if (block instanceof WindowBlock) { + int window_type = world.getBlockState(pos).get(WindowBlock.WINDOW_TYPE); + boolean broken = world.getBlockState(pos).get(WindowBlock.BROKEN); + Direction facing = world.getBlockState(pos).get(HorizontalFacingBlock.FACING); + boolean closed = world.getBlockState(pos).get(WindowBlock.CLOSED); + int broken_glass_type = world.getBlockState(pos).get(WindowBlock.BROKEN_GLASS_TYPE); + boolean waterlogged = world.getBlockState(pos).get(WindowBlock.WATERLOGGED); + DoorHinge hinge = world.getBlockState(pos).get(WindowBlock.HINGE); + WindowBlock windowBlock = (WindowBlock) block; + boolean pane = windowBlock.getPane(); + BlockState newWindowState = NSE_Blocks.WHITEWASHED_WINDOW.getDefaultState(); + if (pane) { + newWindowState = NSE_Blocks.WHITEWASHED_PANE_WINDOW.getDefaultState(); + } + world.setBlockState(pos, newWindowState.with(WindowBlock.WINDOW_TYPE, window_type) + .with(WindowBlock.BROKEN, broken) + .with(HorizontalFacingBlock.FACING, facing) + .with(WindowBlock.CLOSED, closed) + .with(WindowBlock.BROKEN_GLASS_TYPE, broken_glass_type) + .with(WindowBlock.WATERLOGGED, waterlogged) + .with(WindowBlock.HINGE, hinge)); + particles(world, pos); + paint_sound(world, pos, player); + remove_whitewash(player); + return ActionResult.SUCCESS; + } + + if (block == NSE_Blocks.CHISELED_BIRCH_DOOR) { + DoubleBlockHalf half = world.getBlockState(pos).get(DoorBlock.HALF); + BlockPos pos1 = pos; + BlockPos pos2 = pos.up(); + if (half == DoubleBlockHalf.UPPER) { + pos1 = pos.down(); + pos2 = pos; + } + boolean open = world.getBlockState(pos).get(DoorBlock.OPEN); + Direction facing = world.getBlockState(pos).get(DoorBlock.FACING); + boolean powered = world.getBlockState(pos).get(DoorBlock.POWERED); + DoorHinge hinge = world.getBlockState(pos).get(DoorBlock.HINGE); + BlockState door_state = NSE_Blocks.WHITE_CHISELED_BIRCH_DOOR.getDefaultState() + .with(DoorBlock.POWERED, powered) + .with(DoorBlock.FACING, facing) + .with(DoorBlock.OPEN, open) + .with(DoorBlock.HINGE, hinge); + world.removeBlock(pos1, false); + world.removeBlock(pos2, true); + + world.setBlockState(pos1, door_state.with(DoorBlock.HALF, DoubleBlockHalf.LOWER)); + world.setBlockState(pos2, door_state.with(DoorBlock.HALF, DoubleBlockHalf.UPPER)); + world.setBlockState(pos1, door_state.with(DoorBlock.HALF, DoubleBlockHalf.LOWER)); + paint_sound(world, pos, player); + remove_whitewash(player); + return ActionResult.SUCCESS; + } + return super.useOnBlock(context); + + } +} + diff --git a/src/main/java/su/a71/new_soviet/items/WhitewashedItem.java b/src/main/java/su/a71/new_soviet/items/WhitewashedItem.java new file mode 100644 index 0000000..1b808b5 --- /dev/null +++ b/src/main/java/su/a71/new_soviet/items/WhitewashedItem.java @@ -0,0 +1,28 @@ +package su.a71.new_soviet.items; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.*; +import net.minecraft.world.World; + +public class WhitewashedItem extends Item { + + public WhitewashedItem(Item.Settings settings) { + super(settings.maxDamageIfAbsent(610)); + } + + public int getSlot(int info) { + if (info < 0) { + return 40; + } + return info; + } + + @Override + public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) { + if (stack.getDamage() >= 600 && entity.isPlayer()) { + PlayerEntity user = (PlayerEntity) entity; + user.getInventory().setStack(getSlot(user.getInventory().getSlotWithStack(stack)), Items.BUCKET.getDefaultStack()); + } + } +} \ No newline at end of file diff --git a/src/main/java/su/a71/new_soviet/mixin/BrushMixin.java b/src/main/java/su/a71/new_soviet/mixin/BrushMixin.java new file mode 100644 index 0000000..2f0afe2 --- /dev/null +++ b/src/main/java/su/a71/new_soviet/mixin/BrushMixin.java @@ -0,0 +1,36 @@ +package su.a71.new_soviet.mixin; + +import net.minecraft.block.AbstractBlock; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.*; +import net.minecraft.sound.SoundCategory; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import net.minecraft.util.math.BlockPos; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import su.a71.new_soviet.NewSoviet; +import su.a71.new_soviet.registration.NSE_Items; +import su.a71.new_soviet.registration.NSE_Sounds; + +@Mixin(BrushItem.class) +public class BrushMixin { + protected BrushMixin(AbstractBlock.Settings settings) { + super(); + } + + @Inject(method = "useOnBlock", at = @At("HEAD")) + private void use(ItemUsageContext context, CallbackInfoReturnable cir) { + Hand hand = context.getHand(); + PlayerEntity user = context.getPlayer(); + if (user.getOffHandStack().getItem() == NSE_Items.WHITEWASH_ITEM) { + user.getInventory().setStack(user.getInventory().selectedSlot, NSE_Items.WHITEWASHED_BRUSH.getDefaultStack()); + user.getOffHandStack().damage(100, user, (p) -> { + p.sendToolBreakStatus(hand); + }); + context.getWorld().playSound(user, BlockPos.ofFloored(user.getPos()), NSE_Sounds.BRUSH_DIPPING_SOUND, SoundCategory.PLAYERS, 1, (float) NewSoviet.RANDOM.nextBetween(8, 11) / 10f); + } + } +} diff --git a/src/main/java/su/a71/new_soviet/registration/NSE_Items.java b/src/main/java/su/a71/new_soviet/registration/NSE_Items.java index 5a0621b..e70b0c9 100644 --- a/src/main/java/su/a71/new_soviet/registration/NSE_Items.java +++ b/src/main/java/su/a71/new_soviet/registration/NSE_Items.java @@ -10,9 +10,7 @@ import net.minecraft.text.Text; import net.minecraft.util.Identifier; import net.minecraft.util.Rarity; -import su.a71.new_soviet.items.CigaretteItem; -import su.a71.new_soviet.items.DiceItem; -import su.a71.new_soviet.items.RakeItem; +import su.a71.new_soviet.items.*; public class NSE_Items extends NSE_BaseRegistration { // Like an iron axe but a hoe and slightly faster (-2.8f vs -3.1f) and a bit weaker (6 vs 6.5 damage) @@ -22,7 +20,8 @@ public class NSE_Items extends NSE_BaseRegistration { // Actually works on wood public static final Item SCREWDRIVER = new Item(new Item.Settings()); - public static final Item WHITEWASH_ITEM = new Item(new Item.Settings()); + public static final WhitewashedItem WHITEWASH_ITEM = new WhitewashedItem(new Item.Settings()); + public static final WhitewashedBrushItem WHITEWASHED_BRUSH = new WhitewashedBrushItem(new Item.Settings().maxCount(1)); public static final FoodComponent CONCENTRATE_FC = (new FoodComponent.Builder()).hunger(5).saturationModifier(1.0F).alwaysEdible().build(); public static final Item CONCENTRATE = new Item(new Item.Settings().food(CONCENTRATE_FC)); @@ -66,6 +65,7 @@ public class NSE_Items extends NSE_BaseRegistration { registerItem("antenna", () -> ANTENNA, NSE_ITEMS_TAB); registerItem("screwdriver", () -> SCREWDRIVER, NSE_ITEMS_TAB); registerItem("whitewash_item", () -> WHITEWASH_ITEM, NSE_ITEMS_TAB); + registerItem("whitewashed_brush", () -> WHITEWASHED_BRUSH, null); registerItem("makhorka", ()-> MAKHORKA, NSE_ITEMS_TAB); registerItem("cigarette", ()-> CIGARETTE, NSE_ITEMS_TAB); registerItem("duchess_cigarette", ()-> DUCHESS_CIGARETTE, NSE_ITEMS_TAB); diff --git a/src/main/java/su/a71/new_soviet/registration/NSE_Sounds.java b/src/main/java/su/a71/new_soviet/registration/NSE_Sounds.java index 31a6d85..11edcf6 100644 --- a/src/main/java/su/a71/new_soviet/registration/NSE_Sounds.java +++ b/src/main/java/su/a71/new_soviet/registration/NSE_Sounds.java @@ -8,6 +8,10 @@ import su.a71.new_soviet.NewSoviet; public class NSE_Sounds extends NSE_BaseRegistration { public static SoundEvent DICE_SOUND = registerSoundEvent("dice_sound"); + public static SoundEvent BRUSH_DIPPING_SOUND = registerSoundEvent("brush_dipping"); + + public static SoundEvent BRUSH_PAINTING_SOUND = registerSoundEvent("brush_painting"); + public static SoundEvent TYPEWRITER_BUTTON_PRESS = registerSoundEvent("typewriter_button_press_sound"); public static SoundEvent SCREWDRIVER_SOUND = registerSoundEvent("screwdriver_sound"); diff --git a/src/main/resources/assets/new_soviet/lang/en_us.json b/src/main/resources/assets/new_soviet/lang/en_us.json index 49f843e..e42ee53 100644 --- a/src/main/resources/assets/new_soviet/lang/en_us.json +++ b/src/main/resources/assets/new_soviet/lang/en_us.json @@ -646,6 +646,8 @@ "subtitles.new_soviet.tv_on": "TV turned on", "subtitles.new_soviet.tv_off": "TV turned off", "subtitles.new_soviet.tv_break": "TV screen shattered", + "item.new_soviet.whitewash_item": "Whitewash Bucket", + "item.new_soviet.whitewashed_brush": "Whitewashed Brush", "item.new_soviet.antenna": "Antenna", "item.new_soviet.screwdriver": "Screwdriver", "item.new_soviet.sickle_pattern": "Banner Pattern", diff --git a/src/main/resources/assets/new_soviet/lang/rpr.json b/src/main/resources/assets/new_soviet/lang/rpr.json index 7abe7ea..aa5c84e 100644 --- a/src/main/resources/assets/new_soviet/lang/rpr.json +++ b/src/main/resources/assets/new_soviet/lang/rpr.json @@ -625,8 +625,16 @@ "subtitles.new_soviet.tv_on": "Включается тѣлѣвизоръ", "subtitles.new_soviet.tv_off": "Выключается тѣлѣвизоръ", "subtitles.new_soviet.tv_break": "Разбитъ экранъ тѣлѣвизора", + "item.new_soviet.whitewash_item": "Вѣдро побѣлки", + "item.new_soviet.whitewashed_brush": "Побѣлённыя кисть", "item.new_soviet.antenna": "Антенна", "item.new_soviet.screwdriver": "Отвѣртка", + "item.new_soviet.sickle_pattern": "Узоръ флага", + "item.new_soviet.sickle_pattern.desc": "Сѣрпъ и молот", + "item.new_soviet.star_pattern": "Узоръ флага", + "item.new_soviet.star_pattern.desc": "Звѣзда", + "item.new_soviet.grain_pattern": "Узоръ флага", + "item.new_soviet.grain_pattern.desc": "Вѣнки", "advancement.new_soviet.root.name": "Новыя эра!", "advancement.new_soviet.root.desc": "Врѣмя совѣршать вѣликое!", diff --git a/src/main/resources/assets/new_soviet/lang/ru_ru.json b/src/main/resources/assets/new_soviet/lang/ru_ru.json index 1bfc925..031d1ae 100644 --- a/src/main/resources/assets/new_soviet/lang/ru_ru.json +++ b/src/main/resources/assets/new_soviet/lang/ru_ru.json @@ -646,8 +646,16 @@ "subtitles.new_soviet.tv_on": "Включается телевизор", "subtitles.new_soviet.tv_off": "Выключается телевизор", "subtitles.new_soviet.tv_break": "Разбит экран телевизора", + "item.new_soviet.whitewash_item": "Ведро побелки", + "item.new_soviet.whitewashed_brush": "Побелённая кисть", "item.new_soviet.antenna": "Антенна", "item.new_soviet.screwdriver": "Отвертка", + "item.new_soviet.sickle_pattern": "Узор флага", + "item.new_soviet.sickle_pattern.desc": "Серп и молот", + "item.new_soviet.star_pattern": "Узор флага", + "item.new_soviet.star_pattern.desc": "Звезда", + "item.new_soviet.grain_pattern": "Узор флага", + "item.new_soviet.grain_pattern.desc": "Венки", "advancement.new_soviet.root.name": "Новая эра!", "advancement.new_soviet.root.desc": "Время совершать великое!", diff --git a/src/main/resources/assets/new_soviet/models/item/whitewashed_brush.json b/src/main/resources/assets/new_soviet/models/item/whitewashed_brush.json new file mode 100644 index 0000000..56b9f1e --- /dev/null +++ b/src/main/resources/assets/new_soviet/models/item/whitewashed_brush.json @@ -0,0 +1,28 @@ +{ + "credit": "Made with Blockbench", + "parent": "item/generated", + "textures": { + "layer0": "new_soviet:item/whitewashed_brush" + }, + "overrides": [ + {"predicate": {"brushing": 0.25}, "model": "item/brush_brushing_0"}, + {"predicate": {"brushing": 0.5}, "model": "item/brush_brushing_1"}, + {"predicate": {"brushing": 0.75}, "model": "item/brush_brushing_2"} + ], + "display": { + "thirdperson_righthand": { + "rotation": [0, 0, 45], + "translation": [0, 4, 0], + "scale": [0.9, 0.9, 0.9] + }, + "thirdperson_lefthand": { + "rotation": [0, 0, -45], + "translation": [0, 4, 0], + "scale": [0.9, 0.9, 0.9] + }, + "firstperson_lefthand": { + "rotation": [55, -85, 0], + "translation": [8, 0.5, -5.5] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/new_soviet/sounds.json b/src/main/resources/assets/new_soviet/sounds.json index fd9a33a..0e90995 100644 --- a/src/main/resources/assets/new_soviet/sounds.json +++ b/src/main/resources/assets/new_soviet/sounds.json @@ -51,6 +51,20 @@ "new_soviet:electric_hit" ] }, + "brush_dipping": { + "sounds": [ + "new_soviet:brush/dipping1", + "new_soviet:brush/dipping2", + "new_soviet:brush/dipping3", + "new_soviet:brush/dipping4" + ] + }, + "brush_painting": { + "sounds": [ + "new_soviet:brush/painting1", + "new_soviet:brush/painting2" + ] + }, "parquet_step": { "sounds": [ "new_soviet:parquet/parquet_step1", diff --git a/src/main/resources/assets/new_soviet/sounds/brush/dipping1.ogg b/src/main/resources/assets/new_soviet/sounds/brush/dipping1.ogg new file mode 100644 index 0000000..6ef4077 Binary files /dev/null and b/src/main/resources/assets/new_soviet/sounds/brush/dipping1.ogg differ diff --git a/src/main/resources/assets/new_soviet/sounds/brush/dipping2.ogg b/src/main/resources/assets/new_soviet/sounds/brush/dipping2.ogg new file mode 100644 index 0000000..6d43d4e Binary files /dev/null and b/src/main/resources/assets/new_soviet/sounds/brush/dipping2.ogg differ diff --git a/src/main/resources/assets/new_soviet/sounds/brush/dipping3.ogg b/src/main/resources/assets/new_soviet/sounds/brush/dipping3.ogg new file mode 100644 index 0000000..277dd76 Binary files /dev/null and b/src/main/resources/assets/new_soviet/sounds/brush/dipping3.ogg differ diff --git a/src/main/resources/assets/new_soviet/sounds/brush/dipping4.ogg b/src/main/resources/assets/new_soviet/sounds/brush/dipping4.ogg new file mode 100644 index 0000000..23f86e9 Binary files /dev/null and b/src/main/resources/assets/new_soviet/sounds/brush/dipping4.ogg differ diff --git a/src/main/resources/assets/new_soviet/sounds/brush/painting1.ogg b/src/main/resources/assets/new_soviet/sounds/brush/painting1.ogg new file mode 100644 index 0000000..3b4fb2b Binary files /dev/null and b/src/main/resources/assets/new_soviet/sounds/brush/painting1.ogg differ diff --git a/src/main/resources/assets/new_soviet/sounds/brush/painting2.ogg b/src/main/resources/assets/new_soviet/sounds/brush/painting2.ogg new file mode 100644 index 0000000..3968872 Binary files /dev/null and b/src/main/resources/assets/new_soviet/sounds/brush/painting2.ogg differ diff --git a/src/main/resources/assets/new_soviet/textures/item/whitewash.png b/src/main/resources/assets/new_soviet/textures/item/whitewash.png index a265776..fadafa0 100644 Binary files a/src/main/resources/assets/new_soviet/textures/item/whitewash.png and b/src/main/resources/assets/new_soviet/textures/item/whitewash.png differ diff --git a/src/main/resources/assets/new_soviet/textures/item/whitewashed_brush.png b/src/main/resources/assets/new_soviet/textures/item/whitewashed_brush.png new file mode 100644 index 0000000..3f28dbb Binary files /dev/null and b/src/main/resources/assets/new_soviet/textures/item/whitewashed_brush.png differ diff --git a/src/main/resources/new_soviet.mixins.json b/src/main/resources/new_soviet.mixins.json index 9ac47e1..e781f0b 100644 --- a/src/main/resources/new_soviet.mixins.json +++ b/src/main/resources/new_soviet.mixins.json @@ -4,6 +4,9 @@ "package": "su.a71.new_soviet.mixin", "refmap": "client-new_soviet-refmap.json", "compatibilityLevel": "JAVA_17", + "mixins": [ + "BrushMixin" + ], "client": [ "client.ItemRendererAccessor", "client.ItemRendererMixin",