-
-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
125 additions
and
344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
.../arclight/common/mixin/core/world/entity/ai/behavior/TryLaySpawnOnWaterNearLandMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package io.izzel.arclight.common.mixin.core.world.entity.ai.behavior; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.sounds.SoundEvents; | ||
import net.minecraft.sounds.SoundSource; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.ai.behavior.BehaviorControl; | ||
import net.minecraft.world.entity.ai.behavior.TryLaySpawnOnWaterNearLand; | ||
import net.minecraft.world.entity.ai.behavior.declarative.BehaviorBuilder; | ||
import net.minecraft.world.entity.ai.memory.MemoryModuleType; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.gameevent.GameEvent; | ||
import net.minecraft.world.level.material.Fluids; | ||
import org.bukkit.craftbukkit.v.event.CraftEventFactory; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
|
||
@Mixin(TryLaySpawnOnWaterNearLand.class) | ||
public class TryLaySpawnOnWaterNearLandMixin { | ||
|
||
/** | ||
* @author IzzelAliz | ||
* @reason | ||
*/ | ||
@Overwrite | ||
public static BehaviorControl<LivingEntity> create(Block block) { | ||
return BehaviorBuilder.create((instance) -> { | ||
return instance.group(instance.absent(MemoryModuleType.ATTACK_TARGET), instance.present(MemoryModuleType.WALK_TARGET), instance.present(MemoryModuleType.IS_PREGNANT)).apply(instance, (memoryAccessor, memoryAccessor2, memoryAccessor3) -> { | ||
return (serverLevel, livingEntity, l) -> { | ||
if (!livingEntity.isInWater() && livingEntity.onGround()) { | ||
BlockPos blockPos = livingEntity.blockPosition().below(); | ||
|
||
for (Direction direction : Direction.Plane.HORIZONTAL) { | ||
BlockPos blockPos2 = blockPos.relative(direction); | ||
if (serverLevel.getBlockState(blockPos2).getCollisionShape(serverLevel, blockPos2).getFaceShape(Direction.UP).isEmpty() && serverLevel.getFluidState(blockPos2).is(Fluids.WATER)) { | ||
BlockPos blockPos3 = blockPos2.above(); | ||
if (serverLevel.getBlockState(blockPos3).isAir()) { | ||
BlockState blockState = block.defaultBlockState(); | ||
if (!CraftEventFactory.callEntityChangeBlockEvent(livingEntity, blockPos3, blockState)) { | ||
memoryAccessor3.erase(); | ||
return true; | ||
} | ||
serverLevel.setBlock(blockPos3, blockState, 3); | ||
serverLevel.gameEvent(GameEvent.BLOCK_PLACE, blockPos3, GameEvent.Context.of(livingEntity, blockState)); | ||
serverLevel.playSound(null, livingEntity, SoundEvents.FROG_LAY_SPAWN, SoundSource.BLOCKS, 1.0F, 1.0F); | ||
memoryAccessor3.erase(); | ||
return true; | ||
} | ||
} | ||
} | ||
|
||
return true; | ||
} else { | ||
return false; | ||
} | ||
}; | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 0 additions & 101 deletions
101
...n/java/io/izzel/arclight/common/mixin/vanilla/server/level/ServerEntityMixin_Vanilla.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
.../main/java/io/izzel/arclight/fabric/mixin/core/server/level/ServerEntityMixin_Fabric.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.