Skip to content

Commit

Permalink
Now using Simple Network Implementation. IMessage instead of IPacket.
Browse files Browse the repository at this point in the history
  • Loading branch information
zoonie committed Jan 10, 2015
1 parent 2323ae4 commit 2a7964c
Show file tree
Hide file tree
Showing 27 changed files with 1,215 additions and 1,153 deletions.
123 changes: 64 additions & 59 deletions java/com/dynious/soundscool/SoundsCool.java
Original file line number Diff line number Diff line change
@@ -1,59 +1,64 @@
package com.dynious.soundscool;

import com.dynious.soundscool.block.ModBlocks;
import com.dynious.soundscool.command.CommandSoundsCool;
import com.dynious.soundscool.creativetab.CreativeTabSoundsCool;
import com.dynious.soundscool.handler.GuiHandler;
import com.dynious.soundscool.handler.SoundHandler;
import com.dynious.soundscool.lib.Reference;
import com.dynious.soundscool.proxy.CommonProxy;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import net.minecraft.creativetab.CreativeTabs;

@Mod(modid = Reference.modid, name = Reference.name, version = Reference.version)
public class SoundsCool
{
@Instance(Reference.modid)
public static SoundsCool instance;

@SidedProxy(clientSide = Reference.clientProxy, serverSide = Reference.commonProxy)
public static CommonProxy proxy;

public static CreativeTabs tabSoundsCool = new CreativeTabSoundsCool(CreativeTabs.getNextID(), Reference.modid);

@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
proxy.soundSetup();

proxy.UISetup();

SoundHandler.findSounds();

ModBlocks.init();

proxy.initNetworking();
}

@EventHandler
public void init(FMLInitializationEvent event)
{

proxy.initTileEntities();

NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
}

@EventHandler
public void serverStarting(FMLServerStartingEvent event)
{
event.registerServerCommand(new CommandSoundsCool());
}
}
package com.dynious.soundscool;

import net.minecraft.creativetab.CreativeTabs;

import com.dynious.soundscool.block.ModBlocks;
import com.dynious.soundscool.command.CommandSoundsCool;
import com.dynious.soundscool.creativetab.CreativeTabSoundsCool;
import com.dynious.soundscool.handler.GuiHandler;
import com.dynious.soundscool.handler.SoundHandler;
import com.dynious.soundscool.lib.Reference;
import com.dynious.soundscool.proxy.CommonProxy;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;

@Mod(modid = Reference.modid, name = Reference.name, version = Reference.version)
public class SoundsCool
{
@Instance(Reference.modid)
public static SoundsCool instance;

@SidedProxy(clientSide = Reference.clientProxy, serverSide = Reference.commonProxy)
public static CommonProxy proxy;

public static CreativeTabs tabSoundsCool = new CreativeTabSoundsCool(CreativeTabs.getNextID(), Reference.modid);

public static SimpleNetworkWrapper network = NetworkRegistry.INSTANCE.newSimpleChannel("soundscool");

@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
proxy.registerMessages();

proxy.soundSetup();

proxy.UISetup();

SoundHandler.findSounds();

ModBlocks.init();
}

@EventHandler
public void init(FMLInitializationEvent event)
{

proxy.initTileEntities();

NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
}

@EventHandler
public void serverStarting(FMLServerStartingEvent event)
{
event.registerServerCommand(new CommandSoundsCool());
}
}
148 changes: 75 additions & 73 deletions java/com/dynious/soundscool/client/gui/GuiAdminPanel.java
Original file line number Diff line number Diff line change
@@ -1,73 +1,75 @@
package com.dynious.soundscool.client.gui;

import com.dynious.soundscool.SoundsCool;
import com.dynious.soundscool.network.packet.client.GetUploadedSoundsPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;

public class GuiAdminPanel extends GuiScreen
{
private EntityPlayer player;
private GuiTextField maxSounds;

public GuiAdminPanel(EntityPlayer player)
{
this.player = player;
SoundsCool.proxy.getChannel().writeOutbound(new GetUploadedSoundsPacket(player));
}

@Override
public void initGui()
{
super.initGui();
this.buttonList.add(new GuiButton(0, getWidth() / 2, getHeight() - 42, I18n.format("gui.done")));
maxSounds = new GuiTextField(fontRendererObj, getWidth()/2, getHeight()/2, 20, 15);
}

@Override
public void updateScreen()
{
super.updateScreen();
}

@Override
public void drawScreen(int p_571_1_, int p_571_2_, float p_571_3_)
{

}

@Override
protected void actionPerformed(GuiButton button)
{
if (button.enabled)
{
switch (button.id)
{
case 0:
this.mc.displayGuiScreen(null);
this.mc.setIngameFocus();
break;

}
}
}

public int getWidth()
{
return width;
}

public int getHeight()
{
return height;
}

@Override
public boolean doesGuiPauseGame()
{
return false;
}
}
package com.dynious.soundscool.client.gui;

import com.dynious.soundscool.SoundsCool;
import com.dynious.soundscool.helper.NetworkHelper;
import com.dynious.soundscool.network.packet.client.GetUploadedSoundsPacket;

import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;

public class GuiAdminPanel extends GuiScreen
{
private EntityPlayer player;
private GuiTextField maxSounds;

public GuiAdminPanel(EntityPlayer player)
{
this.player = player;
NetworkHelper.syncPlayerSounds(player);
}

@Override
public void initGui()
{
super.initGui();
this.buttonList.add(new GuiButton(0, getWidth() / 2, getHeight() - 42, I18n.format("gui.done")));
maxSounds = new GuiTextField(fontRendererObj, getWidth()/2, getHeight()/2, 20, 15);
}

@Override
public void updateScreen()
{
super.updateScreen();
}

@Override
public void drawScreen(int p_571_1_, int p_571_2_, float p_571_3_)
{

}

@Override
protected void actionPerformed(GuiButton button)
{
if (button.enabled)
{
switch (button.id)
{
case 0:
this.mc.displayGuiScreen(null);
this.mc.setIngameFocus();
break;

}
}
}

public int getWidth()
{
return width;
}

public int getHeight()
{
return height;
}

@Override
public boolean doesGuiPauseGame()
{
return false;
}
}
Loading

0 comments on commit 2a7964c

Please sign in to comment.