Search in sources :

Example 1 with ItemFrameEntity

use of net.minecraft.entity.decoration.ItemFrameEntity in project BleachHack by BleachDrinker420.

the class StorageESP method onWorldRender.

@BleachSubscribe
public void onWorldRender(EventWorldRender.Post event) {
    if (getSetting(0).asMode().getMode() == 0) {
        // Manually render blockentities because of culling
        for (BlockEntity be : WorldUtils.getBlockEntities()) {
            int[] color = getColorForBlock(be);
            if (color != null) {
                BlockEntityRenderer<BlockEntity> renderer = mc.getBlockEntityRenderDispatcher().get(be);
                MatrixStack matrices = Renderer.matrixFrom(be.getPos().getX(), be.getPos().getY(), be.getPos().getZ());
                if (renderer != null) {
                    renderer.render(be, mc.getTickDelta(), matrices, colorVertexer.createSingleProvider(mc.getBufferBuilders().getEntityVertexConsumers(), color[0], color[1], color[2], getSetting(1).asSlider().getValueInt()), LightmapTextureManager.MAX_LIGHT_COORDINATE, OverlayTexture.DEFAULT_UV);
                } else {
                    BlockState state = be.getCachedState();
                    mc.getBlockRenderManager().getModelRenderer().renderFlat(mc.world, mc.getBlockRenderManager().getModel(state), state, be.getPos(), matrices, colorVertexer.createSingleProvider(mc.getBufferBuilders().getEntityVertexConsumers(), color[0], color[1], color[2], getSetting(1).asSlider().getValueInt()).getBuffer(RenderLayers.getMovingBlockLayer(state)), false, new Random(), 0L, OverlayTexture.DEFAULT_UV);
                }
            }
        }
        colorVertexer.draw();
        shader.render();
        shader.drawFramebufferToMain("main");
    } else {
        float width = getSetting(2).asSlider().getValueFloat();
        int fill = getSetting(3).asSlider().getValueInt();
        for (Entity e : mc.world.getEntities()) {
            int[] color = getColorForEntity(e);
            Box box = e.getBoundingBox();
            if (e instanceof ItemFrameEntity && ((ItemFrameEntity) e).getHeldItemStack().getItem() == Items.FILLED_MAP) {
                Axis axis = e.getHorizontalFacing().getAxis();
                box = box.expand(axis == Axis.X ? 0 : 0.125, axis == Axis.Y ? 0 : 0.125, axis == Axis.Z ? 0 : 0.125);
            }
            if (color != null) {
                if (width != 0)
                    Renderer.drawBoxOutline(box, QuadColor.single(color[0], color[1], color[2], 255), width);
                if (fill != 0)
                    Renderer.drawBoxFill(box, QuadColor.single(color[0], color[1], color[2], fill));
            }
        }
        Set<BlockPos> skip = new HashSet<>();
        for (BlockEntity be : WorldUtils.getBlockEntities()) {
            if (skip.contains(be.getPos()))
                continue;
            int[] color = getColorForBlock(be);
            Box box = be.getCachedState().getOutlineShape(mc.world, be.getPos()).getBoundingBox().offset(be.getPos());
            Direction dir = getChestDirection(be);
            if (dir != null) {
                box = Boxes.stretch(box, dir, 0.94);
                skip.add(be.getPos().offset(dir));
            }
            if (color != null) {
                if (width != 0)
                    Renderer.drawBoxOutline(box, QuadColor.single(color[0], color[1], color[2], 255), width);
                if (fill != 0)
                    Renderer.drawBoxFill(box, QuadColor.single(color[0], color[1], color[2], fill));
            }
        }
    }
}
Also used : ItemFrameEntity(net.minecraft.entity.decoration.ItemFrameEntity) FurnaceMinecartEntity(net.minecraft.entity.vehicle.FurnaceMinecartEntity) Entity(net.minecraft.entity.Entity) HopperMinecartEntity(net.minecraft.entity.vehicle.HopperMinecartEntity) ChestMinecartEntity(net.minecraft.entity.vehicle.ChestMinecartEntity) MatrixStack(net.minecraft.client.util.math.MatrixStack) Box(net.minecraft.util.math.Box) Direction(net.minecraft.util.math.Direction) BlockState(net.minecraft.block.BlockState) Random(java.util.Random) ItemFrameEntity(net.minecraft.entity.decoration.ItemFrameEntity) BlockPos(net.minecraft.util.math.BlockPos) Axis(net.minecraft.util.math.Direction.Axis) HashSet(java.util.HashSet) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 2 with ItemFrameEntity

use of net.minecraft.entity.decoration.ItemFrameEntity in project ArmorStandEditor by Patbox.

the class ServerPlayerEntityMixin method showInvisible.

@Inject(method = "playerTick", at = @At("HEAD"))
private void showInvisible(CallbackInfo ci) {
    try {
        if (ConfigManager.getConfig().configData.holdingToolSpawnsParticles) {
            tickTimer++;
            if (tickTimer > 10 && this.getMainHandStack().getItem() == ConfigManager.getConfig().armorStandTool) {
                tickTimer = 0;
                List<ArmorStandEntity> armorStands = this.world.getEntitiesByClass(ArmorStandEntity.class, new Box(this.getBlockPos().add(10, 10, 10), this.getBlockPos().add(-10, -10, -10)), null);
                ParticleEffect particleEffect = new DustParticleEffect(0.8f, 0.2f, 0.2f, 1f);
                for (ArmorStandEntity armorStand : armorStands) {
                    this.networkHandler.sendPacket(new ParticleS2CPacket(particleEffect, false, armorStand.getX(), armorStand.getY() + armorStand.getHeight() / 2, armorStand.getZ(), 0.2f, 0.2f, 0.2f, 0.1f, 3));
                }
                List<ItemFrameEntity> itemFrames = this.world.getEntitiesByClass(ItemFrameEntity.class, new Box(this.getBlockPos().add(10, 10, 10), this.getBlockPos().add(-10, -10, -10)), null);
                ParticleEffect particleEffect2 = new DustParticleEffect(0.2f, 0.8f, 0.2f, 1f);
                for (ItemFrameEntity itemFrame : itemFrames) {
                    this.networkHandler.sendPacket(new ParticleS2CPacket(particleEffect2, false, itemFrame.getX(), itemFrame.getY() + itemFrame.getHeight() / 2, itemFrame.getZ(), 0.2f, 0.2f, 0.2f, 0.1f, 3));
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : DustParticleEffect(net.minecraft.particle.DustParticleEffect) ParticleEffect(net.minecraft.particle.ParticleEffect) ItemFrameEntity(net.minecraft.entity.decoration.ItemFrameEntity) DustParticleEffect(net.minecraft.particle.DustParticleEffect) Box(net.minecraft.util.math.Box) ParticleS2CPacket(net.minecraft.network.packet.s2c.play.ParticleS2CPacket) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 3 with ItemFrameEntity

use of net.minecraft.entity.decoration.ItemFrameEntity in project ArmorStandEditor by Patbox.

the class EditorGuis method openItemFrameEditor.

public static void openItemFrameEditor(ServerPlayerEntity player, ItemFrameEntity entity) {
    ItemFrameEntityAccessor ifa = (ItemFrameEntityAccessor) entity;
    SimpleGui gui = new SimpleGui(ScreenHandlerType.GENERIC_9X1, player, false);
    ItemFrameInventory inventory = new ItemFrameInventory(entity);
    GuiElement empty = new GuiElementBuilder(Items.GRAY_STAINED_GLASS_PANE).setName(new LiteralText("")).build();
    gui.setTitle(new TranslatableText("armorstandeditor.gui.item_frame_title"));
    gui.setSlotRedirect(0, new Slot(inventory, 0, 0, 0));
    gui.setSlot(1, empty);
    gui.setSlot(2, new GuiElementBuilder(ifa.getFixed() ? Items.GREEN_STAINED_GLASS_PANE : Items.RED_STAINED_GLASS_PANE).setName(new TranslatableText("armorstandeditor.gui.name.if-fixed", ifa.getFixed()).setStyle(Style.EMPTY.withItalic(false))).setCallback((index, type, action) -> {
        ifa.setFixed(!ifa.getFixed());
        ItemStack stack = new ItemStack(ifa.getFixed() ? Items.GREEN_STAINED_GLASS_PANE : Items.RED_STAINED_GLASS_PANE);
        stack.setCustomName(new TranslatableText("armorstandeditor.gui.name.if-fixed", ifa.getFixed()).setStyle(Style.EMPTY.withItalic(false)));
        ((GuiElement) gui.getSlot(index)).setItemStack(stack);
    }));
    gui.setSlot(3, new GuiElementBuilder(entity.isInvisible() ? Items.GREEN_STAINED_GLASS_PANE : Items.RED_STAINED_GLASS_PANE).setName(new TranslatableText("armorstandeditor.gui.name.if-invisible", entity.isInvisible()).setStyle(Style.EMPTY.withItalic(false))).setCallback((index, type, action) -> {
        entity.setInvisible(!entity.isInvisible());
        System.out.println(entity.isInvisible());
        ItemStack stack = new ItemStack(entity.isInvisible() ? Items.GREEN_STAINED_GLASS_PANE : Items.RED_STAINED_GLASS_PANE);
        stack.setCustomName(new TranslatableText("armorstandeditor.gui.name.if-invisible", entity.isInvisible()).setStyle(Style.EMPTY.withItalic(false)));
        ((GuiElement) gui.getSlot(index)).setItemStack(stack);
    }));
    gui.setSlot(4, new GuiElementBuilder(Items.ARROW).setName(new TranslatableText("armorstandeditor.gui.name.if-rotate", entity.getRotation()).setStyle(Style.EMPTY.withItalic(false))).setCallback((index, type, action) -> {
        if (type.isLeft || type.isRight) {
            int rotation = entity.getRotation() + (type.isLeft ? -1 : 1);
            if (rotation < 0) {
                rotation = 8 + rotation;
            }
            entity.setRotation(rotation % 8);
            ItemStack stack = new ItemStack(Items.ARROW);
            stack.setCustomName(new TranslatableText("armorstandeditor.gui.name.if-rotate", rotation).setStyle(Style.EMPTY.withItalic(false)));
            ((GuiElement) gui.getSlot(index)).setItemStack(stack);
        }
    }));
    for (int x = 5; x < 8; x++) {
        gui.setSlot(x, empty);
    }
    gui.setSlot(8, new GuiElementBuilder(Items.BARRIER).setName(new TranslatableText("armorstandeditor.gui.close").setStyle(Style.EMPTY.withItalic(false))).setCallback(((index, type, action) -> {
        gui.close();
    })));
    gui.open();
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) LiteralText(net.minecraft.text.LiteralText) ConfigManager(eu.pb4.armorstandeditor.config.ConfigManager) Item(net.minecraft.item.Item) StringTag(net.minecraft.nbt.StringTag) Permissions(me.lucko.fabric.api.permissions.v0.Permissions) TranslatableText(net.minecraft.text.TranslatableText) ItemFrameEntity(net.minecraft.entity.decoration.ItemFrameEntity) Slot(net.minecraft.screen.slot.Slot) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) Style(net.minecraft.text.Style) GuiElementInterface(eu.pb4.sgui.api.elements.GuiElementInterface) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AnvilInputGui(eu.pb4.sgui.api.gui.AnvilInputGui) ItemFrameEntityAccessor(eu.pb4.armorstandeditor.mixin.ItemFrameEntityAccessor) Enchantments(net.minecraft.enchantment.Enchantments) EquipmentSlot(net.minecraft.entity.EquipmentSlot) GuiElementBuilder(eu.pb4.sgui.api.elements.GuiElementBuilder) ClickType(eu.pb4.sgui.api.ClickType) ScreenHandlerType(net.minecraft.screen.ScreenHandlerType) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ArmorStandEntityAccessor(eu.pb4.armorstandeditor.mixin.ArmorStandEntityAccessor) LivingEntity(net.minecraft.entity.LivingEntity) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) Collection(java.util.Collection) ItemFrameInventory(eu.pb4.armorstandeditor.helpers.ItemFrameInventory) GuiElement(eu.pb4.sgui.api.elements.GuiElement) Items(net.minecraft.item.Items) ArmorStandData(eu.pb4.armorstandeditor.helpers.ArmorStandData) Collectors(java.util.stream.Collectors) SPEInterface(eu.pb4.armorstandeditor.helpers.SPEInterface) Formatting(net.minecraft.util.Formatting) List(java.util.List) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ArmorStandInventory(eu.pb4.armorstandeditor.helpers.ArmorStandInventory) ArmorStandPreset(eu.pb4.armorstandeditor.config.ArmorStandPreset) Text(net.minecraft.text.Text) SlotActionType(net.minecraft.screen.slot.SlotActionType) ListTag(net.minecraft.nbt.ListTag) SimpleGui(eu.pb4.sgui.api.gui.SimpleGui) ItemFrameInventory(eu.pb4.armorstandeditor.helpers.ItemFrameInventory) Slot(net.minecraft.screen.slot.Slot) EquipmentSlot(net.minecraft.entity.EquipmentSlot) GuiElementBuilder(eu.pb4.sgui.api.elements.GuiElementBuilder) ItemFrameEntityAccessor(eu.pb4.armorstandeditor.mixin.ItemFrameEntityAccessor) SimpleGui(eu.pb4.sgui.api.gui.SimpleGui) ItemStack(net.minecraft.item.ItemStack) GuiElement(eu.pb4.sgui.api.elements.GuiElement) LiteralText(net.minecraft.text.LiteralText)

Example 4 with ItemFrameEntity

use of net.minecraft.entity.decoration.ItemFrameEntity in project ArmorStandEditor by Patbox.

the class Events method registerEvents.

public static void registerEvents() {
    if (FabricLoader.getInstance().isModLoaded("disguiselib")) {
        AttackEntityCallback.EVENT.register((player, world, hand, entity, hitResult) -> {
            Config config = ConfigManager.getConfig();
            ItemStack itemStack = player.getMainHandStack();
            if (entity instanceof EntityDisguise && player instanceof ServerPlayerEntity && Permissions.check(player, "armorstandeditor.use", config.configData.toggleAllPermissionOnByDefault) && itemStack.getItem() == config.armorStandTool && (!config.configData.requireIsArmorStandEditorTag || itemStack.getOrCreateTag().getBoolean("isArmorStandEditor"))) {
                EntityDisguise disguise = (EntityDisguise) entity;
                if (disguise.isDisguised() && disguise.getDisguiseType() == EntityType.ARMOR_STAND && Permissions.check(player, "armorstandeditor.useDisguised", 2)) {
                    Events.modifyArmorStand((ServerPlayerEntity) player, (ArmorStandEntity) disguise.getDisguiseEntity(), 1, entity);
                    return ActionResult.SUCCESS;
                } else if (entity instanceof ArmorStandEntity) {
                    Events.modifyArmorStand((ServerPlayerEntity) player, (ArmorStandEntity) entity, 1, null);
                    return ActionResult.SUCCESS;
                }
            }
            return ActionResult.PASS;
        });
        UseEntityCallback.EVENT.register((player, world, hand, entity, hitResult) -> {
            Config config = ConfigManager.getConfig();
            ItemStack itemStack = player.getMainHandStack();
            if (entity instanceof EntityDisguise && player instanceof ServerPlayerEntity && Permissions.check(player, "armorstandeditor.use", config.configData.toggleAllPermissionOnByDefault) && itemStack.getItem() == config.armorStandTool && (!config.configData.requireIsArmorStandEditorTag || itemStack.getOrCreateTag().getBoolean("isArmorStandEditor"))) {
                EntityDisguise disguise = (EntityDisguise) entity;
                if (disguise.isDisguised() && disguise.getDisguiseType() == EntityType.ARMOR_STAND) {
                    Events.modifyArmorStand((ServerPlayerEntity) player, (ArmorStandEntity) disguise.getDisguiseEntity(), -1, entity);
                    return ActionResult.SUCCESS;
                } else if (entity instanceof ArmorStandEntity) {
                    Events.modifyArmorStand((ServerPlayerEntity) player, (ArmorStandEntity) entity, -1, null);
                    return ActionResult.SUCCESS;
                }
            }
            return ActionResult.PASS;
        });
    } else {
        AttackEntityCallback.EVENT.register((player, world, hand, entity, hitResult) -> {
            Config config = ConfigManager.getConfig();
            ItemStack itemStack = player.getMainHandStack();
            if (entity instanceof ArmorStandEntity && player instanceof ServerPlayerEntity && Permissions.check(player, "armorstandeditor.use", config.configData.toggleAllPermissionOnByDefault) && itemStack.getItem() == config.armorStandTool && (!config.configData.requireIsArmorStandEditorTag || itemStack.getOrCreateTag().getBoolean("isArmorStandEditor"))) {
                Events.modifyArmorStand((ServerPlayerEntity) player, (ArmorStandEntity) entity, 1, null);
                return ActionResult.SUCCESS;
            }
            return ActionResult.PASS;
        });
        UseEntityCallback.EVENT.register((player, world, hand, entity, hitResult) -> {
            Config config = ConfigManager.getConfig();
            ItemStack itemStack = player.getMainHandStack();
            if (entity instanceof ArmorStandEntity && player instanceof ServerPlayerEntity && Permissions.check(player, "armorstandeditor.use", config.configData.toggleAllPermissionOnByDefault) && itemStack.getItem() == config.armorStandTool && (!config.configData.requireIsArmorStandEditorTag || itemStack.getOrCreateTag().getBoolean("isArmorStandEditor"))) {
                Events.modifyArmorStand((ServerPlayerEntity) player, (ArmorStandEntity) entity, -1, null);
                return ActionResult.SUCCESS;
            }
            return ActionResult.PASS;
        });
    }
    UseItemCallback.EVENT.register((PlayerEntity player, World world, Hand hand) -> {
        Config config = ConfigManager.getConfig();
        ItemStack itemStack = player.getMainHandStack();
        if (player instanceof ServerPlayerEntity && itemStack.getItem() == config.armorStandTool && Permissions.check(player, "armorstandeditor.use", config.configData.toggleAllPermissionOnByDefault) && (!config.configData.requireIsArmorStandEditorTag || itemStack.getOrCreateTag().getBoolean("isArmorStandEditor"))) {
            EditorGuis.openGui((ServerPlayerEntity) player);
            return TypedActionResult.success(player.getMainHandStack());
        }
        return TypedActionResult.pass(player.getMainHandStack());
    });
    AttackEntityCallback.EVENT.register((player, world, hand, entity, hitResult) -> {
        Config config = ConfigManager.getConfig();
        ItemStack itemStack = player.getMainHandStack();
        if (entity instanceof ItemFrameEntity && player instanceof ServerPlayerEntity && Permissions.check(player, "armorstandeditor.useItemFrame", config.configData.toggleAllPermissionOnByDefault) && itemStack.getItem() == config.armorStandTool && (!config.configData.requireIsArmorStandEditorTag || itemStack.getOrCreateTag().getBoolean("isArmorStandEditor"))) {
            EditorGuis.openItemFrameEditor((ServerPlayerEntity) player, (ItemFrameEntity) entity);
            return ActionResult.SUCCESS;
        }
        return ActionResult.PASS;
    });
}
Also used : ItemFrameEntity(net.minecraft.entity.decoration.ItemFrameEntity) Config(eu.pb4.armorstandeditor.config.Config) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ItemStack(net.minecraft.item.ItemStack) World(net.minecraft.world.World) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) Hand(net.minecraft.util.Hand) EntityDisguise(xyz.nucleoid.disguiselib.casts.EntityDisguise) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity)

Aggregations

ItemFrameEntity (net.minecraft.entity.decoration.ItemFrameEntity)4 ArmorStandEntity (net.minecraft.entity.decoration.ArmorStandEntity)3 Entity (net.minecraft.entity.Entity)2 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 ItemStack (net.minecraft.item.ItemStack)2 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)2 Box (net.minecraft.util.math.Box)2 ArmorStandPreset (eu.pb4.armorstandeditor.config.ArmorStandPreset)1 Config (eu.pb4.armorstandeditor.config.Config)1 ConfigManager (eu.pb4.armorstandeditor.config.ConfigManager)1 ArmorStandData (eu.pb4.armorstandeditor.helpers.ArmorStandData)1 ArmorStandInventory (eu.pb4.armorstandeditor.helpers.ArmorStandInventory)1 ItemFrameInventory (eu.pb4.armorstandeditor.helpers.ItemFrameInventory)1 SPEInterface (eu.pb4.armorstandeditor.helpers.SPEInterface)1 ArmorStandEntityAccessor (eu.pb4.armorstandeditor.mixin.ArmorStandEntityAccessor)1 ItemFrameEntityAccessor (eu.pb4.armorstandeditor.mixin.ItemFrameEntityAccessor)1 ClickType (eu.pb4.sgui.api.ClickType)1 GuiElement (eu.pb4.sgui.api.elements.GuiElement)1 GuiElementBuilder (eu.pb4.sgui.api.elements.GuiElementBuilder)1 GuiElementInterface (eu.pb4.sgui.api.elements.GuiElementInterface)1