Lightbulb and fixes

This commit is contained in:
Andrew-71 2023-08-06 17:37:19 +03:00
parent ea5af6ca06
commit d99e8fd54c
16 changed files with 338 additions and 10 deletions

37
LICENSE Normal file
View file

@ -0,0 +1,37 @@
The following directory, it's subdirectories, and any files inside said directories or subdirectories are subject to
the license below.
The only exceptions are files in /src/main/resources/assets/new_soviet/sounds, see relevant LICENSE file there
/src/main/resources/
All Rights Reserved
Copyright (c) 2023 Andrey Nikitin and Рюжин Юрий.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
All other files within this repository are subject to the license below.
MIT License
Copyright (c) 2023 Andrey Nikitin.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

7
TODO
View file

@ -1,21 +1,20 @@
=== ADD BLOCKS/FEATURES ===
* Add brown+white+yellow+red+green blocks
* Add brown+yellow+red+green blocks
* Add slab and stair variations
* Add doors and fences
* Add windows
* Add (with functionality) present appliance/furniture/electronics textures
* Figure out what to do with "NII wall", nii floor, tilled block
* Add achievement criterion for dice
* Add achievement criterion for dice and advancements
=== FIX STUFF ===
* PO2 wall
* Replace a ton of stuff with FabricBlockSettings.copy and resistance+hardness -> strength
* Crate (likely cheap shulker box with small capacity)
=== NON-GAME CHANGES ===
* Minotaur publishing to modrinth and something similar for curse
* git.a71.su maven
* Good README.md and icon, assets, screenshots etc.
* mkDocs for recipes and more
=== ACHIEVEMENTS ===
Kolkhoz warrior - kill a zombie, skeleton, creeper and spider with a sickle

View file

@ -0,0 +1,90 @@
package su.a71.new_soviet.blocks;
import net.minecraft.block.*;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.state.property.Property;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.random.Random;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
import org.jetbrains.annotations.Nullable;
import su.a71.new_soviet.registration.NSE_Custom;
public class LightBulbBlock extends Block {
protected static final VoxelShape SHAPE;
public static final BooleanProperty ON;
public static final BooleanProperty BROKEN;
public LightBulbBlock(Block.Settings settings) {
super(settings);
this.setDefaultState((BlockState)this.getDefaultState().with(ON, false).with(BROKEN, false));
}
@Nullable
public BlockState getPlacementState(ItemPlacementContext ctx) {
return (BlockState)this.getDefaultState().with(ON, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos())).with(BROKEN, false);
}
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) {
if (!world.isClient) {
boolean bl = (Boolean)state.get(ON);
if (bl != world.isReceivingRedstonePower(pos)) {
if (bl) {
world.scheduleBlockTick(pos, this, 4);
} else {
world.setBlockState(pos, (BlockState)state.cycle(ON), 2);
}
}
}
}
@Override
public void onProjectileHit(World world, BlockState state, BlockHitResult hit, ProjectileEntity projectile) {
if (!state.get(BROKEN)) {
world.playSound((PlayerEntity)null, hit.getBlockPos().getX(), hit.getBlockPos().getY(), hit.getBlockPos().getZ(), NSE_Custom.LIGHT_BULB_BROKEN_SOUND, SoundCategory.NEUTRAL, 0.8f, 1f);
}
world.setBlockState(hit.getBlockPos(), (BlockState)state.with(BROKEN, true).with(ON, false), 2);
super.onProjectileHit(world, state, hit, projectile);
}
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
if ((Boolean)state.get(ON) && !world.isReceivingRedstonePower(pos)) {
world.setBlockState(pos, (BlockState)state.cycle(ON), 2);
}
}
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(new Property[]{ON, BROKEN});
}
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
if (state.get(BROKEN)) {
return SHAPE;
}
return VoxelShapes.union(SHAPE, Block.createCuboidShape(7, 3, 7, 10, 6, 10).offset(-0.03125, 0, -0.03125));
}
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
Direction direction = Direction.UP;
return Block.sideCoversSmallSquare(world, pos.offset(direction), direction.getOpposite());
}
static {
SHAPE = VoxelShapes.union(Block.createCuboidShape(7, 15, 7, 9, 16, 9), Block.createCuboidShape(7, 6, 7, 9, 8, 9)); //VoxelShapes.union(Block.createCuboidShape(4.0, 2.0, 4.0, 12.0, 7.0, 12.0), Block.createCuboidShape(7.0, 7.0, 7.0, 9.0, 13.0, 9.0), Block.createCuboidShape(6.0, 13.0, 6.0, 10.0, 16.0, 10.0));
ON = RedstoneTorchBlock.LIT;
BROKEN = Properties.CRACKED;
}
}

View file

@ -20,7 +20,6 @@ import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
import su.a71.new_soviet.NewSoviet;
import su.a71.new_soviet.registration.NSE_Custom;
public class SirenBlock extends HorizontalFacingBlock {
@ -81,13 +80,9 @@ public class SirenBlock extends HorizontalFacingBlock {
}
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
NewSoviet.LOG.info("Scheduled tick");
if ((Boolean)state.get(ON) && !world.isReceivingRedstonePower(pos)) {
world.setBlockState(pos, (BlockState)state.cycle(ON), 2);
NewSoviet.LOG.info("Stopping!");
} else {
NewSoviet.LOG.info("Playing!");
world.playSound((PlayerEntity)null, pos.getX(), pos.getY(), pos.getZ(), NSE_Custom.SIREN_SOUND, SoundCategory.NEUTRAL, getSirenVolume(world, pos), 1f);
world.scheduleBlockTick(pos, this, 140);
}

View file

@ -29,6 +29,9 @@ public class NSE_Custom {
public static final TVBlock BROWN_TV = new TVBlock(FabricBlockSettings.create().mapColor(MapColor.TERRACOTTA_BROWN));
public static final RadioBlock RADIO = new RadioBlock();
public static final LampBlock LAMP = new LampBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.LANTERN).strength(1f, 1.5f).mapColor(MapColor.WHITE));
public static final LightBulbBlock LIGHT_BULB = new LightBulbBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.LANTERN).strength(1f, 1.5f).mapColor(MapColor.WHITE));
public static final SoundEvent LIGHT_BULB_BROKEN_SOUND = SoundEvent.of(new Identifier("new_soviet", "light_bulb_broken_sound"));
public static final CeilingFanBlock CEILING_FAN = new CeilingFanBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).strength(1f, 1.5f).mapColor(MapColor.WHITE));
public static final SirenBlock SIREN = new SirenBlock();
@ -58,9 +61,11 @@ public class NSE_Custom {
register("brown_tv", () -> BROWN_TV, NSE_CUSTOM_TAB);
register("radio", () -> RADIO, NSE_CUSTOM_TAB);
register("lamp", () -> LAMP, NSE_CUSTOM_TAB);
register("light_bulb", () -> LIGHT_BULB, NSE_CUSTOM_TAB);
register("ceiling_fan", () -> CEILING_FAN, NSE_CUSTOM_TAB);
register("siren", () -> SIREN, NSE_CUSTOM_TAB);
Registry.register(Registries.SOUND_EVENT, new Identifier("new_soviet", "siren_sound"), SIREN_SOUND);
Registry.register(Registries.SOUND_EVENT, new Identifier("new_soviet", "light_bulb_broken_sound"), LIGHT_BULB_BROKEN_SOUND);
}
}

View file

@ -0,0 +1,16 @@
{
"variants": {
"lit=true,cracked=true": {
"model": "new_soviet:block/light_bulb_broken"
},
"lit=true,cracked=false": {
"model": "new_soviet:block/light_bulb_on"
},
"lit=false,cracked=false": {
"model": "new_soviet:block/light_bulb_off"
},
"lit=false,cracked=true": {
"model": "new_soviet:block/light_bulb_broken"
}
}
}

View file

@ -148,5 +148,7 @@
"block.new_soviet.white_concrete_with_bars": "White Concrete With Bars",
"block.new_soviet.green_concrete_with_bars": "Green Concrete With Bars",
"block.new_soviet.blue_concrete_with_bars": "Blue Concrete With Bars",
"block.new_soviet.red_concrete_with_bars": "Red Concrete With Bars"
"block.new_soviet.red_concrete_with_bars": "Red Concrete With Bars",
"subtitles.new_soviet.light_bulb_broken": "Light bulb breaks",
"block.new_soviet.light_bulb": "Light Bulb"
}

View file

@ -0,0 +1,84 @@
{
"credit": "Made by Feulim (karoter2)",
"textures": {
"0": "new_soviet:block/custom/furniture/light_bulb_off",
"particle": "new_soviet:block/custom/furniture/light_bulb_off"
},
"elements": [
{
"from": [7, 6, 7],
"to": [9, 8, 9],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]},
"faces": {
"north": {"uv": [7, 0, 5, 2], "texture": "#0"},
"east": {"uv": [5, 0, 7, 2], "texture": "#0"},
"south": {"uv": [7, 0, 5, 2], "texture": "#0"},
"west": {"uv": [5, 0, 7, 2], "texture": "#0"},
"up": {"uv": [7, 4, 5, 2], "texture": "#0"},
"down": {"uv": [16, 14, 14, 16], "texture": "#0"}
}
},
{
"from": [8, 5, 7.5],
"to": [8, 16, 8.5],
"rotation": {"angle": -45, "axis": "y", "origin": [8, 0, 8]},
"faces": {
"north": {"uv": [0, 0, 0, 11], "texture": "#0"},
"east": {"uv": [0, 0, 1, 11], "texture": "#0"},
"south": {"uv": [0, 0, 0, 11], "texture": "#0"},
"west": {"uv": [0, 0, 1, 11], "texture": "#0"},
"up": {"uv": [0, 0, 0, 1], "texture": "#0"},
"down": {"uv": [0, 0, 0, 1], "texture": "#0"}
}
},
{
"from": [8, 5, 7.5],
"to": [8, 16, 8.5],
"rotation": {"angle": 45, "axis": "y", "origin": [8, 0, 8]},
"faces": {
"north": {"uv": [0, 0, 0, 11], "texture": "#0"},
"east": {"uv": [1, 0, 2, 11], "texture": "#0"},
"south": {"uv": [0, 0, 0, 11], "texture": "#0"},
"west": {"uv": [1, 0, 2, 11], "texture": "#0"},
"up": {"uv": [0, 1, 0, 0], "texture": "#0"},
"down": {"uv": [0, 0, 0, 1], "texture": "#0"}
}
},
{
"from": [7, 15.5, 7],
"to": [9, 16.5, 9],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]},
"faces": {
"north": {"uv": [9, 0, 7, 1], "texture": "#0"},
"east": {"uv": [7, 0, 9, 1], "texture": "#0"},
"south": {"uv": [9, 0, 7, 1], "texture": "#0"},
"west": {"uv": [7, 0, 9, 1], "texture": "#0"},
"up": {"uv": [16, 16, 14, 14], "texture": "#0"},
"down": {"uv": [5, 9, 3, 11], "texture": "#0"}
}
},
{
"name": "cube_outline",
"from": [9, 8, 9],
"to": [7, 6, 7],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]},
"faces": {
"north": {"uv": [7, 0, 5, 2], "rotation": 180, "texture": "#0"},
"east": {"uv": [5, 0, 7, 2], "rotation": 180, "texture": "#0"},
"south": {"uv": [7, 0, 5, 2], "rotation": 180, "texture": "#0"},
"west": {"uv": [5, 0, 7, 2], "rotation": 180, "texture": "#0"},
"up": {"uv": [16, 14, 14, 16], "rotation": 180, "texture": "#0"},
"down": {"uv": [7, 4, 5, 2], "rotation": 180, "texture": "#0"}
}
}
],
"groups": [
{
"name": "group",
"origin": [16, 8, 16],
"color": 0,
"nbt": "{}",
"children": [0, 1, 2, 3, 4]
}
]
}

View file

@ -0,0 +1,7 @@
{
"parent": "new_soviet:block/light_bulb_on",
"textures": {
"0": "new_soviet:block/custom/furniture/light_bulb_off",
"particle": "new_soviet:block/custom/furniture/light_bulb_off"
}
}

View file

@ -0,0 +1,83 @@
{
"credit": "Made by Feulim (karoter2)",
"textures": {
"0": "new_soviet:block/custom/furniture/light_bulb_on",
"particle": "new_soviet:block/custom/furniture/light_bulb_on"
},
"elements": [
{
"from": [6.5, 3, 6.5],
"to": [9.5, 6, 9.5],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]},
"faces": {
"north": {"uv": [2, 3, 5, 0], "texture": "#0"},
"east": {"uv": [2, 3, 5, 0], "texture": "#0"},
"south": {"uv": [2, 3, 5, 0], "texture": "#0"},
"west": {"uv": [2, 3, 5, 0], "texture": "#0"},
"up": {"uv": [5, 6, 2, 3], "texture": "#0"},
"down": {"uv": [5, 6, 2, 9], "texture": "#0"}
}
},
{
"from": [7, 6, 7],
"to": [9, 8, 9],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]},
"faces": {
"north": {"uv": [7, 0, 5, 2], "texture": "#0"},
"east": {"uv": [5, 0, 7, 2], "texture": "#0"},
"south": {"uv": [7, 0, 5, 2], "texture": "#0"},
"west": {"uv": [5, 0, 7, 2], "texture": "#0"},
"up": {"uv": [7, 4, 5, 2], "texture": "#0"},
"down": {"uv": [16, 14, 14, 16], "texture": "#0"}
}
},
{
"from": [8, 5, 7.5],
"to": [8, 16, 8.5],
"rotation": {"angle": -45, "axis": "y", "origin": [8, 0, 8]},
"faces": {
"north": {"uv": [0, 0, 0, 11], "texture": "#0"},
"east": {"uv": [0, 0, 1, 11], "texture": "#0"},
"south": {"uv": [0, 0, 0, 11], "texture": "#0"},
"west": {"uv": [0, 0, 1, 11], "texture": "#0"},
"up": {"uv": [0, 0, 0, 1], "texture": "#0"},
"down": {"uv": [0, 0, 0, 1], "texture": "#0"}
}
},
{
"from": [8, 5, 7.5],
"to": [8, 16, 8.5],
"rotation": {"angle": 45, "axis": "y", "origin": [8, 0, 8]},
"faces": {
"north": {"uv": [0, 0, 0, 11], "texture": "#0"},
"east": {"uv": [1, 0, 2, 11], "texture": "#0"},
"south": {"uv": [0, 0, 0, 11], "texture": "#0"},
"west": {"uv": [1, 0, 2, 11], "texture": "#0"},
"up": {"uv": [0, 1, 0, 0], "texture": "#0"},
"down": {"uv": [0, 0, 0, 1], "texture": "#0"}
}
},
{
"from": [7, 15.5, 7],
"to": [9, 16.5, 9],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]},
"faces": {
"north": {"uv": [9, 0, 7, 1], "texture": "#0"},
"east": {"uv": [7, 0, 9, 1], "texture": "#0"},
"south": {"uv": [9, 0, 7, 1], "texture": "#0"},
"west": {"uv": [7, 0, 9, 1], "texture": "#0"},
"up": {"uv": [16, 16, 14, 14], "texture": "#0"},
"down": {"uv": [5, 9, 3, 11], "texture": "#0"}
}
}
],
"groups": [
{
"name": "group",
"origin": [16, 8, 16],
"color": 0,
"nbt": "{}",
"children": [0, 1, 2, 3, 4]
}
]
}

View file

@ -0,0 +1,3 @@
{
"parent": "new_soviet:block/light_bulb_off"
}

View file

@ -10,6 +10,12 @@
"sounds": [
"new_soviet:siren"
]
},
"light_bulb_broken_sound": {
"subtitle": "subtitles.new_soviet.light_bulb_broken",
"sounds": [
"new_soviet:light_bulb_broken"
]
}
}

View file

@ -0,0 +1 @@
File light_bulb_broken.ogg is converted .mp3 file made by Mike Koenig, which is licensed under CC Attribution 3.0 (https://creativecommons.org/licenses/by/3.0/). Original file is available at https://soundbible.com/105-Light-Bulb-Breaking.html

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B