Add whitewashed brush

This commit is contained in:
Andrew-71 2024-04-28 00:19:24 +03:00
parent 919688f44f
commit df44b84dd7
21 changed files with 287 additions and 13 deletions

View file

@ -6,12 +6,5 @@
* Concrete plate - missing
* Po-2 wall and crate...? - missing
* Rusty blue iron bars - missing
* Most wallpaper - missing
* Nutrient block - missing
* Nutrient block - missing by design
* 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

View file

@ -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())) {

View file

@ -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);
}
}

View file

@ -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());
}
}
}

View file

@ -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<ActionResult> 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);
}
}
}

View file

@ -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);

View file

@ -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");

View file

@ -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",

View file

@ -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": "Врѣмя совѣршать вѣликое!",

View file

@ -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": "Время совершать великое!",

View file

@ -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]
}
}
}

View file

@ -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",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 378 B

After

Width:  |  Height:  |  Size: 375 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 B

View file

@ -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",