Skip to content

Commit

Permalink
修改合成器配方
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhuRuoLing committed Sep 28, 2024
1 parent 0e487f4 commit 6fe8137
Show file tree
Hide file tree
Showing 3 changed files with 2,562 additions and 2,554 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
"category": "equipment",
"key": {
"A": {
"item": "minecraft:iron_ingot"
"item": "minecraft:glass"
},
"B": {
"item": "minecraft:crafting_table"
},
"C": {
"item": "minecraft:dropper"
"item": "minecraft:crafter"
},
"D": {
"item": "anvilcraft:magnetoelectric_core"
Expand All @@ -20,7 +17,7 @@
},
"pattern": [
"ABA",
"ADC",
"ADA",
"AEA"
],
"result": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public FallingSpectralBlockEntity(EntityType<? extends FallingSpectralBlockEntit
* @param isGhostEntity 是否为分身
*/
private FallingSpectralBlockEntity(
Level level, double x, double y, double z, BlockState state, boolean isGhostEntity) {
Level level, double x, double y, double z, BlockState state, boolean isGhostEntity) {
this(ModEntities.FALLING_SPECTRAL_BLOCK.get(), level);
this.blockState = state;
this.blocksBuilding = true;
Expand All @@ -63,7 +63,8 @@ private FallingSpectralBlockEntity(
}

@Override
public void callOnBrokenAfterFall(@NotNull Block block, @NotNull BlockPos pos) {}
public void callOnBrokenAfterFall(@NotNull Block block, @NotNull BlockPos pos) {
}

@Override
public void tick() {
Expand All @@ -80,6 +81,9 @@ public void tick() {
BlockPos current = this.blockPosition();
BlockPos below = current.below();
BlockState blockStateDown = this.level().getBlockState(below);
if (current.getY() < -160) {
discard();
}
if (!shouldIgnoreBlockInMovement(blockStateDown)) {
this.discard();
if (!isGhostEntity) {
Expand All @@ -91,16 +95,24 @@ public void tick() {
return;
}
level().playSound(
this,
below,
SoundEvents.ANVIL_LAND,
SoundSource.BLOCKS,
SoundType.ANVIL.volume,
SoundType.ANVIL.pitch);
this,
below,
SoundEvents.ANVIL_LAND,
SoundSource.BLOCKS,
SoundType.ANVIL.volume,
SoundType.ANVIL.pitch
);
Predicate<Entity> predicate =
EntitySelector.NO_CREATIVE_OR_SPECTATOR.and(EntitySelector.LIVING_ENTITY_STILL_ALIVE);
level().getEntitiesOfClass(LivingEntity.class, new AABB(current), predicate)
.forEach(it -> it.hurt(level().damageSources().anvil(this), Math.min(40f, fallDistance * 2)));
EntitySelector.NO_CREATIVE_OR_SPECTATOR.and(EntitySelector.LIVING_ENTITY_STILL_ALIVE);
level().getEntitiesOfClass(
LivingEntity.class,
new AABB(current),
predicate
).forEach(it -> it.hurt(
level().damageSources().anvil(this),
Math.min(40f, fallDistance * 2)
)
);
AnvilCraft.EVENT_BUS.post(new AnvilFallOnLandEvent(level(), current, this, fallDistance));
}
this.setDeltaMovement(this.getDeltaMovement().scale(0.98));
Expand Down Expand Up @@ -129,7 +141,7 @@ public boolean causeFallDamage(float fallDistance, float multiplier, DamageSourc
return false;
}
Predicate<Entity> predicate =
EntitySelector.NO_CREATIVE_OR_SPECTATOR.and(EntitySelector.LIVING_ENTITY_STILL_ALIVE);
EntitySelector.NO_CREATIVE_OR_SPECTATOR.and(EntitySelector.LIVING_ENTITY_STILL_ALIVE);
float f = (float) Math.min(Mth.floor((float) dist * 2), 40);
this.level().getEntities(this, this.getBoundingBox(), predicate).forEach(entity -> entity.hurt(source, f));
boolean isAnvil = this.blockState.is(BlockTags.ANVIL);
Expand All @@ -146,27 +158,27 @@ public boolean causeFallDamage(float fallDistance, float multiplier, DamageSourc

protected static boolean shouldIgnoreBlockInMovement(BlockState blockState) {
return (blockState.isAir()
|| blockState.is(Tags.Blocks.GLASS_BLOCKS)
|| blockState.is(Tags.Blocks.GLASS_PANES)
|| blockState.getBlock() instanceof TransparentBlock
|| blockState.canBeReplaced())
&& !(blockState.getBlock() instanceof SpectralAnvilBlock);
|| blockState.is(Tags.Blocks.GLASS_BLOCKS)
|| blockState.is(Tags.Blocks.GLASS_PANES)
|| blockState.getBlock() instanceof TransparentBlock
|| blockState.canBeReplaced())
&& !(blockState.getBlock() instanceof SpectralAnvilBlock);
}

/**
* 落下幻灵实体
*/
public static FallingSpectralBlockEntity fall(
Level level, BlockPos pos, BlockState blockState, boolean updateBlock, boolean isGhostEntity) {
Level level, BlockPos pos, BlockState blockState, boolean updateBlock, boolean isGhostEntity) {
FallingSpectralBlockEntity fallingBlockEntity = new FallingSpectralBlockEntity(
level,
(double) pos.getX() + 0.5,
pos.getY(),
(double) pos.getZ() + 0.5,
blockState.hasProperty(BlockStateProperties.WATERLOGGED)
? blockState.setValue(BlockStateProperties.WATERLOGGED, false)
: blockState,
isGhostEntity);
level,
(double) pos.getX() + 0.5,
pos.getY(),
(double) pos.getZ() + 0.5,
blockState.hasProperty(BlockStateProperties.WATERLOGGED)
? blockState.setValue(BlockStateProperties.WATERLOGGED, false)
: blockState,
isGhostEntity);
if (updateBlock) {
level.setBlock(pos, blockState.getFluidState().createLegacyBlock(), 3);
}
Expand Down
Loading

0 comments on commit 6fe8137

Please sign in to comment.