use of net.minecraft.entity.item.EntityItemFrame in project minecolonies by Minecolonies.
the class AbstractEntityAIStructure method spawnEntity.
/**
* Iterates through all entities and spawns them
* Suppressing Sonar Rule Squid:S3047
* The rule thinks we can merge the two forge loops iterating over resources
* But in this case the rule does not apply because that would destroy the logic.
*/
@SuppressWarnings(MULTIPLE_LOOPS_OVER_THE_SAME_SET_SHOULD_BE_COMBINED)
private Boolean spawnEntity(@NotNull final Structure.StructureBlock currentBlock) {
final Template.EntityInfo entityInfo = currentBlock.entity;
if (entityInfo == null) {
return true;
}
final Entity entity = getEntityFromEntityInfoOrNull(entityInfo);
if (entity != null && !isEntityAtPosition(entity, world)) {
final List<ItemStack> request = new ArrayList<>();
if (entity instanceof EntityItemFrame) {
final ItemStack stack = ((EntityItemFrame) entity).getDisplayedItem();
if (stack != null) {
stack.setCount(stack.getCount() + 1);
request.add(stack);
}
request.add(new ItemStack(Items.ITEM_FRAME, 1));
} else if (entity instanceof EntityArmorStand) {
request.add(entity.getPickedResult(new RayTraceResult(worker)));
entity.getArmorInventoryList().forEach(request::add);
} else {
request.add(entity.getPickedResult(new RayTraceResult(worker)));
}
if (!Configurations.builderInfiniteResources) {
for (final ItemStack stack : request) {
if (checkOrRequestItems(stack)) {
return false;
}
}
//Surpress
for (final ItemStack stack : request) {
if (stack == null) {
continue;
}
final int slot = worker.findFirstSlotInInventoryWith(stack.getItem(), stack.getItemDamage());
if (slot != -1) {
new InvWrapper(getInventory()).extractItem(slot, 1, false);
reduceNeededResources(stack);
}
}
}
entity.setUniqueId(UUID.randomUUID());
entity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
if (!world.spawnEntity(entity)) {
Log.getLogger().info("Failed to spawn entity");
}
}
return true;
}
use of net.minecraft.entity.item.EntityItemFrame in project ArsMagica2 by Mithion.
the class AMEventHandler method onEntityConstructing.
@SubscribeEvent
public void onEntityConstructing(EntityConstructing event) {
if (event.entity instanceof EntityLivingBase) {
event.entity.registerExtendedProperties(ExtendedProperties.identifier, new ExtendedProperties());
((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.maxManaBonus);
((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.maxBurnoutBonus);
((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.xpGainModifier);
((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.burnoutReductionRate);
((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.manaRegenTimeModifier);
if (event.entity instanceof EntityPlayer) {
event.entity.registerExtendedProperties(RiftStorage.identifier, new RiftStorage());
event.entity.registerExtendedProperties(AffinityData.identifier, new AffinityData());
event.entity.registerExtendedProperties(SkillData.identifier, new SkillData((EntityPlayer) event.entity));
}
} else if (event.entity instanceof EntityItemFrame) {
AMCore.proxy.itemFrameWatcher.startWatchingFrame((EntityItemFrame) event.entity);
}
}
Aggregations