Skip to content

Commit

Permalink
Merge pull request #1352 from Gu-ZT/releases/1.21
Browse files Browse the repository at this point in the history
修复幻灵铁砧会被磁铁吸引的问题,修改幻灵铁砧实体碰撞箱
  • Loading branch information
Gu-ZT authored Dec 18, 2024
2 parents 6f67fda + 947d05d commit aec8bc8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
6 changes: 3 additions & 3 deletions src/main/java/dev/dubhe/anvilcraft/block/MagnetBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import dev.dubhe.anvilcraft.api.hammer.IHammerRemovable;
import dev.dubhe.anvilcraft.entity.AnimateAscendingBlockEntity;

import dev.dubhe.anvilcraft.init.ModBlocks;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
Expand All @@ -22,7 +23,6 @@
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.phys.AABB;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.annotation.ParametersAreNonnullByDefault;
Expand Down Expand Up @@ -97,7 +97,7 @@ private void attract(BlockState state, Level level, BlockPos magnetPos) {
currentPos = currentPos.below();
BlockState state1 = level.getBlockState(currentPos);

if (state1.is(BlockTags.ANVIL)) {
if (state1.is(BlockTags.ANVIL) && !state1.is(ModBlocks.SPECTRAL_ANVIL)) {
level.destroyBlock(magnetPos.below(), true);
level.setBlockAndUpdate(magnetPos.below(), state1);
level.setBlockAndUpdate(currentPos, Blocks.AIR.defaultBlockState());
Expand All @@ -109,7 +109,7 @@ private void attract(BlockState state, Level level, BlockPos magnetPos) {
level.getEntitiesOfClass(FallingBlockEntity.class, new AABB(currentPos));
for (FallingBlockEntity entity : entities) {
BlockState state2 = entity.getBlockState();
if (state2.is(BlockTags.ANVIL)) {
if (state2.is(BlockTags.ANVIL) && !state2.is(ModBlocks.SPECTRAL_ANVIL)) {
level.destroyBlock(magnetPos.below(), true);
level.setBlockAndUpdate(magnetPos.below(), state2);
entity.remove(Entity.RemovalReason.DISCARDED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void render(
&& blockState.getRenderShape() != RenderShape.INVISIBLE) {
poseStack.pushPose();
BlockPos blockPos = BlockPos.containing(entity.getX(), entity.getBoundingBox().maxY, entity.getZ());
poseStack.translate(-0.5, -1.0, -0.5);
poseStack.translate(-0.5, -0.0, -0.5);
this.dispatcher
.getModelRenderer()
.tesselateBlock(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
@ParametersAreNonnullByDefault
public class FallingSpectralBlockEntity extends FallingBlockEntity {
private boolean isGhostEntity;
private float fallDistance = 0;
private float fallDistance = 1.0f;

public FallingSpectralBlockEntity(EntityType<? extends FallingSpectralBlockEntity> entityType, Level level) {
super(entityType, level);
Expand Down Expand Up @@ -87,9 +87,11 @@ public void tick() {
fallDistance -= (float) this.getDeltaMovement().y;
if (this.level().isClientSide) return;
BlockPos current = this.blockPosition();
BlockPos below = current.below();
Vec3 pos = this.position();
Vec3 belowPos = pos.subtract(0.0D, 0.335D, 0.0D);
BlockPos below = new BlockPos((int) Math.floor(belowPos.x()), (int) Math.floor(belowPos.y()), (int) Math.floor(belowPos.z()));
BlockState blockStateDown = this.level().getBlockState(below);
if (current.getY() < -160) {
if (pos.y() < -160) {
discard();
}
if (!shouldIgnoreBlockInMovement(blockStateDown)) {
Expand Down Expand Up @@ -182,7 +184,7 @@ protected static boolean shouldIgnoreBlockInMovement(BlockState blockState) {
FallingSpectralBlockEntity fallingBlockEntity = new FallingSpectralBlockEntity(
level,
(double) pos.getX() + 0.5,
pos.getY(),
(double) pos.getY() - 0.96,
(double) pos.getZ() + 0.5,
blockState.hasProperty(BlockStateProperties.WATERLOGGED)
? blockState.setValue(BlockStateProperties.WATERLOGGED, false)
Expand Down
28 changes: 14 additions & 14 deletions src/main/java/dev/dubhe/anvilcraft/init/ModEntities.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@
import com.tterrag.registrate.util.entry.EntityEntry;

public class ModEntities {
public static final EntityEntry<? extends AnimateAscendingBlockEntity> ASCENDING_BLOCK_ENTITY =
AnvilCraft.REGISTRATE
.entity("animate_ascending_block", AnimateAscendingBlockEntity::new, MobCategory.MISC)
.renderer(() -> AscendingBlockRenderer::new)
.register();
public static final EntityEntry<? extends AnimateAscendingBlockEntity> ASCENDING_BLOCK_ENTITY = AnvilCraft.REGISTRATE
.entity("animate_ascending_block", AnimateAscendingBlockEntity::new, MobCategory.MISC)
.renderer(() -> AscendingBlockRenderer::new)
.register();

public static final EntityEntry<? extends FallingGiantAnvilEntity> FALLING_GIANT_ANVIL = AnvilCraft.REGISTRATE
.entity("falling_giant_anvil", FallingGiantAnvilEntity::new, MobCategory.MISC)
.renderer(() -> FallingBlockRenderer::new)
.register();
.entity("falling_giant_anvil", FallingGiantAnvilEntity::new, MobCategory.MISC)
.renderer(() -> FallingBlockRenderer::new)
.register();

public static final EntityEntry<? extends FallingSpectralBlockEntity> FALLING_SPECTRAL_BLOCK = AnvilCraft.REGISTRATE
.entity("falling_spectral_block", FallingSpectralBlockEntity::new, MobCategory.MISC)
.renderer(() -> SpectralBlockRenderer::new)
.register();
.entity("falling_spectral_block", FallingSpectralBlockEntity::new, MobCategory.MISC)
.properties(builder -> builder.sized(0.98f, 0.98f))
.renderer(() -> SpectralBlockRenderer::new)
.register();

public static final EntityEntry<? extends FloatingBlockEntity> FLOATING_BLOCK = AnvilCraft.REGISTRATE
.entity("floating_block", FloatingBlockEntity::new, MobCategory.MISC)
.renderer(() -> FallingBlockRenderer::new)
.register();
.entity("floating_block", FloatingBlockEntity::new, MobCategory.MISC)
.renderer(() -> FallingBlockRenderer::new)
.register();

public static void register() {
// intentionally empty
Expand Down

0 comments on commit aec8bc8

Please sign in to comment.