use of net.minecraft.entity.effect.StatusEffectInstance in project MCDoom by AzureDoom.
the class DoomWallBlock method checkIconSpawn.
public static void checkIconSpawn(World world, BlockPos pos, IconBlockEntity blockEntity) {
if (!world.isClient()) {
BlockState block = blockEntity.getCachedState();
boolean flag = block.isOf(DoomBlocks.ICON_WALL1) || block.isOf(DoomBlocks.ICON_WALL2) || block.isOf(DoomBlocks.ICON_WALL3) || block.isOf(DoomBlocks.ICON_WALL4) || block.isOf(DoomBlocks.ICON_WALL5) || block.isOf(DoomBlocks.ICON_WALL6) || block.isOf(DoomBlocks.ICON_WALL7) || block.isOf(DoomBlocks.ICON_WALL8) || block.isOf(DoomBlocks.ICON_WALL9) || block.isOf(DoomBlocks.ICON_WALL10) || block.isOf(DoomBlocks.ICON_WALL11) || block.isOf(DoomBlocks.ICON_WALL12) || block.isOf(DoomBlocks.ICON_WALL13) || block.isOf(DoomBlocks.ICON_WALL14) || block.isOf(DoomBlocks.ICON_WALL15) || block.isOf(DoomBlocks.ICON_WALL16);
if (flag && pos.getY() >= 3 && world.getDifficulty() != Difficulty.PEACEFUL) {
BlockPattern blockPattern = getOrCreateIconFull();
BlockPattern.Result result = blockPattern.searchAround(world, pos);
if (result != null) {
for (int i = 0; i < blockPattern.getWidth(); ++i) {
for (int j = 0; j < blockPattern.getHeight(); ++j) {
CachedBlockPosition cachedBlockPosition = result.translate(i, j, 0);
world.setBlockState(cachedBlockPosition.getBlockPos(), Blocks.AIR.getDefaultState(), 2);
world.syncWorldEvent(2001, cachedBlockPosition.getBlockPos(), Block.getRawIdFromState(cachedBlockPosition.getBlockState()));
}
}
IconofsinEntity witherentity = ModEntityTypes.ICONOFSIN.create(world);
BlockPos blockPos = result.translate(1, 2, 0).getBlockPos();
witherentity.refreshPositionAndAngles((double) blockPos.getX() + 0.5D, (double) blockPos.getY() + 0.55D, (double) blockPos.getZ() + 0.5D, result.getForwards().getAxis() == Direction.Axis.X ? 0.0F : 90.0F, 0.0F);
witherentity.bodyYaw = result.getForwards().getAxis() == Direction.Axis.X ? 0.0F : 90.0F;
witherentity.addStatusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 200, 4));
witherentity.addStatusEffect(new StatusEffectInstance(StatusEffects.RESISTANCE, 200, 4));
world.spawnEntity(witherentity);
Iterator<ServerPlayerEntity> var13 = world.getNonSpectatingEntities(ServerPlayerEntity.class, witherentity.getBoundingBox().expand(50.0D)).iterator();
while (var13.hasNext()) {
ServerPlayerEntity serverPlayerEntity = (ServerPlayerEntity) var13.next();
Criteria.SUMMONED_ENTITY.trigger(serverPlayerEntity, witherentity);
}
for (int k = 0; k < blockPattern.getWidth(); ++k) {
for (int l = 0; l < blockPattern.getHeight(); ++l) {
world.updateNeighbors(result.translate(k, l, 0).getBlockPos(), Blocks.AIR);
}
}
}
}
}
}
use of net.minecraft.entity.effect.StatusEffectInstance in project MCDoom by AzureDoom.
the class DoomHunterEntity method tick.
@Override
public void tick() {
super.tick();
flameTimer = (flameTimer + 1) % 8;
if (this.getHealth() < (this.getMaxHealth() * 0.50)) {
if (!this.world.isClient) {
this.addStatusEffect(new StatusEffectInstance(StatusEffects.SPEED, 10000000, 2));
}
}
}
use of net.minecraft.entity.effect.StatusEffectInstance in project MCDoom by AzureDoom.
the class InmortalSphereItem method usageTick.
@Override
public void usageTick(World worldIn, LivingEntity livingEntityIn, ItemStack stack, int count) {
if (livingEntityIn instanceof PlayerEntity) {
PlayerEntity playerentity = (PlayerEntity) livingEntityIn;
if (!worldIn.isClient) {
livingEntityIn.addStatusEffect(new StatusEffectInstance(StatusEffects.FIRE_RESISTANCE, 600, 4));
livingEntityIn.addStatusEffect(new StatusEffectInstance(StatusEffects.RESISTANCE, 600, 4));
if (!playerentity.getAbilities().creativeMode) {
stack.decrement(1);
if (stack.isEmpty()) {
playerentity.getInventory().removeOne(stack);
}
}
}
}
}
use of net.minecraft.entity.effect.StatusEffectInstance in project MCDoom by AzureDoom.
the class MegaSphereItem method usageTick.
@Override
public void usageTick(World worldIn, LivingEntity livingEntityIn, ItemStack stack, int count) {
if (livingEntityIn instanceof PlayerEntity) {
PlayerEntity playerentity = (PlayerEntity) livingEntityIn;
if (!worldIn.isClient) {
livingEntityIn.addStatusEffect(new StatusEffectInstance(StatusEffects.HEALTH_BOOST, 600, 4));
livingEntityIn.heal(40);
livingEntityIn.addStatusEffect(new StatusEffectInstance(StatusEffects.RESISTANCE, 600, 4));
livingEntityIn.addStatusEffect(new StatusEffectInstance(StatusEffects.FIRE_RESISTANCE, 600, 4));
if (!playerentity.getAbilities().creativeMode) {
stack.decrement(1);
if (stack.isEmpty()) {
playerentity.getInventory().removeOne(stack);
}
}
}
}
}
use of net.minecraft.entity.effect.StatusEffectInstance in project Potions-HUD-Fabric by Samuel-Martineau.
the class InGameHudMixin method renderStatusEffectOverlay.
/**
* @author Samuel-Martineau
* @reason Prevents the default status effects overlay from being rendered
*/
@Overwrite()
public void renderStatusEffectOverlay(MatrixStack matrices) {
MinecraftClient client = MinecraftClient.getInstance();
InGameHud inGameHud = client.inGameHud;
TextRenderer textRenderer = inGameHud.getTextRenderer();
int spriteSize = 18;
assert client.player != null;
Collection<StatusEffectInstance> statusEffectsCollection = client.player.getStatusEffects();
if (!statusEffectsCollection.isEmpty()) {
RenderSystem.enableBlend();
StatusEffectSpriteManager statusEffectSpriteManager = client.getStatusEffectSpriteManager();
List<Runnable> statusEffectsRunnableList = Lists.newArrayListWithExpectedSize(statusEffectsCollection.size());
RenderSystem.setShaderTexture(0, HandledScreen.BACKGROUND_TEXTURE);
Iterator<StatusEffectInstance> statusEffectsIterator = Ordering.natural().reverse().sortedCopy(statusEffectsCollection).iterator();
int i = 0;
while (statusEffectsIterator.hasNext()) {
int x = PotionsHUDMod.CONFIG_MANAGER.X_OFFSET;
int y = spriteSize * i + PotionsHUDMod.CONFIG_MANAGER.Y_OFFSET;
StatusEffectInstance statusEffectInstance = statusEffectsIterator.next();
StatusEffect statusEffect = statusEffectInstance.getEffectType();
if (statusEffectInstance.shouldShowIcon()) {
Sprite statusEffectSprite = statusEffectSpriteManager.getSprite(statusEffect);
statusEffectsRunnableList.add(() -> {
RenderSystem.setShaderTexture(0, statusEffectSprite.getAtlas().getId());
DrawableHelper.drawSprite(matrices, x, y, inGameHud.getZOffset(), spriteSize, spriteSize, statusEffectSprite);
int duration = statusEffectInstance.getDuration() / 20;
long mins = TimeUnit.SECONDS.toMinutes(duration);
long secs = duration - TimeUnit.MINUTES.toSeconds(mins);
String formattedDuration;
if (statusEffectInstance.isPermanent())
formattedDuration = "∞";
else if (mins == 0)
formattedDuration = secs + " sec";
else
formattedDuration = String.format("%d min, %d sec", mins, secs);
float textX = x + spriteSize + 3;
float textY = y + (spriteSize / 2f - textRenderer.fontHeight / 2.5f);
int color;
if (duration <= 5)
color = 0xFF5555;
else if (duration <= 15)
color = 0xFFAA00;
else if (duration <= 25)
color = 0xFFFF55;
else
color = 0xFFFFFF;
textRenderer.draw(matrices, formattedDuration, textX, textY, color);
});
}
i++;
}
statusEffectsRunnableList.forEach(Runnable::run);
}
}
Aggregations