Partially working, partially not
parent
11b5f4a564
commit
fc9265cebe
@ -0,0 +1,25 @@
|
||||
package net.brokenmoon.afloydtubemod;
|
||||
|
||||
import net.brokenmoon.afloydtubemod.block.BlockTransposer;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.Material;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import turniplabs.halplibe.helper.BlockHelper;
|
||||
|
||||
|
||||
public class Afloydtubemod implements ModInitializer {
|
||||
public static final String MOD_ID = "tubemod";
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||
|
||||
public static final Block tubeBlock = BlockHelper.createBlock(MOD_ID, new Block(904, Material.iron), "tubeBlock", "testTexture.png", Block.soundMetalFootstep, 5, 5, 0);
|
||||
public static final Block transposerBlock = BlockHelper.createBlock(MOD_ID, new BlockTransposer(905, Material.iron), "transposerBlock", "testTexture.png", Block.soundMetalFootstep, 5, 5, 0);
|
||||
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
LOGGER.info("Afloydtubemod initialized.");
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package net.brokenmoon.afloydtubemod.block;
|
||||
|
||||
import net.brokenmoon.afloydtubemod.mixinInterface.IEntityPlayer;
|
||||
import net.brokenmoon.afloydtubemod.tileEntity.TileEntityTransposer;
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public class BlockTransposer extends BlockContainerRotatable {
|
||||
|
||||
private boolean isActive;
|
||||
public BlockTransposer(int i, Material material) {
|
||||
super(i, material);
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public void onBlockAdded(World world, int i, int j, int k) {
|
||||
super.onBlockAdded(world, i, j, k);
|
||||
this.setDefaultDirection(world, i, j, k);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean blockActivated(World world, int x, int y, int z, EntityPlayer entityplayer) {
|
||||
IInventory inventory = (TileEntityTransposer)world.getBlockTileEntity(x, y, z);
|
||||
if (!world.isMultiplayerAndNotHost)
|
||||
this.displayGui(entityplayer, inventory);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TileEntity getBlockEntity() {
|
||||
return new TileEntityTransposer();
|
||||
}
|
||||
|
||||
public static void displayGui(EntityPlayer player, IInventory inventory){
|
||||
if(player instanceof EntityPlayerMP) {
|
||||
//Multiplayer
|
||||
((IEntityPlayer)player).displayGUITransposer(inventory);
|
||||
return;
|
||||
}
|
||||
//Singleplayer
|
||||
System.out.println("One");
|
||||
((IEntityPlayer)player).displayGUITransposer(inventory);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package net.brokenmoon.afloydtubemod.block;
|
||||
|
||||
import net.minecraft.src.BlockContainer;
|
||||
import net.minecraft.src.Material;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.brokenmoon.afloydtubemod.tileEntity.TileEntityTube;
|
||||
|
||||
public class BlockTube extends BlockContainer {
|
||||
|
||||
|
||||
public BlockTube(int i, Material material) {
|
||||
super(i, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TileEntity getBlockEntity(){
|
||||
return new TileEntityTube();
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package net.brokenmoon.afloydtubemod.gui;
|
||||
|
||||
import net.minecraft.src.*;
|
||||
|
||||
|
||||
public class ContainerTransposer extends Container {
|
||||
|
||||
private IInventory inventory;
|
||||
private int numberOfRowsUpper;
|
||||
|
||||
public ContainerTransposer(IInventory lowerInventory, IInventory upperInventory) {
|
||||
this.inventory = upperInventory;
|
||||
this.numberOfRowsUpper = upperInventory.getSizeInventory() / 3;
|
||||
//Upper
|
||||
for (int j = 0; j < this.numberOfRowsUpper; ++j) {
|
||||
for (int i1 = 0; i1 < 12; ++i1) {
|
||||
this.addSlot(new Slot(upperInventory, i1 + j * 12, 8 + i1 * 18, 8 + j * 18));
|
||||
}
|
||||
}
|
||||
//Lower
|
||||
for (int k = 0; k < 3; ++k) {
|
||||
for (int j1 = 0; j1 < 9; ++j1) {
|
||||
this.addSlot(new Slot(lowerInventory, j1 + k * 9 + 9, 8 + 18 + 9 + j1 * 18, 174 + k * 18));
|
||||
}
|
||||
}
|
||||
//Taskbar
|
||||
for (int l = 0; l < 9; ++l) {
|
||||
this.addSlot(new Slot(lowerInventory, l, 8 + 18 + 9 + l * 18, 232));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void quickMoveItems(int slotID, EntityPlayer player, boolean shift, boolean control) {
|
||||
Slot slot = (Slot)this.inventorySlots.get(slotID);
|
||||
if (slot == null || !slot.hasStack()) {
|
||||
return;
|
||||
}
|
||||
ItemStack item = slot.getStack();
|
||||
ItemStack originalItem = item.copy();
|
||||
if (slotID < this.numberOfRowsUpper * 12) {
|
||||
this.onStackMergeShiftClick(item, this.numberOfRowsUpper * 3, this.inventorySlots.size(), true);
|
||||
} else {
|
||||
this.onStackMergeShiftClick(item, 0, this.numberOfRowsUpper * 3, false);
|
||||
}
|
||||
if (item.stackSize == 0) {
|
||||
slot.putStack(null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
if (item.stackSize != originalItem.stackSize) {
|
||||
slot.onPickupFromSlot(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsableByPlayer(EntityPlayer entityPlayer) {
|
||||
return this.inventory.canInteractWith(entityPlayer);
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package net.brokenmoon.afloydtubemod.gui;
|
||||
|
||||
import net.minecraft.src.GuiContainer;
|
||||
import net.minecraft.src.IInventory;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiTransposer extends GuiContainer {
|
||||
private IInventory upperChestInventory;
|
||||
private IInventory lowerChestInventory;
|
||||
private int inventoryRows;
|
||||
public GuiTransposer(IInventory iinventory, IInventory iinventory1) {
|
||||
super(new ContainerTransposer(iinventory, iinventory1));
|
||||
this.upperChestInventory = iinventory;
|
||||
this.lowerChestInventory = iinventory1;
|
||||
this.field_948_f = false;
|
||||
this.inventoryRows = iinventory1.getSizeInventory() / 3;
|
||||
this.ySize = 176;
|
||||
this.xSize = 166;
|
||||
System.out.println("Three");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f) {
|
||||
int i = this.mc.renderEngine.getTexture("/assets/tubemod/gui/containerTransposer.png");
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
this.mc.renderEngine.bindTexture(i);
|
||||
int x = (this.width - this.xSize) / 2;
|
||||
int y = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package net.brokenmoon.afloydtubemod.mixin;
|
||||
|
||||
import net.brokenmoon.afloydtubemod.gui.ContainerTransposer;
|
||||
import net.brokenmoon.afloydtubemod.mixinInterface.IEntityPlayer;
|
||||
import net.minecraft.src.EntityPlayerMP;
|
||||
import net.minecraft.src.IInventory;
|
||||
import net.minecraft.src.NetServerHandler;
|
||||
import net.minecraft.src.Packet100OpenWindow;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(value = EntityPlayerMP.class, remap = false)
|
||||
public class MixinEntityPlayerMP implements IEntityPlayer {
|
||||
@Shadow
|
||||
private void getNextWindowId() {}
|
||||
@Shadow
|
||||
private int currentWindowId;
|
||||
@Shadow
|
||||
public NetServerHandler playerNetServerHandler;
|
||||
|
||||
@Override
|
||||
public void displayGUITransposer(IInventory iInventory) {
|
||||
this.getNextWindowId();
|
||||
NetServerHandler.logger.info(((EntityPlayerMP)(Object)this).username + " interacted with chest at (" + ((EntityPlayerMP)(Object)this).posX + ", " + ((EntityPlayerMP)(Object)this).posY + ", " + ((EntityPlayerMP)(Object)this).posZ + ")");
|
||||
this.playerNetServerHandler.sendPacket(new Packet100OpenWindow(this.currentWindowId, 8, iInventory.getInvName(), iInventory.getSizeInventory()));
|
||||
((EntityPlayerMP)(Object)this).craftingInventory = new ContainerTransposer(((EntityPlayerMP)(Object)this).inventory, iInventory);
|
||||
((EntityPlayerMP)(Object)this).craftingInventory.windowId = this.currentWindowId;
|
||||
((EntityPlayerMP)(Object)this).craftingInventory.onContainerInit(((EntityPlayerMP)(Object)this));
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package net.brokenmoon.afloydtubemod.mixin;
|
||||
|
||||
import net.brokenmoon.afloydtubemod.gui.GuiTransposer;
|
||||
import net.brokenmoon.afloydtubemod.mixinInterface.IEntityPlayer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.EntityPlayerSP;
|
||||
import net.minecraft.src.IInventory;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(value = EntityPlayerSP.class, remap = false)
|
||||
public class MixinEntityPlayerSP implements IEntityPlayer {
|
||||
@Shadow
|
||||
protected Minecraft mc;
|
||||
@Override
|
||||
public void displayGUITransposer(IInventory iInventory) {
|
||||
System.out.println("Two");
|
||||
this.mc.displayGuiScreen(new GuiTransposer(((EntityPlayerSP)(Object)this).inventory, iInventory));
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package net.brokenmoon.afloydtubemod.mixin;
|
||||
|
||||
import net.brokenmoon.afloydtubemod.mixinInterface.IEntityPlayer;
|
||||
import net.brokenmoon.afloydtubemod.tileEntity.TileEntityTransposer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.NetClientHandler;
|
||||
import net.minecraft.src.Packet100OpenWindow;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(value = NetClientHandler.class, remap = false)
|
||||
public class MixinNetClientHandler {
|
||||
@Shadow
|
||||
private Minecraft mc;
|
||||
|
||||
@Inject(method = "handleOpenWindow", at = @At("TAIL"))
|
||||
public void injectMethod(Packet100OpenWindow packet100openwindow, CallbackInfo info) {
|
||||
if (packet100openwindow.inventoryType == 8) {
|
||||
TileEntityTransposer trans = new TileEntityTransposer();
|
||||
((IEntityPlayer)this.mc.thePlayer).displayGUITransposer(trans);
|
||||
this.mc.thePlayer.craftingInventory.windowId = packet100openwindow.windowId;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package net.brokenmoon.afloydtubemod.mixin;
|
||||
|
||||
import net.brokenmoon.afloydtubemod.tileEntity.TileEntityTransposer;
|
||||
import net.brokenmoon.afloydtubemod.tileEntity.TileEntityTube;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(value = TileEntity.class, remap = false)
|
||||
public class MixinTileEntity {
|
||||
@Shadow
|
||||
private static void addMapping(Class class1, String s) {}
|
||||
|
||||
static {
|
||||
addMapping(TileEntityTransposer.class, "Iron Chest");
|
||||
addMapping(TileEntityTube.class, "Gold Chest");
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package net.brokenmoon.afloydtubemod.mixinInterface;
|
||||
|
||||
import net.minecraft.src.IInventory;
|
||||
|
||||
public interface IEntityPlayer {
|
||||
public void displayGUITransposer(IInventory iInventory);
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package net.brokenmoon.afloydtubemod.tileEntity;
|
||||
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.IInventory;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public class TileEntityTransposer extends TileEntity implements IInventory {
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemStack) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityPlayer) {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package net.brokenmoon.afloydtubemod.tileEntity;
|
||||
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public class TileEntityTube extends TileEntity {
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package turniplabs.examplemod;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class ExampleMod implements ModInitializer {
|
||||
public static final String MOD_ID = "examplemod";
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
LOGGER.info("ExampleMod initialized.");
|
||||
}
|
||||
}
|
@ -1,9 +1,13 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "turniplabs.examplemod.mixin",
|
||||
"package": "net.brokenmoon.afloydtubemod.mixin",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"MixinEntityPlayerSP",
|
||||
"MixinEntityPlayerMP",
|
||||
"MixinNetClientHandler",
|
||||
"MixinTileEntity"
|
||||
],
|
||||
"client": [
|
||||
],
|
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
@ -0,0 +1,2 @@
|
||||
item.afloydtubemod.item.name=Test Item
|
||||
item.afloydtubemod.item.desc=Test Desc.
|
Loading…
Reference in New Issue