use of net.minecraft.world.entity.animal.Sheep in project IntegratedDynamics by CyclopsMC.
the class TestEntityOperators method before.
@IntegrationBefore
public void before() {
Level world = ServerLifecycleHooks.getCurrentServer().getLevel(Level.OVERWORLD);
eZombie = new DummyVariableEntity(makeEntity(new Zombie(world)));
Zombie zombieBurning = new Zombie(world);
zombieBurning.setSecondsOnFire(10);
eZombieBurning = new DummyVariableEntity(makeEntity(zombieBurning));
Zombie zombieWet = new Zombie(world) {
@Override
protected void registerGoals() {
super.registerGoals();
this.wasTouchingWater = true;
}
};
eZombieWet = new DummyVariableEntity(makeEntity(zombieWet));
Zombie zombieCrouching = new Zombie(world) {
@Override
public boolean isCrouching() {
return true;
}
};
eZombieCrouching = new DummyVariableEntity(makeEntity(zombieCrouching));
Zombie zombieEating = new Zombie(world) {
@Override
public int getUseItemRemainingTicks() {
return 1;
}
};
eZombieEating = new DummyVariableEntity(makeEntity(zombieEating));
eChicken = new DummyVariableEntity(makeEntity(new Chicken(EntityType.CHICKEN, world)));
eItem = new DummyVariableEntity(makeEntity(new ItemEntity(world, 0, 0, 0, ItemStack.EMPTY)));
eItemFrame = new DummyVariableEntity(makeEntity(new ItemFrame(world, new BlockPos(0, 0, 0), Direction.NORTH)));
ePlayer = new DummyVariableEntity(makeEntity(world.players().get(0)));
Zombie zombieHeldItems = new Zombie(world);
zombieHeldItems.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.APPLE));
zombieHeldItems.setItemSlot(EquipmentSlot.OFFHAND, new ItemStack(Items.POTATO));
eZombieHeldItems = new DummyVariableEntity(makeEntity(zombieHeldItems));
Boat boat = new Boat(world, 0, 0, 0);
eZombie.getValue().getRawValue().get().startRiding(boat, true);
eBoat = new DummyVariableEntity(makeEntity(boat));
ItemFrame itemframe = new ItemFrame(world, new BlockPos(0, 0, 0), Direction.NORTH);
itemframe.setItem(new ItemStack(Items.POTATO));
itemframe.setRotation(3);
eItemframe = new DummyVariableEntity(makeEntity(itemframe));
Zombie zombieAged = new Zombie(world) {
@Override
public int getNoActionTime() {
return 3;
}
};
eZombieAged = new DummyVariableEntity(makeEntity(zombieAged));
Zombie zombieBaby = new Zombie(world);
zombieBaby.setBaby(true);
eZombieBaby = new DummyVariableEntity(makeEntity(zombieBaby));
eCow = new DummyVariableEntity(makeEntity(new Cow(EntityType.COW, world)));
eCowAlreadyBred = new DummyVariableEntity(makeEntity(new Cow(EntityType.COW, world) {
@Override
public int getAge() {
return 10;
}
}));
eCowBaby = new DummyVariableEntity(makeEntity(new Cow(EntityType.COW, world) {
@Override
public int getAge() {
return -10;
}
}));
eCowInLove = new DummyVariableEntity(makeEntity(new Cow(EntityType.COW, world) {
@Override
public boolean isInLove() {
return true;
}
}));
ePig = new DummyVariableEntity(makeEntity(new Pig(EntityType.PIG, world)));
eSheep = new DummyVariableEntity(makeEntity(new Sheep(EntityType.SHEEP, world)));
Sheep sheepSheared = new Sheep(EntityType.SHEEP, world);
sheepSheared.setSheared(true);
eSheepSheared = new DummyVariableEntity(makeEntity(sheepSheared));
iCarrot = new DummyVariableItemStack(ValueObjectTypeItemStack.ValueItemStack.of(new ItemStack(Items.CARROT)));
iWheat = new DummyVariableItemStack(ValueObjectTypeItemStack.ValueItemStack.of(new ItemStack(Items.WHEAT)));
}
use of net.minecraft.world.entity.animal.Sheep in project Supplementaries by MehVahdJukaar.
the class EatFodderGoal method tick.
@Override
public void tick() {
super.tick();
Level world = this.animal.level;
// BlockPos blockpos = this.removerMob.blockPosition();
// BlockPos blockpos1 = this.getPosWithBlock(blockpos, world);
Random random = this.animal.getRandom();
if (this.isReachedTarget()) {
// prevents stopping while eating
this.tryTicks--;
BlockPos targetPos = this.getMoveToTarget().below();
Vec3 vector3d = Vec3.atBottomCenterOf(targetPos);
this.mob.getLookControl().setLookAt(vector3d.x(), vector3d.y(), vector3d.z());
if (this.ticksSinceReachedGoal > 0) {
if (!world.isClientSide && ticksSinceReachedGoal % 2 == 0) {
((ServerLevel) world).sendParticles(new BlockParticleOption(ParticleTypes.BLOCK, FODDER_STATE), (double) targetPos.getX() + 0.5D, (double) targetPos.getY() + 0.7D, (double) targetPos.getZ() + 0.5D, 3, ((double) random.nextFloat() - 0.5D) * 0.08D, ((double) random.nextFloat() - 0.5D) * 0.08D, ((double) random.nextFloat() - 0.5D) * 0.08D, 0.15F);
}
}
if (this.ticksSinceReachedGoal == 1 && this.animal instanceof Sheep) {
world.broadcastEntityEvent(this.mob, (byte) 10);
}
// breaking animation
int k = (int) ((float) this.ticksSinceReachedGoal / (float) this.blockBreakingTime * 10.0F);
if (k != this.lastBreakProgress) {
this.mob.level.destroyBlockProgress(this.mob.getId(), this.blockPos, k);
this.lastBreakProgress = k;
}
// break block
if (this.ticksSinceReachedGoal > this.blockBreakingTime) {
BlockState state = world.getBlockState(targetPos);
if (state.is(ModRegistry.FODDER.get())) {
int layers = state.getValue(FodderBlock.LAYERS);
if (layers > 1) {
world.levelEvent(2001, targetPos, Block.getId(FODDER_STATE));
world.setBlock(targetPos, FODDER_STATE.setValue(FodderBlock.LAYERS, layers - 1), 2);
} else {
world.destroyBlock(targetPos, false);
}
if (!world.isClientSide) {
((ServerLevel) world).sendParticles(ParticleTypes.HAPPY_VILLAGER, this.animal.getX(), this.animal.getY(), this.animal.getZ(), 5, this.animal.getBbWidth() / 2f, this.animal.getBbHeight() / 2f, this.animal.getBbWidth() / 2f, 0);
}
if (!this.animal.isBaby())
this.animal.setInLove(null);
this.animal.ate();
}
// so it stops
this.nextStartTick = this.nextStartTick(this.mob);
this.tryTicks = 800;
}
++this.ticksSinceReachedGoal;
}
}
use of net.minecraft.world.entity.animal.Sheep in project JustEnoughResources by way2muchnoise.
the class MobTableBuilder method addSheep.
public void addSheep(ResourceLocation resourceLocation, EntityType<Sheep> entityType, DyeColor dye) {
mobTables.put(resourceLocation, () -> {
Sheep sheep = entityType.create(level);
assert sheep != null;
sheep.setColor(dye);
return sheep;
});
}
use of net.minecraft.world.entity.animal.Sheep in project Create by Creators-of-Create.
the class DeployerScenes method filter.
public static void filter(SceneBuilder scene, SceneBuildingUtil util) {
scene.title("deployer", "Using the Deployer");
scene.configureBasePlate(0, 0, 5);
BlockPos potPosition = util.grid.at(1, 1, 2);
BlockPos deployerPos = util.grid.at(3, 1, 2);
Selection deployerSelection = util.select.position(deployerPos);
scene.world.setBlock(potPosition, Blocks.AIR.defaultBlockState(), false);
scene.world.showSection(util.select.layer(0).add(util.select.position(1, 1, 2)), Direction.UP);
scene.idle(5);
scene.world.showSection(util.select.fromTo(3, 1, 3, 3, 1, 5), Direction.DOWN);
scene.idle(10);
scene.world.showSection(deployerSelection, Direction.SOUTH);
scene.idle(10);
scene.overlay.showText(60).placeNearTarget().pointAt(util.vector.topOf(deployerPos)).text("Given Rotational Force, a Deployer can imitate player interactions");
scene.world.moveDeployer(deployerPos, 1, 25);
scene.idle(26);
scene.world.moveDeployer(deployerPos, -1, 25);
scene.idle(44);
scene.overlay.showSelectionWithText(util.select.position(deployerPos.west(2)), 60).text("It will always interact with the position 2 blocks in front of itself").attachKeyFrame().placeNearTarget().colored(PonderPalette.GREEN).attachKeyFrame();
scene.world.moveDeployer(deployerPos, 1, 25);
scene.idle(26);
scene.world.moveDeployer(deployerPos, -1, 25);
scene.idle(20);
scene.world.showSection(util.select.fromTo(2, 1, 3, 2, 1, 1), Direction.DOWN);
scene.idle(24);
scene.overlay.showText(50).pointAt(util.vector.topOf(deployerPos.west())).text("Blocks directly in front will not obstruct it").placeNearTarget();
scene.world.moveDeployer(deployerPos, 1, 25);
scene.idle(26);
scene.world.moveDeployer(deployerPos, -1, 25);
scene.idle(34);
scene.world.hideSection(util.select.fromTo(2, 1, 3, 2, 1, 1), Direction.UP);
scene.idle(20);
String[] actions = new String[] { "Place Blocks,", "Use Items,", "Activate Blocks,", "Harvest blocks", "and Attack Mobs" };
scene.overlay.showText(80).attachKeyFrame().independent(40).placeNearTarget().text("Deployers can:");
int y = 60;
for (String s : actions) {
scene.idle(15);
scene.overlay.showText(50).colored(PonderPalette.MEDIUM).placeNearTarget().independent(y).text(s);
y += 16;
}
scene.idle(50);
ItemStack pot = new ItemStack(Items.FLOWER_POT);
Vec3 frontVec = util.vector.blockSurface(deployerPos, Direction.WEST).add(-.125, 0, 0);
scene.overlay.showControls(new InputWindowElement(frontVec, Pointing.DOWN).rightClick().withItem(pot), 40);
scene.idle(7);
Class<DeployerTileEntity> teType = DeployerTileEntity.class;
scene.world.modifyTileNBT(deployerSelection, teType, nbt -> nbt.put("HeldItem", pot.serializeNBT()));
scene.idle(10);
scene.overlay.showText(40).attachKeyFrame().placeNearTarget().pointAt(frontVec).text("Right-click the front to give it an Item to use");
scene.idle(40);
scene.world.moveDeployer(deployerPos, 1, 25);
scene.idle(26);
scene.world.restoreBlocks(util.select.position(potPosition));
scene.world.modifyTileNBT(deployerSelection, teType, nbt -> nbt.put("HeldItem", ItemStack.EMPTY.serializeNBT()));
scene.world.moveDeployer(deployerPos, -1, 25);
scene.idle(20);
scene.world.showSection(util.select.position(deployerPos.above()), Direction.DOWN);
ItemStack tulip = new ItemStack(Items.RED_TULIP);
Vec3 entitySpawn = util.vector.topOf(deployerPos.above(3));
ElementLink<EntityElement> entity1 = scene.world.createItemEntity(entitySpawn, util.vector.of(0, 0.2, 0), tulip);
scene.idle(17);
scene.world.modifyEntity(entity1, Entity::discard);
scene.world.modifyTileNBT(deployerSelection, teType, nbt -> nbt.put("HeldItem", tulip.serializeNBT()));
scene.idle(10);
scene.overlay.showText(40).placeNearTarget().pointAt(util.vector.of(3, 2.5, 3)).text("Items can also be inserted automatically");
scene.idle(30);
scene.world.moveDeployer(deployerPos, 1, 25);
scene.idle(26);
scene.world.setBlock(potPosition, Blocks.POTTED_RED_TULIP.defaultBlockState(), false);
scene.world.modifyTileNBT(deployerSelection, teType, nbt -> nbt.put("HeldItem", ItemStack.EMPTY.serializeNBT()));
scene.world.moveDeployer(deployerPos, -1, 25);
scene.idle(25);
scene.world.hideSection(util.select.position(potPosition), Direction.UP);
scene.world.hideSection(util.select.position(deployerPos.above()), Direction.EAST);
scene.idle(20);
Vec3 filterSlot = frontVec.add(0.375, 0.25, 0);
scene.overlay.showFilterSlotInput(filterSlot, 80);
scene.overlay.showText(40).attachKeyFrame().placeNearTarget().pointAt(filterSlot).text("Deployers carry a filter slot");
scene.idle(50);
ItemStack shears = new ItemStack(Items.SHEARS);
scene.overlay.showControls(new InputWindowElement(filterSlot, Pointing.DOWN).rightClick().withItem(shears), 40);
scene.idle(7);
scene.world.setFilterData(deployerSelection, teType, shears);
scene.overlay.showText(60).placeNearTarget().pointAt(filterSlot).text("When a filter is set, it activates only while holding a matching item");
scene.idle(70);
ElementLink<EntityElement> sheep = scene.world.createEntity(w -> {
Sheep entity = EntityType.SHEEP.create(w);
entity.setColor(DyeColor.PINK);
Vec3 p = util.vector.topOf(util.grid.at(1, 0, 2));
entity.setPos(p.x, p.y, p.z);
entity.xo = p.x;
entity.yo = p.y;
entity.zo = p.z;
entity.animationPosition = 0;
entity.yRotO = 210;
entity.setYRot(210);
entity.yHeadRotO = 210;
entity.yHeadRot = 210;
return entity;
});
scene.idle(20);
scene.world.showSection(util.select.position(deployerPos.above()), Direction.WEST);
entity1 = scene.world.createItemEntity(entitySpawn, util.vector.of(0, 0.2, 0), shears);
scene.idle(17);
scene.world.modifyEntity(entity1, Entity::discard);
scene.world.modifyTileNBT(deployerSelection, teType, nbt -> nbt.put("HeldItem", shears.serializeNBT()));
scene.idle(10);
scene.overlay.showText(60).placeNearTarget().pointAt(util.vector.of(3, 2.5, 3)).text("Only items matching the filter can now be inserted...");
scene.idle(70);
scene.world.moveDeployer(deployerPos, 1, 25);
scene.idle(26);
scene.world.modifyEntity(sheep, e -> ((Sheep) e).setSheared(true));
scene.effects.emitParticles(util.vector.topOf(deployerPos.west(2)).add(0, -.25, 0), Emitter.withinBlockSpace(new BlockParticleOption(ParticleTypes.BLOCK, Blocks.PINK_WOOL.defaultBlockState()), util.vector.of(0, 0, 0)), 25, 1);
scene.world.moveDeployer(deployerPos, -1, 25);
scene.world.showSection(util.select.position(deployerPos.north()), Direction.SOUTH);
scene.idle(25);
scene.overlay.showText(80).placeNearTarget().pointAt(util.vector.of(3.5, 1.25, 1.25)).text("...and only non-matching items will be extracted");
scene.world.flapFunnel(deployerPos.north(), true);
scene.world.createItemEntity(util.vector.centerOf(deployerPos.north()).subtract(0, .45, 0), util.vector.of(0, 0, -0.1), new ItemStack(Items.PINK_WOOL));
scene.markAsFinished();
for (int i = 0; i < 10; i++) {
scene.idle(26);
scene.world.moveDeployer(deployerPos, 1, 25);
scene.idle(26);
scene.world.moveDeployer(deployerPos, -1, 25);
scene.idle(26);
}
}
Aggregations