Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
implement peek
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroeightysix committed Sep 13, 2018
1 parent 39904cc commit 094a4df
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package me.zeroeightsix.kami.command.commands;

import me.zeroeightsix.kami.command.Command;
import me.zeroeightsix.kami.command.syntax.ChunkBuilder;
import me.zeroeightsix.kami.command.syntax.SyntaxChunk;
import me.zeroeightsix.kami.util.Wrapper;
import net.minecraft.item.ItemShulkerBox;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityShulkerBox;

/**
* @author 086
*/
public class PeekCommand extends Command {

public static TileEntityShulkerBox sb;

public PeekCommand() {
super("peek", SyntaxChunk.EMPTY);
}

@Override
public void call(String[] args) {
ItemStack is = Wrapper.getPlayer().inventory.getCurrentItem();

if (is.getItem() instanceof ItemShulkerBox) {
TileEntityShulkerBox entityBox = new TileEntityShulkerBox();
entityBox.blockType = ((ItemShulkerBox) is.getItem()).getBlock();
entityBox.setWorld(Wrapper.getWorld());
entityBox.readFromNBT(is.getTagCompound().getCompoundTag("BlockEntityTag"));
sb = entityBox;
} else {
Command.sendChatMessage("You aren't carrying a shulker box.");
}
}
}
13 changes: 13 additions & 0 deletions src/main/java/me/zeroeightsix/kami/event/ForgeEventProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import me.zeroeightsix.kami.KamiMod;
import me.zeroeightsix.kami.command.Command;
import me.zeroeightsix.kami.command.commands.PeekCommand;
import me.zeroeightsix.kami.event.events.DisplaySizeChangedEvent;
import me.zeroeightsix.kami.gui.UIRenderer;
import me.zeroeightsix.kami.gui.kami.KamiGUI;
Expand All @@ -11,6 +12,8 @@
import me.zeroeightsix.kami.util.KamiTessellator;
import me.zeroeightsix.kami.util.Wrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.gui.inventory.GuiShulkerBox;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraftforge.client.event.*;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
Expand Down Expand Up @@ -47,6 +50,16 @@ public void onUpdate(LivingEvent.LivingUpdateEvent event) {
.filter(component -> component instanceof Frame)
.forEach(component -> KamiGUI.dock((Frame) component));
}

if (PeekCommand.sb != null) {
ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
int i = scaledresolution.getScaledWidth();
int j = scaledresolution.getScaledHeight();
GuiShulkerBox gui = new GuiShulkerBox(Wrapper.getPlayer().inventory, PeekCommand.sb);
gui.setWorldAndResolution(Wrapper.getMinecraft(), i, j);
Minecraft.getMinecraft().displayGuiScreen(gui);
PeekCommand.sb = null;
}
}

@SubscribeEvent
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/kami_at.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public net.minecraft.client.renderer.BlockModelRenderer *()
public net.minecraft.pathfinding.Path *
public net.minecraft.client.gui.GuiBossOverlay *
public net.minecraft.client.gui.GuiBossOverlay func_184052_a(IILnet/minecraft/world/BossInfo;)V
public net.minecraft.tileentity.TileEntity field_145854_h # blockType

#Specific targeting past here
#public net.minecraft.world.chunk.Chunk func_186034_a(Lnet/minecraft/world/chunk/IChunkGenerator;)V # Populate Chunk Method
Expand Down

0 comments on commit 094a4df

Please sign in to comment.