将某些方块设置为可含水,添加军用小刀,添加野兽加特林音效

This commit is contained in:
Atsuihsio 2024-08-15 18:03:04 +08:00
parent 8bc9c0386a
commit 4e7119befb
17 changed files with 1356 additions and 31 deletions

View file

@ -12,12 +12,17 @@ import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
@ -26,11 +31,12 @@ import net.minecraft.world.phys.shapes.VoxelShape;
import java.util.List;
public class BarbedWireBlock extends Block {
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
public BarbedWireBlock() {
super(BlockBehaviour.Properties.of().ignitedByLava().instrument(NoteBlockInstrument.BASS).sound(SoundType.WOOD).strength(10f, 20f).noCollission().speedFactor(0.01f).noOcclusion().isRedstoneConductor((bs, br, bp) -> false));
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH));
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(WATERLOGGED, false));
}
@Override
@ -50,12 +56,18 @@ public class BarbedWireBlock extends Block {
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(FACING);
builder.add(FACING, WATERLOGGED);
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite());
boolean flag = context.getLevel().getFluidState(context.getClickedPos()).getType() == Fluids.WATER;
return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite()).setValue(WATERLOGGED, flag);
}
@Override
public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
}
public BlockState rotate(BlockState state, Rotation rot) {
@ -66,6 +78,14 @@ public class BarbedWireBlock extends Block {
return state.rotate(mirrorIn.getRotation(state.getValue(FACING)));
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor world, BlockPos currentPos, BlockPos facingPos) {
if (state.getValue(WATERLOGGED)) {
world.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
}
return super.updateShape(state, facing, facingState, world, currentPos, facingPos);
}
@Override
public void entityInside(BlockState blockstate, Level world, BlockPos pos, Entity entity) {
super.entityInside(blockstate, world, pos, entity);

View file

@ -1,13 +1,21 @@
package net.mcreator.superbwarfare.block;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.level.pathfinder.BlockPathTypes;
import net.minecraft.world.phys.shapes.CollisionContext;
@ -15,8 +23,11 @@ import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
public class DragonTeethBlock extends Block {
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public DragonTeethBlock() {
super(BlockBehaviour.Properties.of().instrument(NoteBlockInstrument.BASEDRUM).sound(SoundType.STONE).strength(25f, 500f).requiresCorrectToolForDrops().pushReaction(PushReaction.BLOCK).noOcclusion().isRedstoneConductor((bs, br, bp) -> false));
this.registerDefaultState(this.stateDefinition.any().setValue(WATERLOGGED, false));
}
@Override
@ -43,5 +54,30 @@ public class DragonTeethBlock extends Block {
public BlockPathTypes getBlockPathType(BlockState state, BlockGetter world, BlockPos pos, Mob entity) {
return BlockPathTypes.LAVA;
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(WATERLOGGED);
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
boolean flag = context.getLevel().getFluidState(context.getClickedPos()).getType() == Fluids.WATER;
return this.defaultBlockState().setValue(WATERLOGGED, flag);
}
@Override
public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor world, BlockPos currentPos, BlockPos facingPos) {
if (state.getValue(WATERLOGGED)) {
world.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
}
return super.updateShape(state, facing, facingState, world, currentPos, facingPos);
}
}

View file

@ -11,12 +11,17 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
@ -24,11 +29,12 @@ import net.minecraft.world.phys.shapes.VoxelShape;
@SuppressWarnings("deprecation")
public class JumpPadBlock extends Block {
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
public JumpPadBlock() {
super(BlockBehaviour.Properties.of().instrument(NoteBlockInstrument.BASEDRUM).sound(SoundType.STONE).strength(-1, 3600000).noCollission().noOcclusion().isRedstoneConductor((bs, br, bp) -> false));
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH));
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(WATERLOGGED, false));
}
@Override
@ -57,12 +63,18 @@ public class JumpPadBlock extends Block {
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(FACING);
builder.add(FACING, WATERLOGGED);
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite());
boolean flag = context.getLevel().getFluidState(context.getClickedPos()).getType() == Fluids.WATER;
return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite()).setValue(WATERLOGGED, flag);
}
@Override
public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
}
public BlockState rotate(BlockState state, Rotation rot) {
@ -73,6 +85,14 @@ public class JumpPadBlock extends Block {
return state.rotate(mirrorIn.getRotation(state.getValue(FACING)));
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor world, BlockPos currentPos, BlockPos facingPos) {
if (state.getValue(WATERLOGGED)) {
world.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
}
return super.updateShape(state, facing, facingState, world, currentPos, facingPos);
}
@Override
public void entityInside(BlockState blockstate, Level level, BlockPos pos, Entity entity) {
super.entityInside(blockstate, level, pos, entity);

View file

@ -14,12 +14,17 @@ import net.minecraft.world.inventory.ContainerLevelAccess;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
@ -29,12 +34,13 @@ import javax.annotation.Nullable;
@SuppressWarnings("deprecation")
public class ReforgingTableBlock extends Block {
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
private static final Component CONTAINER_TITLE = Component.translatable("container.superbwarfare.reforging_table");
public ReforgingTableBlock() {
super(BlockBehaviour.Properties.of().instrument(NoteBlockInstrument.BASEDRUM).sound(SoundType.STONE).strength(2f).lightLevel(s -> 4).hasPostProcess((bs, br, bp) -> true).emissiveRendering((bs, br, bp) -> true));
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH));
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(WATERLOGGED, false));
}
public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHit) {
@ -49,7 +55,7 @@ public class ReforgingTableBlock extends Block {
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(FACING);
builder.add(FACING, WATERLOGGED);
}
@Override
@ -70,7 +76,13 @@ public class ReforgingTableBlock extends Block {
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite());
boolean flag = context.getLevel().getFluidState(context.getClickedPos()).getType() == Fluids.WATER;
return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite()).setValue(WATERLOGGED, flag);
}
@Override
public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
}
public BlockState rotate(BlockState state, Rotation rot) {
@ -95,6 +107,15 @@ public class ReforgingTableBlock extends Block {
}
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor world, BlockPos currentPos, BlockPos facingPos) {
if (state.getValue(WATERLOGGED)) {
world.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
}
return super.updateShape(state, facing, facingState, world, currentPos, facingPos);
}
@Override
@Nullable
public MenuProvider getMenuProvider(BlockState pState, Level pLevel, BlockPos pPos) {

View file

@ -222,23 +222,22 @@ public class GunEventHandler {
SoundTool.playLocalSound(serverPlayer, ModSounds.MINIGUN_OVERHEAT.get(), 2f, 1f);
}
}
var perk = PerkHelper.getPerkByType(stack, Perk.Type.AMMO);
float pitch = tag.getDouble("heat") <= 40 ? 1 : (float) (1 - 0.025 * Math.abs(40 - tag.getDouble("heat")));
if (!player.level().isClientSide() && player instanceof ServerPlayer serverPlayer) {
if (tag.getDouble("heat") <= 40) {
SoundTool.playLocalSound(serverPlayer, ModSounds.MINIGUN_FIRE_1P.get(), 2f, 1f);
player.playSound(ModSounds.MINIGUN_FIRE_3P.get(), 4f, 1f);
player.playSound(ModSounds.MINIGUN_FAR.get(), 12f, 1f);
player.playSound(ModSounds.MINIGUN_VERYFAR.get(), 24f, 1f);
} else {
float pitch = (float) (1 - 0.025 * Math.abs(40 - tag.getDouble("heat")));
SoundTool.playLocalSound(serverPlayer, ModSounds.MINIGUN_FIRE_1P.get(), 2f, pitch);
player.playSound(ModSounds.MINIGUN_FIRE_3P.get(), 4f, pitch);
player.playSound(ModSounds.MINIGUN_FAR.get(), 12f, pitch);
player.playSound(ModSounds.MINIGUN_VERYFAR.get(), 24f, pitch);
SoundTool.playLocalSound(serverPlayer, ModSounds.MINIGUN_FIRE_1P.get(), 2f, pitch);
player.playSound(ModSounds.MINIGUN_FIRE_3P.get(), 4f, pitch);
player.playSound(ModSounds.MINIGUN_FAR.get(), 12f, pitch);
player.playSound(ModSounds.MINIGUN_VERYFAR.get(), 24f, pitch);
if (perk == ModPerks.BEAST_BULLET.get()) {
player.playSound(ModSounds.HENG.get(), 5f, pitch);
SoundTool.playLocalSound(serverPlayer, ModSounds.HENG.get(), 5f, pitch);
}
}
stack.getOrCreateTag().putBoolean("shoot", true);
for (int index0 = 0; index0 < (int) stack.getOrCreateTag().getDouble("projectile_amount"); index0++) {

View file

@ -95,6 +95,7 @@ public class ModItems {
public static final RegistryObject<Item> MONITOR = ITEMS.register("monitor", Monitor::new);
public static final RegistryObject<Item> TARGET_DEPLOYER = ITEMS.register("target_deployer", TargetDeployer::new);
public static final RegistryObject<Item> LIGHT_SABER = ITEMS.register("light_saber", LightSaber::new);
public static final RegistryObject<Item> KNIFE = ITEMS.register("knife", Knife::new);
public static final RegistryObject<Item> HAMMER = ITEMS.register("hammer", Hammer::new);
public static final RegistryObject<Item> MORTAR_DEPLOYER = ITEMS.register("mortar_deployer", MortarDeployer::new);
public static final RegistryObject<Item> MORTAR_BARREL = ITEMS.register("mortar_barrel", () -> new Item(new Item.Properties()));

View file

@ -1,16 +1,13 @@
package net.mcreator.superbwarfare.item;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.Tier;
import net.minecraft.world.item.*;
import net.minecraft.world.item.crafting.Ingredient;
public class Hammer extends SwordItem {
public Hammer() {
super(new Tier() {
public int getUses() {
return 800;
return 400;
}
public float getSpeed() {
@ -18,7 +15,7 @@ public class Hammer extends SwordItem {
}
public float getAttackDamageBonus() {
return 10f;
return 8f;
}
public int getLevel() {
@ -26,11 +23,11 @@ public class Hammer extends SwordItem {
}
public int getEnchantmentValue() {
return 14;
return 9;
}
public Ingredient getRepairIngredient() {
return Ingredient.of();
return Ingredient.of(new ItemStack(Items.IRON_INGOT));
}
}, 3, -3.2f, new Item.Properties());
}
@ -52,7 +49,7 @@ public class Hammer extends SwordItem {
@Override
public boolean isRepairable(ItemStack itemstack) {
return false;
return true;
}
}

View file

@ -0,0 +1,38 @@
package net.mcreator.superbwarfare.item;
import net.mcreator.superbwarfare.init.ModItems;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.Tier;
import net.minecraft.world.item.crafting.Ingredient;
public class Knife extends SwordItem {
public Knife() {
super(new Tier() {
public int getUses() {
return 500;
}
public float getSpeed() {
return 7f;
}
public float getAttackDamageBonus() {
return 2.5f;
}
public int getLevel() {
return 2;
}
public int getEnchantmentValue() {
return 2;
}
public Ingredient getRepairIngredient() {
return Ingredient.of(new ItemStack(ModItems.INGOT_STEEL.get()));
}
}, 3, -1.8f, new Item.Properties());
}
}

View file

@ -4,8 +4,12 @@ import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.client.renderer.item.LightSaberItemRenderer;
import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.tools.SoundTool;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes;
@ -125,4 +129,16 @@ public class LightSaber extends SwordItem implements GeoItem, AnimatedItem {
public boolean isDamageable(ItemStack stack) {
return false;
}
@Override
public boolean onEntitySwing(ItemStack itemstack, LivingEntity entity) {
boolean retval = super.onEntitySwing(itemstack, entity);
entity.playSound(ModSounds.LIGHT_SABER.get(), 1f, 1f);
if (entity instanceof ServerPlayer serverPlayer) {
SoundTool.playLocalSound(serverPlayer, ModSounds.LIGHT_SABER.get(), 1f, 1f);
}
return retval;
}
}

View file

@ -220,6 +220,16 @@ public class FireMessage {
}
}
var perk = PerkHelper.getPerkByType(stack, Perk.Type.AMMO);
if (perk == ModPerks.BEAST_BULLET.get()) {
player.playSound(ModSounds.HENG.get(), 5f, 1f);
if (player instanceof ServerPlayer serverPlayer) {
SoundTool.playLocalSound(serverPlayer, ModSounds.HENG.get(), 5f, 1f);
}
}
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoil = 0.1;
capability.firing = 1;

View file

@ -130,6 +130,7 @@
"item.superbwarfare.target_deployer": "Target",
"item.superbwarfare.senpai_spawn_egg": "Senpai Spawn Egg",
"item.superbwarfare.light_saber": "Light Saber",
"item.superbwarfare.knife": "Knife",
"item.superbwarfare.hammer": "Hammer",
"item.superbwarfare.mortar_bipod": "Mortar Bipod",
"item.superbwarfare.mortar_base_plate": "Mortar Base Plate",

View file

@ -130,6 +130,7 @@
"item.superbwarfare.target_deployer": "标靶",
"item.superbwarfare.senpai_spawn_egg": "野兽先辈刷怪蛋",
"item.superbwarfare.light_saber": "光剑",
"item.superbwarfare.knife": "军刀",
"item.superbwarfare.hammer": "大锤",
"item.superbwarfare.mortar_bipod": "迫击炮架",
"item.superbwarfare.mortar_base_plate": "迫击炮座钣",

File diff suppressed because it is too large Load diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

@ -19,6 +19,6 @@
},
"result": {
"item": "superbwarfare:high_energy_explosives",
"count": 2
"count": 1
}
}

View file

@ -0,0 +1,20 @@
{
"type": "minecraft:crafting_shaped",
"category": "equipment",
"pattern": [
" a",
"b "
],
"key": {
"a": {
"item": "superbwarfare:ingot_steel"
},
"b": {
"item": "minecraft:stick"
}
},
"result": {
"item": "superbwarfare:knife",
"count": 1
}
}

View file

@ -14,7 +14,7 @@
"item": "minecraft:beacon"
},
"c": {
"item": "minecraft:blaze_rod"
"item": "superbwarfare:tungsten_rod"
}
},
"result": {