Reimplement pixie spawning

This commit is contained in:
Vincent Lee committed 2020-07-18 18:57:24 -05:00
1 parent 313b0fb0a2
commit 4d8174cf95
5 files changed
+20 -18

No files matched your search

@@ -174,7 +174,6 @@ public class Botania {
forgeBus.addListener(ItemVirus::onLivingHurt);
forgeBus.addListener(SleepingHandler::trySleep);
forgeBus.addListener(PixieHandler::onDamageTaken);
forgeBus.addGenericListener(Entity.class, PixieHandler::attachAttribute);
forgeBus.addGenericListener(TileEntity.class, ExoflameFurnaceHandler::attachFurnaceCapability);
forgeBus.addListener(CommonTickHandler::onTick);
forgeBus.addListener(PotionBloodthirst::onSpawn);
@@ -43,7 +43,6 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, ITickable
AccessorAbstractSpawner mLogic = (AccessorAbstractSpawner) logic;
// [VanillaCopy] AbstractSpawner.tick, edits noted
// todo 1.16 investigate instead mixing into AbstractSpawner instead of duplicating logic here
if (!mLogic.callIsActivated()) { // Activate when vanilla is *not* running the spawner
mLogic.setPrevMobRotation(mLogic.getMobRotation());
} else {
@@ -68,23 +68,10 @@ public final class PixieHandler {
return new AttributeModifier(DEFAULT_MODIFIER_UUIDS.get(slot), name, amount, AttributeModifier.Operation.ADDITION);
}
// Want to do this as early as possible -- doing it at entity join world means attribute modifiers are ignored when loading
public static void attachAttribute(AttachCapabilitiesEvent<Entity> evt) {
if (evt.getObject() instanceof PlayerEntity) {
/* todo 1.16 impossible rn?
AbstractAttributeMap attributes = ((PlayerEntity) evt.getObject()).getAttributes();
if (attributes.getAttributeInstance(PIXIE_SPAWN_CHANCE) == null) {
attributes.registerAttribute(PIXIE_SPAWN_CHANCE);
}
*/
}
}
public static void onDamageTaken(LivingHurtEvent event) {
if (!event.getEntityLiving().world.isRemote && event.getEntityLiving() instanceof PlayerEntity && event.getSource().getTrueSource() instanceof LivingEntity) {
PlayerEntity player = (PlayerEntity) event.getEntityLiving();
/* todo unimpl
double chance = player.getAttribute(PIXIE_SPAWN_CHANCE).getValue();
double chance = player.func_233637_b_(PIXIE_SPAWN_CHANCE);
ItemStack sword = PlayerHelper.getFirstHeldItem(player, s -> s.getItem() == ModItems.elementiumSword);
if (Math.random() < chance) {
@@ -105,7 +92,6 @@ public final class PixieHandler {
SpawnReason.EVENT, null, null);
player.world.addEntity(pixie);
}
*/
}
}
}
@@ -0,0 +1,17 @@
package vazkii.botania.mixin;
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
import net.minecraft.entity.player.PlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import vazkii.botania.common.core.handler.PixieHandler;
@Mixin(PlayerEntity.class)
public class MixinPlayerEntity {
@Inject(at = @At("RETURN"), method = "func_234570_el_")
private static void addPixieAttribute(CallbackInfoReturnable<AttributeModifierMap.MutableAttribute> cir) {
cir.getReturnValue().func_233814_a_(PixieHandler.PIXIE_SPAWN_CHANCE);
}
}
@@ -18,7 +18,8 @@
"AccessorMobEntity",
"AccessorNearestAttackableTarget",
"AccessorRecipeManager",
"AccessorWitherEntity"
"AccessorWitherEntity",
"MixinPlayerEntity"
],
"client": [
"AccessorBiomeGeneratorTypeScreens",