use of net.minecraft.block.BlockGrass in project SpongeCommon by SpongePowered.
the class MixinBlock method onConstruction.
@Inject(method = "<init>*", at = @At("RETURN"))
public void onConstruction(CallbackInfo ci) {
// Determine which blocks can avoid executing un-needed event logic
// This will allow us to avoid running event logic for blocks that do nothing such as grass collisions
// -- blood
this.hasCollideLogic = true;
this.hasCollideWithStateLogic = true;
// onEntityCollidedWithBlock
try {
String mapping = SpongeImplHooks.isDeobfuscatedEnvironment() ? "onEntityWalk" : "func_176199_a";
Class<?>[] argTypes = { net.minecraft.world.World.class, BlockPos.class, Entity.class };
Class<?> clazz = this.getClass().getMethod(mapping, argTypes).getDeclaringClass();
if (clazz.equals(Block.class)) {
this.hasCollideLogic = false;
}
} catch (Throwable ex) {
// ignore
}
// onEntityCollidedWithBlock (IBlockState)
try {
String mapping = SpongeImplHooks.isDeobfuscatedEnvironment() ? "onEntityCollidedWithBlock" : "func_180634_a";
Class<?>[] argTypes = { net.minecraft.world.World.class, BlockPos.class, IBlockState.class, Entity.class };
Class<?> clazz = this.getClass().getMethod(mapping, argTypes).getDeclaringClass();
if (clazz.equals(Block.class)) {
this.hasCollideWithStateLogic = false;
}
} catch (Throwable ex) {
// ignore
}
Block block = (Block) (Object) this;
if (block instanceof BlockLeaves || block instanceof BlockLog || block instanceof BlockGrass || block instanceof BlockLiquid) {
this.requiresBlockCapture = false;
}
}
use of net.minecraft.block.BlockGrass in project BiomesOPlenty by Glitchfiend.
the class EntityAIEatBOPGrass method shouldExecute.
@Override
public boolean shouldExecute() {
if (this.sheep.getRNG().nextInt(this.sheep.isChild() ? 50 : 1000) != 0) {
return false;
} else {
BlockPos pos = new BlockPos(this.sheep.posX, this.sheep.posY, this.sheep.posZ);
IBlockState state = this.world.getBlockState(pos);
return IS_TALL_GRASS.apply(state) || IS_SHORT_GRASS.apply(state) || IS_MEDIUM_GRASS.apply(state) || IS_WHEAT_GRASS.apply(state) || IS_DAMP_GRASS.apply(state) || this.world.getBlockState(pos.down()).getBlock() instanceof BlockGrass;
}
}
use of net.minecraft.block.BlockGrass in project harvestcraft by MatrexsVigil.
the class TileEntityGroundTrap method countFlowers.
public int countFlowers() {
byte radius = 2;
int count = 0;
// final World world = world;
final int varX = pos.getX();
final int varY = pos.getY();
final int varZ = pos.getZ();
for (int offsetX = -radius; offsetX <= radius; ++offsetX) {
for (int offsetZ = -radius; offsetZ <= radius; ++offsetZ) {
if (offsetX * offsetX + offsetZ * offsetZ <= radius * radius && (offsetX != -(radius - 1) || offsetZ != -(radius - 1)) && (offsetX != radius - 1 || offsetZ != radius - 1) && (offsetX != radius - 1 || offsetZ != -(radius - 1)) && (offsetX != -(radius - 1) || offsetZ != radius - 1)) {
final BlockPos pos = new BlockPos(varX + offsetX, varY, varZ + offsetZ);
if (!world.isBlockLoaded(pos))
continue;
final Block blockAtCoords = world.getBlockState(pos).getBlock();
if (blockAtCoords instanceof BlockDirt || blockAtCoords instanceof BlockGrass) {
count++;
}
}
}
}
return count;
}
use of net.minecraft.block.BlockGrass in project harvestcraft by MatrexsVigil.
the class TileEntityGroundTrap method getRunTime.
private int getRunTime() {
final int radius = 2;
// final World world = world;
final int varX = pos.getX();
final int varY = pos.getY();
final int varZ = pos.getZ();
int speed = 3500;
for (int offsetX = -radius; offsetX <= radius; ++offsetX) {
for (int offsetZ = -radius; offsetZ <= radius; ++offsetZ) {
if (offsetX * offsetX + offsetZ * offsetZ > radius * radius || offsetX == -radius - 1 && offsetZ == -radius - 1 || offsetX == radius - 1 && offsetZ == radius - 1 || offsetX == radius - 1 && offsetZ == -radius - 1 || offsetX == -radius - 1 && offsetZ == radius - 1)
continue;
final BlockPos pos = new BlockPos(varX + offsetX, varY, varZ + offsetZ);
if (!world.isBlockLoaded(pos))
continue;
final Block blockAtCoords = world.getBlockState(pos).getBlock();
if (blockAtCoords instanceof BlockDirt || blockAtCoords instanceof BlockGrass) {
speed = (int) (speed * 0.95);
}
if (blockAtCoords != BlockRegistry.groundtrap)
continue;
speed = (int) (speed / 0.85);
}
}
return speed;
}
Aggregations