net.minecraft.entity.ai.brain.MemoryModuleType Java Examples
The following examples show how to use
net.minecraft.entity.ai.brain.MemoryModuleType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SecondaryPointOfInterestSensor_wartFarmMixin.java From carpet-extra with GNU Lesser General Public License v3.0 | 5 votes |
@Inject(method = "sense", at = @At("HEAD"), cancellable = true) private void notVanillaCleric(ServerWorld serverWorld, VillagerEntity villagerEntity, CallbackInfo ci) { if(!CarpetExtraSettings.clericsFarmWarts && villagerEntity.getVillagerData().getProfession() == VillagerProfession.CLERIC) { // in vanilla we want not to find secondary POI for clerics Brain<?> brain = villagerEntity.getBrain(); brain.forget(MemoryModuleType.SECONDARY_JOB_SITE); ci.cancel(); } }
Example #2
Source File: MixinMemoryModuleType.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@Override public IForgeRegistryEntry<MemoryModuleType> setRegistryName(Identifier name) { this.registryName = name; return this; }
Example #3
Source File: MixinMemoryModuleType.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
public Identifier getRegistryName() { MemoryModuleType<?> memoryModuleType = (MemoryModuleType<?>) (Object) this; return Identifiers.getOrFallback(Registry.MEMORY_MODULE_TYPE, memoryModuleType, registryName); }
Example #4
Source File: MixinMemoryModuleType.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
public Class<MemoryModuleType> getRegistryType() { return MemoryModuleType.class; }
Example #5
Source File: VillagerEntity_aiMixin.java From fabric-carpet with MIT License | 4 votes |
@Inject(method = "tick", at = @At("HEAD")) private void ontick(CallbackInfo ci) { if (MobAI.isTracking(this, MobAI.TrackingType.IRON_GOLEM_SPAWNING)) { long time; Optional<Long> optional_1 = this.brain.getOptionalMemory(MemoryModuleType.GOLEM_LAST_SEEN_TIME); if (!optional_1.isPresent()) { time = 0; } else { Long long_2 = optional_1.get(); time = long_2+600 - getEntityWorld().getTime(); } boolean recentlySeen = hasSeenGolemRecently(getEntityWorld().getTime()); Optional<Timestamp> optional_11 = this.brain.getOptionalMemory(MemoryModuleType.LAST_SLEPT); Optional<Timestamp> optional_22 = this.brain.getOptionalMemory(MemoryModuleType.LAST_WORKED_AT_POI); boolean work = false; boolean sleep = false; boolean panic = this.brain.hasActivity(Activity.PANIC); long currentTime = this.world.getTime(); if (optional_11.isPresent()) { sleep = (currentTime - optional_11.get().getTime()) < 24000L; } if (optional_22.isPresent()) { work = (currentTime - optional_22.get().getTime()) < 36000L; } this.setCustomName(Messenger.c( (sleep?"eb ":"fb ")+"\u263d ", (work?"eb ":"fb ")+"\u2692 ",//"\u26CF ", (panic?"lb ":"fb ")+"\u2623 ",//"\u2622 \u2620 \u26A1 ", (recentlySeen?"rb ":"lb ")+time )); this.setCustomNameVisible(true); } else if (MobAI.isTracking(this, MobAI.TrackingType.VILLAGER_BREEDING)) { if (age % 50 == 0 || age < 20) { totalFood = getAvailableFood() / 12; hasBed = this.brain.getOptionalMemory(MemoryModuleType.HOME).isPresent(); displayAge = getBreedingAge(); } if (Math.abs(displayAge) < 100 && displayAge !=0) displayAge = getBreedingAge(); this.setCustomName(Messenger.c( (hasBed?"eb ":"fb ")+"\u2616 ",//"\u263d ", (totalFood>0?"eb ":"fb ")+"\u2668",(totalFood>0?"e ":"f ")+totalFood+" ", (displayAge==0?"eb ":"fb ")+"\u2661",(displayAge==0?"e ":"f "+displayAge) )); this.setCustomNameVisible(true); } }
Example #6
Source File: VillagerEntity_aiMixin.java From fabric-carpet with MIT License | 4 votes |
@Inject(method = "interactMob", at = @At("HEAD"), cancellable = true) private void onInteract(PlayerEntity playerEntity_1, Hand hand_1, CallbackInfoReturnable<Boolean> cir) { if (MobAI.isTracking(this, MobAI.TrackingType.VILLAGER_BREEDING)) { ItemStack itemStack_1 = playerEntity_1.getStackInHand(hand_1); if (itemStack_1.getItem() == Items.EMERALD) { GlobalPos bedPos = this.brain.getOptionalMemory(MemoryModuleType.HOME).orElse(null); if (bedPos == null || bedPos.getDimension() != dimension) { sayNo(); ((ServerWorld) getEntityWorld()).spawnParticles(ParticleTypes.BARRIER, getX(), getY() + getStandingEyeHeight() + 1, getZ(), 1, 0.1, 0.1, 0.1, 0.0); } else { ParticleDisplay.drawParticleLine((ServerPlayerEntity) playerEntity_1, getPos(), new Vec3d(bedPos.getPos()).add(0.5, 0.5, 0.5), "dust 0 0 0 1", "happy_villager", 100, 0.2); } } else if (itemStack_1.getItem() == Items.ROTTEN_FLESH) { while(getAvailableFood() >= 12) eatForBreeding(); } else if (itemStack_1.getItem() instanceof BedItem) { List<PointOfInterest> list_1 = ((ServerWorld) getEntityWorld()).getPointOfInterestStorage().get( type -> type == PointOfInterestType.HOME, getBlockPos(), 48, PointOfInterestStorage.OccupationStatus.ANY).collect(Collectors.toList()); for (PointOfInterest poi : list_1) { Vec3d pv = new Vec3d(poi.getPos()).add(0.5, 0.5, 0.5); if (!poi.hasSpace()) { ((ServerWorld) getEntityWorld()).spawnParticles(ParticleTypes.HAPPY_VILLAGER, pv.x, pv.y+1.5, pv.z, 50, 0.1, 0.3, 0.1, 0.0); } else if (canReachHome((VillagerEntity)(Object)this, poi.getPos())) ((ServerWorld) getEntityWorld()).spawnParticles(ParticleTypes.END_ROD, pv.x, pv.y+1, pv.z, 50, 0.1, 0.3, 0.1, 0.0); else ((ServerWorld) getEntityWorld()).spawnParticles(ParticleTypes.BARRIER, pv.x, pv.y+1, pv.z, 1, 0.1, 0.1, 0.1, 0.0); } } cir.setReturnValue(false); cir.cancel(); } }
Example #7
Source File: FarmerVillagerTask_wartFarmMixin.java From carpet-extra with GNU Lesser General Public License v3.0 | 3 votes |
public FarmerVillagerTask_wartFarmMixin(Map<MemoryModuleType<?>, MemoryModuleState> requiredMemoryState) { super(requiredMemoryState); }