-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8915bae
commit c9f64da
Showing
10 changed files
with
277 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/family_fun_pack/commands/DisconnectCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package family_fun_pack.commands; | ||
|
||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
|
||
import family_fun_pack.FamilyFunPack; | ||
|
||
@SideOnly(Side.CLIENT) | ||
public class DisconnectCommand extends Command { | ||
|
||
public DisconnectCommand() { | ||
super("disconnect"); | ||
} | ||
|
||
public String usage() { | ||
return this.getName(); | ||
} | ||
|
||
public String execute(String[] args) { | ||
FamilyFunPack.getNetworkHandler().disconnect(); | ||
return null; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/family_fun_pack/commands/OpenDonkeyCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package family_fun_pack.commands; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.entity.passive.EntityDonkey; | ||
import net.minecraft.inventory.ContainerHorseChest; | ||
import net.minecraft.network.EnumPacketDirection; | ||
import net.minecraft.network.Packet; | ||
import net.minecraft.network.play.client.CPacketEntityAction; | ||
import net.minecraft.network.play.server.SPacketOpenWindow; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
|
||
import family_fun_pack.FamilyFunPack; | ||
import family_fun_pack.entities.EntityVoid; | ||
import family_fun_pack.network.PacketListener; | ||
|
||
@SideOnly(Side.CLIENT) | ||
public class OpenDonkeyCommand extends Command implements PacketListener { | ||
|
||
public OpenDonkeyCommand() { | ||
super("open"); | ||
} | ||
|
||
public String usage() { | ||
return this.getName(); | ||
} | ||
|
||
public String execute(String[] args) { | ||
FamilyFunPack.getNetworkHandler().registerListener(EnumPacketDirection.CLIENTBOUND, this, 19); | ||
FamilyFunPack.getNetworkHandler().sendPacket(new CPacketEntityAction(new EntityVoid(Minecraft.getMinecraft().world, 0), CPacketEntityAction.Action.OPEN_INVENTORY)); | ||
return null; | ||
} | ||
|
||
public void onDisconnect() { | ||
FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.CLIENTBOUND, this, 19); | ||
} | ||
|
||
public Packet<?> packetReceived(EnumPacketDirection direction, int id, Packet<?> packet, ByteBuf in) { | ||
SPacketOpenWindow open = (SPacketOpenWindow) packet; | ||
|
||
// Unregister in any case, don't keep listening | ||
FamilyFunPack.getNetworkHandler().unregisterListener(EnumPacketDirection.CLIENTBOUND, this, 19); | ||
|
||
if("EntityHorse".equals(open.getGuiId())) { | ||
Minecraft mc = Minecraft.getMinecraft(); | ||
EntityDonkey fake = new EntityDonkey(mc.world); // Let's assume it's a donkey | ||
fake.setEntityId(open.getEntityId()); | ||
fake.setHorseSaddled(true); | ||
fake.setChested(true); | ||
mc.player.openGuiHorseInventory(fake, new ContainerHorseChest(open.getWindowTitle(), open.getSlotCount())); | ||
mc.player.openContainer.windowId = open.getWindowId(); | ||
return null; | ||
} | ||
return packet; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.