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));
}
}
}
}
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();
}
}
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();
}
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;
});
}
Aggregations