Initially add changes, god this will take a while

This commit is contained in:
Andrew-71 2023-08-13 22:25:32 +03:00
parent b43a0668aa
commit 0fad36a08c
272 changed files with 3438 additions and 197 deletions

View file

@ -1,6 +1,8 @@
package su.a71.new_soviet.blocks;
import net.minecraft.block.*;
import net.minecraft.particle.DustParticleEffect;
import net.minecraft.text.Text;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.fluid.FluidState;
@ -25,6 +27,7 @@ import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
import org.jetbrains.annotations.Nullable;
import su.a71.new_soviet.NewSoviet;
import su.a71.new_soviet.registration.NSE_Custom;
import su.a71.new_soviet.registration.NSE_Items;
@ -70,15 +73,28 @@ public class LightBulbBlock extends Block implements Waterloggable {
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (!world.isClient && state.get(BROKEN) && player.getInventory().getMainHandStack().getItem() == NSE_Items.LIGHT_BULB) {
if (!world.isClient && state.get(BROKEN) && player.getInventory().getMainHandStack().getItem() == NSE_Items.LIGHT_BULB && !world.isReceivingRedstonePower(pos)) {
if (!player.isCreative())
player.getInventory().getMainHandStack().decrement(1);
world.setBlockState(pos, (BlockState)state.with(BROKEN, false)
.with(ON, world.isReceivingRedstonePower(pos)), 2);
world.setBlockState(pos, (BlockState)state.with(BROKEN, false));
//.with(ON, world.isReceivingRedstonePower(pos)), 2);
} else if (!world.isClient && state.get(BROKEN) && player.getInventory().getMainHandStack().getItem() == NSE_Items.LIGHT_BULB) {
player.sendMessage(Text.translatable("block.new_soviet.light_bulb_block.energized"));
world.playSound((PlayerEntity)null, pos.getX(), pos.getY(), pos.getZ(), NSE_Custom.ELECTRIC_HIT, SoundCategory.AMBIENT, 0.8f, 1f);
if (!player.isCreative()) {
player.heal(-1 * NewSoviet.RANDOM.nextBetween(1, 4));
}
if (NewSoviet.RANDOM.nextBetween(1, 32) == 1){
if (!player.isCreative())
player.getInventory().getMainHandStack().decrement(1);
world.setBlockState(pos, (BlockState)state.with(BROKEN, false)
.with(ON, world.isReceivingRedstonePower(pos)), 2);
}
}
return super.onUse(state, world, pos, player, hand, hit);
}
@Override
public void onProjectileHit(World world, BlockState state, BlockHitResult hit, ProjectileEntity projectile) {
if (!state.get(BROKEN)) {