More progress towards multiplayer

main
Astoria 2 years ago
parent dbbe82936a
commit 327afae1d2

@ -29,14 +29,18 @@ public class WireMod implements ModInitializer {
AccessorPacket.callAddIdClassMapping(111, true, true, WiremodWiringGuiPacket.class);
AccessorPacket.callAddIdClassMapping(112, true, true, WiremodPacketSyncIO.class);
AccessorPacket.callAddIdClassMapping(113, true, true, WiremodWiringPacket.class);
AccessorPacket.callAddIdClassMapping(114, true, true, WiremodSettingsGuiPacket.class);
AccessorPacket.callAddIdClassMapping(500, true, true, WiremodWireGuiPacket.class);
}
public static final String MOD_ID = "afloydwiremod";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
public static Block ChipTile = BlockHelper.createBlock(MOD_ID, new ChipTile(905, Material.iron), "chipTile", "chip.png", Block.soundMetalFootstep,1.5f, 6f, 0 );
public static Item ToolProgrammer = ItemHelper.createItem(MOD_ID, new ToolProgrammer(906), "toolProgrammer", "progtool.png");
public static Item ToolWiring = ItemHelper.createItem(MOD_ID, new ToolWiring(907), "toolWiring", "wiretool.png");
public static ToolWiring ToolWiringClass = new ToolWiring(907);
public static Item ToolWiring = ItemHelper.createItem(MOD_ID, ToolWiringClass, "toolWiring", "wiretool.png");
public static Block LinkTileInactive = BlockHelper.createBlock(MOD_ID, new RedstoneLinkTile(908, Material.iron, false), "linkTile", "linkOff.png", Block.soundStoneFootstep, 1.5f, 6f, 0);
public static Block LinkTileActive = BlockHelper.createBlock(MOD_ID, new RedstoneLinkTile(909, Material.iron, true), "linkTile", "linkOn.png", Block.soundStoneFootstep, 1.5f, 6f, 0);

@ -12,6 +12,7 @@ public abstract class AbstractWireTileEntity extends TileEntity {
public void update() {
updateIO();
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
}
@Override
@ -96,7 +97,7 @@ public abstract class AbstractWireTileEntity extends TileEntity {
}
}
}
worldObj.markBlocksDirty(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
}
public void prepForDelete() {
@ -112,6 +113,8 @@ public abstract class AbstractWireTileEntity extends TileEntity {
otherChip.inputs[wire.thatslot].wire.isMade = false;
this.updateIO();
otherChip.updateIO();
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
worldObj.markBlockNeedsUpdate(wire.x, wire.y, wire.z);
}
}
}
@ -121,7 +124,7 @@ public abstract class AbstractWireTileEntity extends TileEntity {
if (inputs[i].wire != null && inputs[i].wire.thisslot > -1) {
WireConnection wire = inputs[i].wire;
AbstractWireTileEntity otherChip = (AbstractWireTileEntity)this.worldObj.getBlockTileEntity(wire.x, wire.y, wire.z);
if(otherChip != null && otherChip.outputs != null) {
if(otherChip != null && otherChip.outputs != null && otherChip.outputs.length > wire.thatslot) {
otherChip.outputs[wire.thatslot].wire.isMade = false;
otherChip.updateIO();
}

@ -1,5 +1,6 @@
package net.brokenmoon.afloydwiremod.gui;
import net.brokenmoon.afloydwiremod.WireMod;
import net.brokenmoon.afloydwiremod.item.ToolWiring;
import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity;
import net.minecraft.client.Minecraft;
@ -15,9 +16,9 @@ public class GuiWireTool extends GuiScreen {
public GuiSlider blue;
public GuiSlider alpha;
public GuiSlider widthslider;
public GuiWireTool(EntityPlayerSP entityPlayerSP, ToolWiring toolWiring) {
public GuiWireTool(EntityPlayerSP entityPlayerSP) {
super.initGui();
this.tool = toolWiring;
this.tool = WireMod.ToolWiringClass;
}
@Override

@ -79,7 +79,7 @@ public class GuiWiring extends GuiScrollable {
tool.sideadd = new ArrayList<Integer>();
}
} else if(!this.tool.type.equals("unpaired")) {
if(this.tool.type.equals("input") && wireEntity.outputs[guibutton.slot].wire.isMade != true && otherEntity.inputs[tool.slot].wire.isMade != true) {
if(this.tool.type.equals("input") && wireEntity.outputs[guibutton.slot].wire.isMade != true && otherEntity != null && otherEntity.inputs[tool.slot].wire.isMade != true) {
if(this.player instanceof EntityClientPlayerMP){
NetClientHandler netclienthandler = ((EntityClientPlayerMP)this.mc.thePlayer).sendQueue;
netclienthandler.addToSendQueue(new WiremodWiringPacket(wireEntity.xCoord, wireEntity.yCoord, wireEntity.zCoord, this.tool.x, this.tool.y, this.tool.z, guibutton.slot, tool.slot, tool.xadd, tool.yadd, tool.zadd, tool.sideadd, false, tool.red, tool.green, tool.blue, tool.alpha, tool.width));
@ -93,7 +93,12 @@ public class GuiWiring extends GuiScrollable {
otherEntity.update();
otherEntity.updateIO();
}
} else if(this.tool.type.equals("output") && otherEntity.outputs[tool.slot].wire.isMade != true && wireEntity.inputs[guibutton.slot].wire.isMade != true ) {
tool.xadd = new ArrayList<Integer>();
tool.yadd = new ArrayList<Integer>();
tool.zadd = new ArrayList<Integer>();
tool.sideadd = new ArrayList<Integer>();
tool.type = "unpaired";
} else if(this.tool.type.equals("output") && otherEntity.outputs[tool.slot].wire.isMade != true && otherEntity != null && wireEntity.inputs[guibutton.slot].wire.isMade != true ) {
if(otherEntity != null) {
if(this.player instanceof EntityClientPlayerMP){
NetClientHandler netclienthandler = ((EntityClientPlayerMP)this.mc.thePlayer).sendQueue;

@ -33,7 +33,7 @@ public class ToolWiring extends Item {
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l, double heightPlaced) {
if(entityplayer.isSneaking()){
if (!world.isMultiplayerAndNotHost) {
this.displayWireSettings(entityplayer, this);
this.displayWireSettings(entityplayer);
return true;
}
} else {
@ -46,14 +46,14 @@ public class ToolWiring extends Item {
return false;
}
private void displayWireSettings(EntityPlayer player, ToolWiring toolWiring) {
private void displayWireSettings(EntityPlayer player) {
if(player instanceof EntityPlayerMP) {
//Multiplayer
((IEntityPlayer)player).displayGuiWireSettings(toolWiring);
((IEntityPlayer)player).displayGuiWireSettings();
return;
}
//Singleplayer
((IEntityPlayer)player).displayGuiWireSettings(toolWiring);
((IEntityPlayer)player).displayGuiWireSettings();
}
@Override

@ -4,6 +4,8 @@ import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
import net.brokenmoon.afloydwiremod.item.ToolWiring;
import net.brokenmoon.afloydwiremod.mixinInterfaces.IEntityPlayer;
import net.brokenmoon.afloydwiremod.packet.WiremodProgrammerGuiPacket;
import net.brokenmoon.afloydwiremod.packet.WiremodSettingsGuiPacket;
import net.brokenmoon.afloydwiremod.packet.WiremodWireGuiPacket;
import net.brokenmoon.afloydwiremod.packet.WiremodWiringGuiPacket;
import net.minecraft.src.*;
import org.spongepowered.asm.mixin.Mixin;
@ -27,11 +29,11 @@ public class MixinEntityPlayerMP implements IEntityPlayer {
@Override
public void displayGuiSettings(AbstractWireTileEntity chip) {
this.playerNetServerHandler.sendPacket(new WiremodSettingsGuiPacket(chip.xCoord, chip.yCoord, chip.zCoord));
}
@Override
public void displayGuiWireSettings(ToolWiring toolWiring) {
public void displayGuiWireSettings() {
this.playerNetServerHandler.sendPacket(new WiremodWireGuiPacket());
}
}

@ -34,7 +34,7 @@ public class MixinEntityPlayerSP implements IEntityPlayer {
}
@Override
public void displayGuiWireSettings(ToolWiring toolWiring) {
this.mc.displayGuiScreen(new GuiWireTool(((EntityPlayerSP)(Object)this), toolWiring));
public void displayGuiWireSettings() {
this.mc.displayGuiScreen(new GuiWireTool(((EntityPlayerSP)(Object)this)));
}
}

@ -1,5 +1,6 @@
package net.brokenmoon.afloydwiremod.mixin;
import net.brokenmoon.afloydwiremod.WireMod;
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
import net.brokenmoon.afloydwiremod.gui.GuiWiring;
import net.brokenmoon.afloydwiremod.item.ToolWiring;
@ -50,4 +51,14 @@ public class MixinNetClientHandler implements INetHandler {
public void wiremodHandleWireChips(WiremodWiringPacket wiremodWiringPacket) {
}
@Override
public void wiremodHandleWireToolGui(WiremodSettingsGuiPacket wiremodSettingsGuiPacket) {
}
@Override
public void wiremodHandleWireToolSettingsGui(WiremodWireGuiPacket wiremodWireGuiPacket) {
((IEntityPlayer)this.mc.thePlayer).displayGuiWireSettings();
}
}

@ -50,7 +50,7 @@ public class MixinNetServerHandler implements INetHandler {
wireEntity.outputs[packet.slot1].wire = new WireConnection(packet.x2, packet.y2, packet.z2, packet.slot1, packet.slot2, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), packet.backwired, packet.red, packet.green, packet.blue, packet.alpha, packet.width);
} else{
wireEntity = (AbstractWireTileEntity) this.mcServer.getWorldManager(this.playerEntity.dimension).getBlockTileEntity(packet.x2, packet.y2, packet.z2);
wireEntity.outputs[packet.slot1].wire = new WireConnection(packet.x1, packet.y1, packet.z1, packet.slot1, packet.slot2, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), packet.backwired, packet.red, packet.green, packet.blue, packet.alpha, packet.width);
wireEntity.outputs[packet.slot2].wire = new WireConnection(packet.x1, packet.y1, packet.z1, packet.slot1, packet.slot2, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), packet.backwired, packet.red, packet.green, packet.blue, packet.alpha, packet.width);
}
wireEntity.update();
wireEntity.updateIO();
@ -62,12 +62,23 @@ public class MixinNetServerHandler implements INetHandler {
otherEntity.inputs[packet.slot2].wire = new WireConnection(packet.x2, packet.y2, packet.z2, packet.slot1, packet.slot2);
} else{
otherEntity = (AbstractWireTileEntity)this.mcServer.getWorldManager(this.playerEntity.dimension).getBlockTileEntity(packet.x2, packet.y2, packet.z2);
otherEntity.inputs[packet.slot2].wire = new WireConnection(packet.x1, packet.y1, packet.z1, packet.slot1, packet.slot2);
otherEntity.inputs[packet.slot1].wire = new WireConnection(packet.x1, packet.y1, packet.z1, packet.slot1, packet.slot2);
}
otherEntity.update();
otherEntity.updateIO();
break;
}
System.out.println("9");
this.mcServer.getWorldManager(this.playerEntity.dimension).markBlockNeedsUpdate(packet.x1, packet.y1, packet.z1);
this.mcServer.getWorldManager(this.playerEntity.dimension).markBlockNeedsUpdate(packet.x2, packet.y2, packet.z2);
}
@Override
public void wiremodHandleWireToolGui(WiremodSettingsGuiPacket wiremodSettingsGuiPacket) {
}
@Override
public void wiremodHandleWireToolSettingsGui(WiremodWireGuiPacket wiremodWireGuiPacket) {
}
}

@ -9,5 +9,5 @@ public interface IEntityPlayer {
public void displayGuiWiring(ToolWiring tool, AbstractWireTileEntity chip, int x, int y, int z);
public void displayGuiSettings(AbstractWireTileEntity chip);
public void displayGuiWireSettings(ToolWiring toolWiring);
public void displayGuiWireSettings();
}

@ -12,4 +12,8 @@ public interface INetHandler {
void wiremodHandleIODisc(WiremodPacketSyncIO wiremodPacketSyncIO);
void wiremodHandleWireChips(WiremodWiringPacket wiremodWiringPacket);
void wiremodHandleWireToolGui(WiremodSettingsGuiPacket wiremodSettingsGuiPacket);
void wiremodHandleWireToolSettingsGui(WiremodWireGuiPacket wiremodWireGuiPacket);
}

@ -0,0 +1,34 @@
package net.brokenmoon.afloydwiremod.packet;
import net.brokenmoon.afloydwiremod.mixinInterfaces.INetHandler;
import net.minecraft.src.NetHandler;
import net.minecraft.src.Packet;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class WiremodSettingsGuiPacket extends Packet {
public WiremodSettingsGuiPacket(int xCoord, int yCoord, int zCoord) {
}
@Override
public void readPacketData(DataInputStream dataInputStream) throws IOException {
}
@Override
public void writePacketData(DataOutputStream dataOutputStream) throws IOException {
}
@Override
public void processPacket(NetHandler netHandler) {
}
@Override
public int getPacketSize() {
return 0;
}
}

@ -0,0 +1,31 @@
package net.brokenmoon.afloydwiremod.packet;
import net.brokenmoon.afloydwiremod.mixinInterfaces.INetHandler;
import net.minecraft.src.NetHandler;
import net.minecraft.src.Packet;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class WiremodWireGuiPacket extends Packet {
@Override
public void readPacketData(DataInputStream dataInputStream) throws IOException {
}
@Override
public void writePacketData(DataOutputStream dataOutputStream) throws IOException {
}
@Override
public void processPacket(NetHandler netHandler) {
((INetHandler)netHandler).wiremodHandleWireToolSettingsGui(this);
}
@Override
public int getPacketSize() {
return 0;
}
}

@ -132,6 +132,7 @@ public class ChipTileEntity extends AbstractWireTileEntity {
doPulse();
break;
}
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
}
private void doPulse() {

@ -43,5 +43,6 @@ public class RedstoneLinkTileEntity extends AbstractWireTileEntity {
this.shouldnotremove = false;
this.isActive = false;
}
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
}
}

Loading…
Cancel
Save