Add barbed wire
This commit is contained in:
parent
483f2730e3
commit
f1bf483b87
12 changed files with 109 additions and 10 deletions
32
src/main/java/su/a71/new_soviet/blocks/BarbedWireBlock.java
Normal file
32
src/main/java/su/a71/new_soviet/blocks/BarbedWireBlock.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
package su.a71.new_soviet.blocks;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BarbedWireBlock extends Block {
|
||||
public BarbedWireBlock(FabricBlockSettings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
|
||||
if (entity instanceof LivingEntity && entity.getType() != EntityType.FOX && entity.getType() != EntityType.BEE) {
|
||||
entity.slowMovement(state, new Vec3d(0.800000011920929, 0.75, 0.800000011920929));
|
||||
if (!world.isClient && (entity.lastRenderX != entity.getX() || entity.lastRenderZ != entity.getZ())) {
|
||||
double d = Math.abs(entity.getX() - entity.lastRenderX);
|
||||
double e = Math.abs(entity.getZ() - entity.lastRenderZ);
|
||||
if (d >= 0.003000000026077032 || e >= 0.003000000026077032) {
|
||||
entity.damage(world.getDamageSources().generic(), 2.0F);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue