mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 08:48:34 +01:00
Completely changed the way packets are handled and removed client data file
This commit is contained in:
parent
ac6cf7c3bc
commit
daaad16a32
37 changed files with 598 additions and 786 deletions
|
@ -19,6 +19,7 @@ import de.ellpeck.actuallyadditions.mod.booklet.button.BookmarkButton;
|
|||
import de.ellpeck.actuallyadditions.mod.booklet.button.IndexButton;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.button.TexturedButton;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntryAllSearch;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.entry.EntrySet;
|
||||
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
|
@ -28,6 +29,8 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.stats.Achievement;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
|
@ -290,6 +293,8 @@ public class BookletUtils{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
booklet.changedPageSinceOpen = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -345,6 +350,8 @@ public class BookletUtils{
|
|||
for(GuiButton chapterButton : booklet.chapterButtons){
|
||||
chapterButton.visible = false;
|
||||
}
|
||||
|
||||
booklet.changedPageSinceOpen = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -409,6 +416,8 @@ public class BookletUtils{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
booklet.changedPageSinceOpen = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -433,6 +442,8 @@ public class BookletUtils{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
booklet.changedPageSinceOpen = true;
|
||||
}
|
||||
|
||||
public static BookletPage getFirstPageForStack(ItemStack stack){
|
||||
|
@ -449,4 +460,50 @@ public class BookletUtils{
|
|||
}
|
||||
return possiblePages;
|
||||
}
|
||||
|
||||
public static void saveBookPage(GuiBooklet gui, NBTTagCompound compound){
|
||||
//Save Entry etc.
|
||||
compound.setTag("SavedEntry", gui.currentEntrySet.writeToNBT());
|
||||
compound.setString("SearchWord", gui.searchField.getText());
|
||||
|
||||
//Save Bookmarks
|
||||
NBTTagList list = new NBTTagList();
|
||||
for(int i = 0; i < gui.bookmarkButtons.length; i++){
|
||||
BookmarkButton button = (BookmarkButton)gui.bookmarkButtons[i];
|
||||
|
||||
list.appendTag(button.assignedEntry.writeToNBT());
|
||||
}
|
||||
compound.setTag("Bookmarks", list);
|
||||
}
|
||||
|
||||
public static void openLastBookPage(GuiBooklet gui, NBTTagCompound compound){
|
||||
//Open Entry etc.
|
||||
EntrySet set = EntrySet.readFromNBT(compound.getCompoundTag("SavedEntry"));
|
||||
if(set != null){
|
||||
|
||||
BookletUtils.openIndexEntry(gui, set.entry, set.pageInIndex, true);
|
||||
if(set.chapter != null){
|
||||
BookletUtils.openChapter(gui, set.chapter, set.page);
|
||||
}
|
||||
|
||||
String searchText = compound.getString("SearchWord");
|
||||
if(!searchText.isEmpty()){
|
||||
gui.searchField.setText(searchText);
|
||||
BookletUtils.updateSearchBar(gui);
|
||||
}
|
||||
}
|
||||
else{
|
||||
//If everything fails, initialize the front page
|
||||
BookletUtils.openIndexEntry(gui, null, 1, true);
|
||||
}
|
||||
|
||||
//Load Bookmarks
|
||||
NBTTagList list = compound.getTagList("Bookmarks", 10);
|
||||
if(list != null){
|
||||
for(int i = 0; i < list.tagCount(); i++){
|
||||
BookmarkButton button = (BookmarkButton)gui.bookmarkButtons[i];
|
||||
button.assignedEntry = EntrySet.readFromNBT(list.getCompoundTagAt(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,11 @@ import de.ellpeck.actuallyadditions.mod.booklet.button.TexturedButton;
|
|||
import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntryAllSearch;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.entry.EntrySet;
|
||||
import de.ellpeck.actuallyadditions.mod.config.GuiConfiguration;
|
||||
import de.ellpeck.actuallyadditions.mod.data.ExtraClientData;
|
||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemBooklet;
|
||||
import de.ellpeck.actuallyadditions.mod.misc.SoundHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
|
||||
import de.ellpeck.actuallyadditions.mod.update.UpdateChecker;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
|
@ -38,6 +40,7 @@ import net.minecraft.client.gui.GuiTextField;
|
|||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
@ -88,6 +91,7 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{
|
|||
private int ticksElapsed;
|
||||
private boolean mousePressed;
|
||||
private int hisNameIsAt;
|
||||
public boolean changedPageSinceOpen;
|
||||
|
||||
public GuiBooklet(GuiScreen parentScreen, boolean tryOpenMainPage, boolean saveOnClose){
|
||||
this.xSize = 146;
|
||||
|
@ -374,14 +378,23 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{
|
|||
|
||||
if(ItemBooklet.forcedEntry == null){
|
||||
//Open last entry or introductory entry
|
||||
if(this.tryOpenMainPage && !ExtraClientData.getBoolean("BookAlreadyOpened")){
|
||||
BookletUtils.openIndexEntry(this, InitBooklet.chapterIntro.entry, 1, true);
|
||||
BookletUtils.openChapter(this, InitBooklet.chapterIntro, null);
|
||||
NBTTagCompound data = PlayerData.getDataFromPlayer(Minecraft.getMinecraft().thePlayer);
|
||||
if(data != null){
|
||||
if(this.tryOpenMainPage && !data.getBoolean("BookAlreadyOpened")){
|
||||
BookletUtils.openIndexEntry(this, InitBooklet.chapterIntro.entry, 1, true);
|
||||
BookletUtils.openChapter(this, InitBooklet.chapterIntro, null);
|
||||
|
||||
ExtraClientData.setBoolean("BookAlreadyOpened", true);
|
||||
}
|
||||
else{
|
||||
ExtraClientData.openLastBookPage(this);
|
||||
NBTTagCompound extraData = new NBTTagCompound();
|
||||
extraData.setBoolean("BookAlreadyOpened", true);
|
||||
NBTTagCompound dataToSend = new NBTTagCompound();
|
||||
dataToSend.setTag("Data", extraData);
|
||||
dataToSend.setInteger("WorldID", Minecraft.getMinecraft().theWorld.provider.getDimension());
|
||||
dataToSend.setInteger("PlayerID", Minecraft.getMinecraft().thePlayer.getEntityId());
|
||||
PacketHandler.theNetwork.sendToServer(new PacketClientToServer(dataToSend, PacketHandler.CHANGE_PLAYER_DATA_HANDLER));
|
||||
}
|
||||
else{
|
||||
BookletUtils.openLastBookPage(this, data.getCompoundTag("BookletData"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
@ -390,6 +403,8 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{
|
|||
BookletUtils.openChapter(this, ItemBooklet.forcedEntry.chapter, ItemBooklet.forcedEntry.page);
|
||||
ItemBooklet.forcedEntry = null;
|
||||
}
|
||||
|
||||
this.changedPageSinceOpen = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -430,8 +445,20 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{
|
|||
|
||||
@Override
|
||||
public void onGuiClosed(){
|
||||
if(this.saveOnClose){
|
||||
ExtraClientData.saveBookPage(this);
|
||||
if(this.saveOnClose && this.changedPageSinceOpen){
|
||||
System.out.println("SAVING");
|
||||
|
||||
NBTTagCompound bookletData = new NBTTagCompound();
|
||||
BookletUtils.saveBookPage(this, bookletData);
|
||||
|
||||
NBTTagCompound extraData = new NBTTagCompound();
|
||||
extraData.setTag("BookletData", bookletData);
|
||||
|
||||
NBTTagCompound dataToSend = new NBTTagCompound();
|
||||
dataToSend.setTag("Data", extraData);
|
||||
dataToSend.setInteger("WorldID", Minecraft.getMinecraft().theWorld.provider.getDimension());
|
||||
dataToSend.setInteger("PlayerID", Minecraft.getMinecraft().thePlayer.getEntityId());
|
||||
PacketHandler.theNetwork.sendToServer(new PacketClientToServer(dataToSend, PacketHandler.CHANGE_PLAYER_DATA_HANDLER));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,13 +10,14 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketBookletStandButton;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBookletStand;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -35,7 +36,14 @@ public class GuiBookletStand extends GuiBooklet{
|
|||
@Override
|
||||
public void actionPerformed(GuiButton button){
|
||||
if(button == this.buttonSetPage){
|
||||
PacketHandler.theNetwork.sendToServer(new PacketBookletStandButton(this.theStand.getPos(), this.theStand.getWorld(), Minecraft.getMinecraft().thePlayer, this.currentEntrySet));
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInteger("X", this.theStand.getPos().getX());
|
||||
compound.setInteger("Y", this.theStand.getPos().getY());
|
||||
compound.setInteger("Z", this.theStand.getPos().getZ());
|
||||
compound.setInteger("PlayerID", Minecraft.getMinecraft().thePlayer.getEntityId());
|
||||
compound.setInteger("WorldID", this.theStand.getWorld().provider.getDimension());
|
||||
compound.setTag("EntrySet", this.currentEntrySet.writeToNBT());
|
||||
PacketHandler.theNetwork.sendToServer(new PacketClientToServer(compound, PacketHandler.BOOKLET_STAND_BUTTON_HANDLER));
|
||||
}
|
||||
super.actionPerformed(button);
|
||||
}
|
||||
|
|
|
@ -1,151 +0,0 @@
|
|||
/*
|
||||
* This file ("PersistentClientData.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.data;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.BookletUtils;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.button.BookmarkButton;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.entry.EntrySet;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ExtraClientData{
|
||||
|
||||
private static File theFile;
|
||||
|
||||
public static void saveBookPage(GuiBooklet gui){
|
||||
NBTTagCompound baseCompound = getBaseCompound();
|
||||
NBTTagCompound worldCompound = getCompoundForWorld(baseCompound);
|
||||
if(worldCompound != null){
|
||||
//Save Entry etc.
|
||||
worldCompound.setTag("SavedEntry", gui.currentEntrySet.writeToNBT());
|
||||
worldCompound.setString("SearchWord", gui.searchField.getText());
|
||||
|
||||
//Save Bookmarks
|
||||
NBTTagList list = new NBTTagList();
|
||||
for(int i = 0; i < gui.bookmarkButtons.length; i++){
|
||||
BookmarkButton button = (BookmarkButton)gui.bookmarkButtons[i];
|
||||
|
||||
list.appendTag(button.assignedEntry.writeToNBT());
|
||||
}
|
||||
worldCompound.setTag("Bookmarks", list);
|
||||
}
|
||||
|
||||
writeCompound(baseCompound, worldCompound);
|
||||
}
|
||||
|
||||
private static NBTTagCompound getBaseCompound(){
|
||||
try{
|
||||
return CompressedStreamTools.readCompressed(new FileInputStream(getTheFile()));
|
||||
}
|
||||
catch(Exception e){
|
||||
return new NBTTagCompound();
|
||||
}
|
||||
}
|
||||
|
||||
private static NBTTagCompound getCompoundForWorld(NBTTagCompound mainCompound){
|
||||
return mainCompound.getCompoundTag(getName());
|
||||
}
|
||||
|
||||
private static void writeCompound(NBTTagCompound baseCompound, NBTTagCompound worldCompound){
|
||||
baseCompound.setTag(getName(), worldCompound);
|
||||
try{
|
||||
CompressedStreamTools.writeCompressed(baseCompound, new FileOutputStream(getTheFile()));
|
||||
}
|
||||
catch(Exception e){
|
||||
ModUtil.LOGGER.fatal("Couldn't write Persistent Variable!", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static File getTheFile(){
|
||||
try{
|
||||
if(!theFile.exists()){
|
||||
theFile.createNewFile();
|
||||
}
|
||||
}
|
||||
catch(Exception e){
|
||||
ModUtil.LOGGER.fatal("Couldn't create Persistent Variables file!", e);
|
||||
}
|
||||
return theFile;
|
||||
}
|
||||
|
||||
private static String getName(){
|
||||
if(Minecraft.getMinecraft().theWorld != null){
|
||||
return Minecraft.getMinecraft().isIntegratedServerRunning() ? Minecraft.getMinecraft().getIntegratedServer().getFolderName() : Minecraft.getMinecraft().getCurrentServerData().serverIP;
|
||||
}
|
||||
else{
|
||||
return "Invalid";
|
||||
}
|
||||
}
|
||||
|
||||
public static void setTheFile(File file){
|
||||
theFile = file;
|
||||
}
|
||||
|
||||
public static void openLastBookPage(GuiBooklet gui){
|
||||
NBTTagCompound worldCompound = getCompoundForWorld(getBaseCompound());
|
||||
if(worldCompound != null){
|
||||
//Open Entry etc.
|
||||
EntrySet set = EntrySet.readFromNBT(worldCompound.getCompoundTag("SavedEntry"));
|
||||
if(set != null){
|
||||
|
||||
BookletUtils.openIndexEntry(gui, set.entry, set.pageInIndex, true);
|
||||
if(set.chapter != null){
|
||||
BookletUtils.openChapter(gui, set.chapter, set.page);
|
||||
}
|
||||
|
||||
String searchText = worldCompound.getString("SearchWord");
|
||||
if(!searchText.isEmpty()){
|
||||
gui.searchField.setText(searchText);
|
||||
BookletUtils.updateSearchBar(gui);
|
||||
}
|
||||
}
|
||||
else{
|
||||
//If everything fails, initialize the front page
|
||||
BookletUtils.openIndexEntry(gui, null, 1, true);
|
||||
}
|
||||
|
||||
//Load Bookmarks
|
||||
NBTTagList list = worldCompound.getTagList("Bookmarks", 10);
|
||||
if(list != null){
|
||||
for(int i = 0; i < list.tagCount(); i++){
|
||||
BookmarkButton button = (BookmarkButton)gui.bookmarkButtons[i];
|
||||
NBTTagCompound compound = list.getCompoundTagAt(i);
|
||||
button.assignedEntry = EntrySet.readFromNBT(compound);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void setBoolean(String name, boolean bool){
|
||||
NBTTagCompound baseCompound = getBaseCompound();
|
||||
NBTTagCompound worldCompound = getCompoundForWorld(baseCompound);
|
||||
if(worldCompound != null){
|
||||
worldCompound.setBoolean(name, bool);
|
||||
writeCompound(baseCompound, worldCompound);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean getBoolean(String name){
|
||||
NBTTagCompound worldCompound = getCompoundForWorld(getBaseCompound());
|
||||
return worldCompound != null && worldCompound.getBoolean(name);
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerServerData{
|
||||
public class PlayerData{
|
||||
|
||||
public static NBTTagCompound getDataFromPlayer(EntityPlayer player){
|
||||
ArrayList<PlayerSave> data = WorldData.PLAYER_SAVE_DATA;
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.data;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.data.PlayerServerData.PlayerSave;
|
||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData.PlayerSave;
|
||||
import de.ellpeck.actuallyadditions.mod.misc.LaserRelayConnectionHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.misc.LaserRelayConnectionHandler.Network;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
package de.ellpeck.actuallyadditions.mod.event;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
import de.ellpeck.actuallyadditions.mod.data.PlayerServerData;
|
||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemWingsOfTheBats;
|
||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
||||
|
@ -70,7 +70,7 @@ public class EntityLivingEvents{
|
|||
public void livingDeathEvent(LivingDeathEvent event){
|
||||
if(event.getEntityLiving().worldObj != null && !event.getEntityLiving().worldObj.isRemote && event.getEntityLiving() instanceof EntityPlayer){
|
||||
EntityPlayer player = (EntityPlayer)event.getEntityLiving();
|
||||
NBTTagCompound data = PlayerServerData.getDataFromPlayer(player);
|
||||
NBTTagCompound data = PlayerData.getDataFromPlayer(player);
|
||||
|
||||
NBTTagList deaths = data.getTagList("Deaths", 10);
|
||||
while(deaths.tagCount() >= 5){
|
||||
|
|
|
@ -25,7 +25,7 @@ public class InitEvents{
|
|||
|
||||
Util.registerEvent(new PlayerObtainEvents());
|
||||
Util.registerEvent(new EntityLivingEvents());
|
||||
Util.registerEvent(new LogoutEvent());
|
||||
Util.registerEvent(new PlayerConnectionEvents());
|
||||
Util.registerEvent(new WorldLoadingEvents());
|
||||
Util.registerEvent(new BreakEvent());
|
||||
MinecraftForge.TERRAIN_GEN_BUS.register(new WorldDecorationEvent());
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* This file ("LogoutEvent.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.event;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemWingsOfTheBats;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
||||
|
||||
public class LogoutEvent{
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLogOutEvent(PlayerEvent.PlayerLoggedOutEvent event){
|
||||
//Remove Player from Wings' Fly Permission List
|
||||
ItemWingsOfTheBats.removeWingsFromPlayer(event.player, true);
|
||||
ItemWingsOfTheBats.removeWingsFromPlayer(event.player, false);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* This file ("LogoutEvent.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.event;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemWingsOfTheBats;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
||||
|
||||
public class PlayerConnectionEvents{
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLogOutEvent(PlayerEvent.PlayerLoggedOutEvent event){
|
||||
//Remove Player from Wings' Fly Permission List
|
||||
ItemWingsOfTheBats.removeWingsFromPlayer(event.player, true);
|
||||
ItemWingsOfTheBats.removeWingsFromPlayer(event.player, false);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLogInEvent(PlayerEvent.PlayerLoggedInEvent event){
|
||||
if(!event.player.worldObj.isRemote && event.player instanceof EntityPlayerMP){
|
||||
NBTTagCompound data = PlayerData.getDataFromPlayer(event.player);
|
||||
if(!data.hasNoTags()){
|
||||
PacketHandler.theNetwork.sendTo(new PacketServerToClient(data, PacketHandler.PLAYER_DATA_TO_CLIENT_HANDLER), (EntityPlayerMP)event.player);
|
||||
ModUtil.LOGGER.info("Sending Player Data to player "+event.player.getName()+"!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.mod.event;
|
|||
import de.ellpeck.actuallyadditions.mod.achievement.InitAchievements;
|
||||
import de.ellpeck.actuallyadditions.mod.achievement.TheAchievements;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
import de.ellpeck.actuallyadditions.mod.data.PlayerServerData;
|
||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
|
@ -48,7 +48,7 @@ public class PlayerObtainEvents{
|
|||
|
||||
String name = event.crafting.getItem().getRegistryName().toString();
|
||||
if(name != null && name.toLowerCase(Locale.ROOT).contains(ModUtil.MOD_ID)){
|
||||
NBTTagCompound compound = PlayerServerData.getDataFromPlayer(event.player);
|
||||
NBTTagCompound compound = PlayerData.getDataFromPlayer(event.player);
|
||||
if(compound != null && !compound.getBoolean("BookGottenAlready")){
|
||||
compound.setBoolean("BookGottenAlready", true);
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerCoffeeMachine;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.PacketGuiButton;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
|
@ -23,6 +23,7 @@ import net.minecraft.client.gui.GuiButton;
|
|||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
@ -118,6 +119,13 @@ public class GuiCoffeeMachine extends GuiContainer{
|
|||
|
||||
@Override
|
||||
public void actionPerformed(GuiButton button){
|
||||
PacketHandler.theNetwork.sendToServer(new PacketGuiButton(this.x, this.y, this.z, this.world, button.id, Minecraft.getMinecraft().thePlayer));
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInteger("X", this.x);
|
||||
compound.setInteger("Y", this.y);
|
||||
compound.setInteger("Z", this.z);
|
||||
compound.setInteger("WorldID", this.world.provider.getDimension());
|
||||
compound.setInteger("PlayerID", Minecraft.getMinecraft().thePlayer.getEntityId());
|
||||
compound.setInteger("ButtonID", button.id);
|
||||
PacketHandler.theNetwork.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER));
|
||||
}
|
||||
}
|
|
@ -11,9 +11,8 @@
|
|||
package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerInputter;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.PacketGuiButton;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.PacketGuiNumber;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInputter;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
|
@ -25,6 +24,7 @@ import net.minecraft.client.gui.GuiTextField;
|
|||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -242,7 +242,15 @@ public class GuiInputter extends GuiContainer{
|
|||
}
|
||||
|
||||
private void sendPacket(int text, int textID){
|
||||
PacketHandler.theNetwork.sendToServer(new PacketGuiNumber(this.x, this.y, this.z, this.world, text, textID, Minecraft.getMinecraft().thePlayer));
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInteger("X", this.x);
|
||||
compound.setInteger("Y", this.y);
|
||||
compound.setInteger("Z", this.z);
|
||||
compound.setInteger("WorldID", this.world.provider.getDimension());
|
||||
compound.setInteger("PlayerID", Minecraft.getMinecraft().thePlayer.getEntityId());
|
||||
compound.setInteger("NumberID", textID);
|
||||
compound.setInteger("Number", text);
|
||||
PacketHandler.theNetwork.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_NUMBER_TO_TILE_HANDLER));
|
||||
}
|
||||
|
||||
private int parse(String theInt){
|
||||
|
@ -263,7 +271,14 @@ public class GuiInputter extends GuiContainer{
|
|||
this.setVariable(this.fieldPullEnd, 3);
|
||||
}
|
||||
else{
|
||||
PacketHandler.theNetwork.sendToServer(new PacketGuiButton(this.x, this.y, this.z, this.world, button.id, Minecraft.getMinecraft().thePlayer));
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInteger("X", this.x);
|
||||
compound.setInteger("Y", this.y);
|
||||
compound.setInteger("Z", this.z);
|
||||
compound.setInteger("WorldID", this.world.provider.getDimension());
|
||||
compound.setInteger("PlayerID", Minecraft.getMinecraft().thePlayer.getEntityId());
|
||||
compound.setInteger("ButtonID", button.id);
|
||||
PacketHandler.theNetwork.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
|||
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerLaserRelayItemWhitelist;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiInputter.SmallerButton;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.PacketGuiButton;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItemWhitelist;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
|
@ -24,6 +24,7 @@ import net.minecraft.client.gui.GuiButton;
|
|||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
@ -66,8 +67,14 @@ public class GuiLaserRelayItemWhitelist extends GuiContainer{
|
|||
|
||||
@Override
|
||||
public void actionPerformed(GuiButton button){
|
||||
BlockPos pos = this.tile.getPos();
|
||||
PacketHandler.theNetwork.sendToServer(new PacketGuiButton(pos.getX(), pos.getY(), pos.getZ(), this.tile.getWorld(), button.id, Minecraft.getMinecraft().thePlayer));
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInteger("X", this.tile.getPos().getX());
|
||||
compound.setInteger("Y", this.tile.getPos().getY());
|
||||
compound.setInteger("Z", this.tile.getPos().getZ());
|
||||
compound.setInteger("WorldID", this.tile.getWorld().provider.getDimension());
|
||||
compound.setInteger("PlayerID", Minecraft.getMinecraft().thePlayer.getEntityId());
|
||||
compound.setInteger("ButtonID", button.id);
|
||||
PacketHandler.theNetwork.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerMiner;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.PacketGuiButton;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityMiner;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
|
@ -22,6 +22,7 @@ import net.minecraft.client.gui.GuiButton;
|
|||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
@ -71,6 +72,13 @@ public class GuiMiner extends GuiContainer{
|
|||
|
||||
@Override
|
||||
public void actionPerformed(GuiButton button){
|
||||
PacketHandler.theNetwork.sendToServer(new PacketGuiButton(this.miner.getPos().getX(), this.miner.getPos().getY(), this.miner.getPos().getZ(), this.miner.getWorld(), button.id, Minecraft.getMinecraft().thePlayer));
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInteger("X", this.miner.getPos().getX());
|
||||
compound.setInteger("Y", this.miner.getPos().getY());
|
||||
compound.setInteger("Z", this.miner.getPos().getZ());
|
||||
compound.setInteger("WorldID", this.miner.getWorld().provider.getDimension());
|
||||
compound.setInteger("PlayerID", Minecraft.getMinecraft().thePlayer.getEntityId());
|
||||
compound.setInteger("ButtonID", button.id);
|
||||
PacketHandler.theNetwork.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER));
|
||||
}
|
||||
}
|
|
@ -11,8 +11,8 @@
|
|||
package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerRangedCollector;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.PacketGuiButton;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityRangedCollector;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
|
@ -23,6 +23,7 @@ import net.minecraft.client.gui.GuiButton;
|
|||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
@ -90,6 +91,13 @@ public class GuiRangedCollector extends GuiContainer{
|
|||
|
||||
@Override
|
||||
public void actionPerformed(GuiButton button){
|
||||
PacketHandler.theNetwork.sendToServer(new PacketGuiButton(this.x, this.y, this.z, this.world, button.id, Minecraft.getMinecraft().thePlayer));
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInteger("X", this.x);
|
||||
compound.setInteger("Y", this.y);
|
||||
compound.setInteger("Z", this.z);
|
||||
compound.setInteger("WorldID", this.world.provider.getDimension());
|
||||
compound.setInteger("PlayerID", Minecraft.getMinecraft().thePlayer.getEntityId());
|
||||
compound.setInteger("ButtonID", button.id);
|
||||
PacketHandler.theNetwork.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER));
|
||||
}
|
||||
}
|
|
@ -11,8 +11,8 @@
|
|||
package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerSmileyCloud;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.PacketGuiString;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
|
@ -22,6 +22,7 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -114,6 +115,14 @@ public class GuiSmileyCloud extends GuiContainer{
|
|||
}
|
||||
|
||||
private void sendPacket(String text, int textID){
|
||||
PacketHandler.theNetwork.sendToServer(new PacketGuiString(this.x, this.y, this.z, this.world, text, textID, Minecraft.getMinecraft().thePlayer));
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInteger("X", this.x);
|
||||
compound.setInteger("Y", this.y);
|
||||
compound.setInteger("Z", this.z);
|
||||
compound.setInteger("WorldID", this.world.provider.getDimension());
|
||||
compound.setInteger("PlayerID", Minecraft.getMinecraft().thePlayer.getEntityId());
|
||||
compound.setInteger("TextID", textID);
|
||||
compound.setString("Text", text);
|
||||
PacketHandler.theNetwork.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER));
|
||||
}
|
||||
}
|
|
@ -11,8 +11,8 @@
|
|||
package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerXPSolidifier;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.PacketGuiButton;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityXPSolidifier;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
|
@ -22,6 +22,7 @@ import net.minecraft.client.gui.GuiButton;
|
|||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
@ -93,7 +94,15 @@ public class GuiXPSolidifier extends GuiContainer{
|
|||
|
||||
@Override
|
||||
public void actionPerformed(GuiButton button){
|
||||
PacketHandler.theNetwork.sendToServer(new PacketGuiButton(this.x, this.y, this.z, this.world, button.id, Minecraft.getMinecraft().thePlayer));
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInteger("X", this.x);
|
||||
compound.setInteger("Y", this.y);
|
||||
compound.setInteger("Z", this.z);
|
||||
compound.setInteger("WorldID", this.world.provider.getDimension());
|
||||
compound.setInteger("PlayerID", Minecraft.getMinecraft().thePlayer.getEntityId());
|
||||
compound.setInteger("ButtonID", button.id);
|
||||
PacketHandler.theNetwork.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER));
|
||||
|
||||
this.solidifier.onButtonPressed(button.id, Minecraft.getMinecraft().thePlayer);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* This file ("IDataHandler.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.network;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public interface IDataHandler{
|
||||
|
||||
void handleData(NBTTagCompound compound);
|
||||
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
* This file ("PacketBookletStandButton.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.network;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.internal.IEntrySet;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.entry.EntrySet;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBookletStand;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
public class PacketBookletStandButton implements IMessage{
|
||||
|
||||
private int worldID;
|
||||
private int playerID;
|
||||
|
||||
private NBTTagCompound entrySet;
|
||||
private BlockPos tilePos;
|
||||
|
||||
public PacketBookletStandButton(){
|
||||
|
||||
}
|
||||
|
||||
public PacketBookletStandButton(BlockPos tilePos, World world, EntityPlayer player, IEntrySet set){
|
||||
this.tilePos = tilePos;
|
||||
this.entrySet = set.writeToNBT();
|
||||
this.worldID = world.provider.getDimension();
|
||||
this.playerID = player.getEntityId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf){
|
||||
PacketBuffer buffer = new PacketBuffer(buf);
|
||||
try{
|
||||
this.entrySet = buffer.readNBTTagCompoundFromBuffer();
|
||||
this.tilePos = buffer.readBlockPos();
|
||||
this.worldID = buffer.readInt();
|
||||
this.playerID = buffer.readInt();
|
||||
}
|
||||
catch(Exception e){
|
||||
ModUtil.LOGGER.error("Something went wrong trying to receive a TileEntity packet!", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf){
|
||||
PacketBuffer buffer = new PacketBuffer(buf);
|
||||
|
||||
buffer.writeNBTTagCompoundToBuffer(this.entrySet);
|
||||
buffer.writeBlockPos(this.tilePos);
|
||||
buffer.writeInt(this.worldID);
|
||||
buffer.writeInt(this.playerID);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<PacketBookletStandButton, IMessage>{
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketBookletStandButton message, MessageContext ctx){
|
||||
World world = DimensionManager.getWorld(message.worldID);
|
||||
TileEntity tile = world.getTileEntity(message.tilePos);
|
||||
EntityPlayer player = (EntityPlayer)world.getEntityByID(message.playerID);
|
||||
|
||||
if(player != null && tile instanceof TileEntityBookletStand){
|
||||
TileEntityBookletStand stand = (TileEntityBookletStand)tile;
|
||||
if(player.getName() != null && player.getName().equalsIgnoreCase(stand.assignedPlayer)){
|
||||
stand.assignedEntry = EntrySet.readFromNBT(message.entrySet);
|
||||
stand.markDirty();
|
||||
stand.sendUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* This file ("PacketServerToClient.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.network;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
public class PacketClientToServer implements IMessage{
|
||||
|
||||
private NBTTagCompound data;
|
||||
private IDataHandler handler;
|
||||
|
||||
public PacketClientToServer(){
|
||||
|
||||
}
|
||||
|
||||
public PacketClientToServer(NBTTagCompound data, IDataHandler handler){
|
||||
this.data = data;
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf){
|
||||
PacketBuffer buffer = new PacketBuffer(buf);
|
||||
try{
|
||||
this.data = buffer.readNBTTagCompoundFromBuffer();
|
||||
|
||||
int handlerId = buffer.readInt();
|
||||
if(handlerId >= 0 && handlerId < PacketHandler.DATA_HANDLERS.size()){
|
||||
this.handler = PacketHandler.DATA_HANDLERS.get(handlerId);
|
||||
}
|
||||
}
|
||||
catch(Exception e){
|
||||
ModUtil.LOGGER.error("Something went wrong trying to receive a server packet!", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf){
|
||||
PacketBuffer buffer = new PacketBuffer(buf);
|
||||
|
||||
buffer.writeNBTTagCompoundToBuffer(this.data);
|
||||
buffer.writeInt(PacketHandler.DATA_HANDLERS.indexOf(this.handler));
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<PacketClientToServer, IMessage>{
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketClientToServer message, MessageContext ctx){
|
||||
if(message.data != null && message.handler != null){
|
||||
message.handler.handleData(message.data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,26 +10,153 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.network;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.PacketGuiButton;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.PacketGuiNumber;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.PacketGuiString;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.entry.EntrySet;
|
||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.IStringReactor;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBookletStand;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class PacketHandler{
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class PacketHandler{
|
||||
|
||||
public static SimpleNetworkWrapper theNetwork;
|
||||
public static final List<IDataHandler> DATA_HANDLERS = new ArrayList<IDataHandler>();
|
||||
|
||||
public static final IDataHandler PARTICLE_HANDLER = new IDataHandler(){
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void handleData(NBTTagCompound compound){
|
||||
AssetUtil.renderParticlesFromAToB(compound.getDouble("StartX"), compound.getDouble("StartY"), compound.getDouble("StartZ"), compound.getDouble("EndX"), compound.getDouble("EndY"), compound.getDouble("EndZ"), compound.getInteger("ParticleAmount"), compound.getFloat("ParticleSize"), new float[]{compound.getFloat("Color1"), compound.getFloat("Color2"), compound.getFloat("Color3")}, compound.getFloat("AgeMultiplier"));
|
||||
}
|
||||
};
|
||||
|
||||
public static final IDataHandler TILE_ENTITY_HANDLER = new IDataHandler(){
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void handleData(NBTTagCompound compound){
|
||||
World world = Minecraft.getMinecraft().theWorld;
|
||||
if(world != null){
|
||||
TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z")));
|
||||
if(tile != null && tile instanceof TileEntityBase){
|
||||
((TileEntityBase)tile).receiveSyncCompound(compound.getCompoundTag("Data"));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static final IDataHandler BOOKLET_STAND_BUTTON_HANDLER = new IDataHandler(){
|
||||
@Override
|
||||
public void handleData(NBTTagCompound compound){
|
||||
World world = DimensionManager.getWorld(compound.getInteger("WorldID"));
|
||||
TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z")));
|
||||
EntityPlayer player = (EntityPlayer)world.getEntityByID(compound.getInteger("PlayerID"));
|
||||
|
||||
if(player != null && tile instanceof TileEntityBookletStand){
|
||||
TileEntityBookletStand stand = (TileEntityBookletStand)tile;
|
||||
if(player.getName() != null && player.getName().equalsIgnoreCase(stand.assignedPlayer)){
|
||||
stand.assignedEntry = EntrySet.readFromNBT(compound.getCompoundTag("EntrySet"));
|
||||
stand.markDirty();
|
||||
stand.sendUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static final IDataHandler GUI_BUTTON_TO_TILE_HANDLER = new IDataHandler(){
|
||||
@Override
|
||||
public void handleData(NBTTagCompound compound){
|
||||
World world = DimensionManager.getWorld(compound.getInteger("WorldID"));
|
||||
TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z")));
|
||||
|
||||
if(tile instanceof IButtonReactor){
|
||||
IButtonReactor reactor = (IButtonReactor)tile;
|
||||
reactor.onButtonPressed(compound.getInteger("ButtonID"), (EntityPlayer)world.getEntityByID(compound.getInteger("PlayerID")));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static final IDataHandler GUI_NUMBER_TO_TILE_HANDLER = new IDataHandler(){
|
||||
@Override
|
||||
public void handleData(NBTTagCompound compound){
|
||||
World world = DimensionManager.getWorld(compound.getInteger("WorldID"));
|
||||
TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z")));
|
||||
|
||||
if(tile instanceof INumberReactor){
|
||||
INumberReactor reactor = (INumberReactor)tile;
|
||||
reactor.onNumberReceived(compound.getInteger("Number"), compound.getInteger("NumberID"), (EntityPlayer)world.getEntityByID(compound.getInteger("PlayerID")));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static final IDataHandler GUI_STRING_TO_TILE_HANDLER = new IDataHandler(){
|
||||
@Override
|
||||
public void handleData(NBTTagCompound compound){
|
||||
World world = DimensionManager.getWorld(compound.getInteger("WorldID"));
|
||||
TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z")));
|
||||
|
||||
if(tile instanceof IStringReactor){
|
||||
IStringReactor reactor = (IStringReactor)tile;
|
||||
reactor.onTextReceived(compound.getString("Text"), compound.getInteger("TextID"), (EntityPlayer)world.getEntityByID(compound.getInteger("PlayerID")));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static final IDataHandler CHANGE_PLAYER_DATA_HANDLER = new IDataHandler(){
|
||||
@Override
|
||||
public void handleData(NBTTagCompound compound){
|
||||
NBTTagCompound data = compound.getCompoundTag("Data");
|
||||
World world = DimensionManager.getWorld(compound.getInteger("WorldID"));
|
||||
EntityPlayer player = (EntityPlayer)world.getEntityByID(compound.getInteger("PlayerID"));
|
||||
|
||||
if(player != null){
|
||||
NBTTagCompound playerData = PlayerData.getDataFromPlayer(player);
|
||||
playerData.merge(data);
|
||||
if(player instanceof EntityPlayerMP){
|
||||
PacketHandler.theNetwork.sendTo(new PacketServerToClient(playerData, PLAYER_DATA_TO_CLIENT_HANDLER), (EntityPlayerMP)player);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static final IDataHandler PLAYER_DATA_TO_CLIENT_HANDLER = new IDataHandler(){
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void handleData(NBTTagCompound compound){
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
PlayerData.getDataFromPlayer(player).merge(compound);
|
||||
}
|
||||
};
|
||||
|
||||
public static void init(){
|
||||
theNetwork = NetworkRegistry.INSTANCE.newSimpleChannel(ModUtil.MOD_ID);
|
||||
theNetwork.registerMessage(PacketServerToClient.Handler.class, PacketServerToClient.class, 0, Side.CLIENT);
|
||||
theNetwork.registerMessage(PacketClientToServer.Handler.class, PacketClientToServer.class, 1, Side.SERVER);
|
||||
|
||||
theNetwork.registerMessage(PacketGuiButton.Handler.class, PacketGuiButton.class, 0, Side.SERVER);
|
||||
theNetwork.registerMessage(PacketGuiNumber.Handler.class, PacketGuiNumber.class, 1, Side.SERVER);
|
||||
theNetwork.registerMessage(PacketGuiString.Handler.class, PacketGuiString.class, 2, Side.SERVER);
|
||||
theNetwork.registerMessage(PacketParticle.Handler.class, PacketParticle.class, 3, Side.CLIENT);
|
||||
theNetwork.registerMessage(PacketUpdateTileEntity.Handler.class, PacketUpdateTileEntity.class, 4, Side.CLIENT);
|
||||
theNetwork.registerMessage(PacketBookletStandButton.Handler.class, PacketBookletStandButton.class, 5, Side.SERVER);
|
||||
DATA_HANDLERS.add(PARTICLE_HANDLER);
|
||||
DATA_HANDLERS.add(TILE_ENTITY_HANDLER);
|
||||
DATA_HANDLERS.add(BOOKLET_STAND_BUTTON_HANDLER);
|
||||
DATA_HANDLERS.add(GUI_BUTTON_TO_TILE_HANDLER);
|
||||
DATA_HANDLERS.add(GUI_STRING_TO_TILE_HANDLER);
|
||||
DATA_HANDLERS.add(GUI_NUMBER_TO_TILE_HANDLER);
|
||||
DATA_HANDLERS.add(CHANGE_PLAYER_DATA_HANDLER);
|
||||
DATA_HANDLERS.add(PLAYER_DATA_TO_CLIENT_HANDLER);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,113 +0,0 @@
|
|||
/*
|
||||
* This file ("PacketParticle.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.network;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.misc.ParticleColored;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class PacketParticle implements IMessage{
|
||||
|
||||
private double startX;
|
||||
private double startY;
|
||||
private double startZ;
|
||||
private double endX;
|
||||
private double endY;
|
||||
private double endZ;
|
||||
private float[] color;
|
||||
private int particleAmount;
|
||||
private float particleSize;
|
||||
|
||||
public PacketParticle(){
|
||||
|
||||
}
|
||||
|
||||
public PacketParticle(double startX, double startY, double startZ, double endX, double endY, double endZ, float[] color, int particleAmount, float particleSize){
|
||||
this.startX = startX;
|
||||
this.startY = startY;
|
||||
this.startZ = startZ;
|
||||
this.endX = endX;
|
||||
this.endY = endY;
|
||||
this.endZ = endZ;
|
||||
this.color = color;
|
||||
this.particleAmount = particleAmount;
|
||||
this.particleSize = particleSize;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void renderParticlesFromAToB(double startX, double startY, double startZ, double endX, double endY, double endZ, int particleAmount, float particleSize, float[] color, float ageMultiplier){
|
||||
World world = Minecraft.getMinecraft().theWorld;
|
||||
|
||||
if(Minecraft.getMinecraft().thePlayer.getDistance(startX, startY, startZ) <= 64 || Minecraft.getMinecraft().thePlayer.getDistance(endX, endY, endZ) <= 64){
|
||||
double difX = startX-endX;
|
||||
double difY = startY-endY;
|
||||
double difZ = startZ-endZ;
|
||||
double distance = new Vec3d(startX, startY, startZ).distanceTo(new Vec3d(endX, endY, endZ));
|
||||
|
||||
for(int times = 0; times < Math.max(particleAmount/2, 1); times++){
|
||||
for(double i = 0; i <= 1; i += 1/(distance*particleAmount)){
|
||||
ParticleColored fx = new ParticleColored(world, (difX*i)+endX+0.5, (difY*i)+endY+0.5, (difZ*i)+endZ+0.5, particleSize, color[0], color[1], color[2], ageMultiplier);
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect(fx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf){
|
||||
this.startX = buf.readDouble();
|
||||
this.startY = buf.readDouble();
|
||||
this.startZ = buf.readDouble();
|
||||
this.endX = buf.readDouble();
|
||||
this.endY = buf.readDouble();
|
||||
this.endZ = buf.readDouble();
|
||||
this.particleAmount = buf.readInt();
|
||||
this.particleSize = buf.readFloat();
|
||||
|
||||
this.color = new float[3];
|
||||
for(int i = 0; i < this.color.length; i++){
|
||||
this.color[i] = buf.readFloat();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf){
|
||||
buf.writeDouble(this.startX);
|
||||
buf.writeDouble(this.startY);
|
||||
buf.writeDouble(this.startZ);
|
||||
buf.writeDouble(this.endX);
|
||||
buf.writeDouble(this.endY);
|
||||
buf.writeDouble(this.endZ);
|
||||
buf.writeInt(this.particleAmount);
|
||||
buf.writeFloat(this.particleSize);
|
||||
|
||||
for(float aColor : this.color){
|
||||
buf.writeFloat(aColor);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<PacketParticle, IMessage>{
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IMessage onMessage(PacketParticle message, MessageContext ctx){
|
||||
renderParticlesFromAToB(message.startX, message.startY, message.startZ, message.endX, message.endY, message.endZ, message.particleAmount, message.particleSize, message.color, 1);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* This file ("PacketServerToClient.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.network;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class PacketServerToClient implements IMessage{
|
||||
|
||||
private NBTTagCompound data;
|
||||
private IDataHandler handler;
|
||||
|
||||
public PacketServerToClient(){
|
||||
|
||||
}
|
||||
|
||||
public PacketServerToClient(NBTTagCompound data, IDataHandler handler){
|
||||
this.data = data;
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf){
|
||||
PacketBuffer buffer = new PacketBuffer(buf);
|
||||
try{
|
||||
this.data = buffer.readNBTTagCompoundFromBuffer();
|
||||
|
||||
int handlerId = buffer.readInt();
|
||||
if(handlerId >= 0 && handlerId < PacketHandler.DATA_HANDLERS.size()){
|
||||
this.handler = PacketHandler.DATA_HANDLERS.get(handlerId);
|
||||
}
|
||||
}
|
||||
catch(Exception e){
|
||||
ModUtil.LOGGER.error("Something went wrong trying to receive a client packet!", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf){
|
||||
PacketBuffer buffer = new PacketBuffer(buf);
|
||||
|
||||
buffer.writeNBTTagCompoundToBuffer(this.data);
|
||||
buffer.writeInt(PacketHandler.DATA_HANDLERS.indexOf(this.handler));
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<PacketServerToClient, IMessage>{
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IMessage onMessage(PacketServerToClient message, MessageContext ctx){
|
||||
if(message.data != null && message.handler != null){
|
||||
message.handler.handleData(message.data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
* This file ("PacketUpdateTileEntity.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.network;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class PacketUpdateTileEntity implements IMessage{
|
||||
|
||||
private NBTTagCompound compound;
|
||||
private BlockPos pos;
|
||||
|
||||
public PacketUpdateTileEntity(){
|
||||
|
||||
}
|
||||
|
||||
public PacketUpdateTileEntity(NBTTagCompound compound, BlockPos pos){
|
||||
this.compound = compound;
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf){
|
||||
PacketBuffer buffer = new PacketBuffer(buf);
|
||||
try{
|
||||
this.compound = buffer.readNBTTagCompoundFromBuffer();
|
||||
this.pos = buffer.readBlockPos();
|
||||
}
|
||||
catch(Exception e){
|
||||
ModUtil.LOGGER.error("Something went wrong trying to receive a TileEntity packet!", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf){
|
||||
PacketBuffer buffer = new PacketBuffer(buf);
|
||||
|
||||
buffer.writeNBTTagCompoundToBuffer(this.compound);
|
||||
buffer.writeBlockPos(this.pos);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<PacketUpdateTileEntity, IMessage>{
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IMessage onMessage(PacketUpdateTileEntity message, MessageContext ctx){
|
||||
if(message.pos != null && message.compound != null){
|
||||
World world = Minecraft.getMinecraft().theWorld;
|
||||
if(world != null){
|
||||
TileEntity tile = world.getTileEntity(message.pos);
|
||||
if(tile != null && tile instanceof TileEntityBase){
|
||||
((TileEntityBase)tile).receiveSyncCompound(message.compound);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
* This file ("PacketGuiButton.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.network.gui;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
public class PacketGuiButton implements IMessage{
|
||||
|
||||
private int tileX;
|
||||
private int tileY;
|
||||
private int tileZ;
|
||||
private int worldID;
|
||||
private int buttonID;
|
||||
private int playerID;
|
||||
|
||||
public PacketGuiButton(){
|
||||
|
||||
}
|
||||
|
||||
public PacketGuiButton(int x, int y, int z, World world, int buttonID, EntityPlayer player){
|
||||
this.tileX = x;
|
||||
this.tileY = y;
|
||||
this.tileZ = z;
|
||||
this.worldID = world.provider.getDimension();
|
||||
this.buttonID = buttonID;
|
||||
this.playerID = player.getEntityId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf){
|
||||
this.tileX = buf.readInt();
|
||||
this.tileY = buf.readInt();
|
||||
this.tileZ = buf.readInt();
|
||||
this.worldID = buf.readInt();
|
||||
this.buttonID = buf.readInt();
|
||||
this.playerID = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf){
|
||||
buf.writeInt(this.tileX);
|
||||
buf.writeInt(this.tileY);
|
||||
buf.writeInt(this.tileZ);
|
||||
buf.writeInt(this.worldID);
|
||||
buf.writeInt(this.buttonID);
|
||||
buf.writeInt(this.playerID);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<PacketGuiButton, IMessage>{
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketGuiButton message, MessageContext ctx){
|
||||
World world = DimensionManager.getWorld(message.worldID);
|
||||
TileEntity tile = world.getTileEntity(new BlockPos(message.tileX, message.tileY, message.tileZ));
|
||||
|
||||
if(tile instanceof IButtonReactor){
|
||||
IButtonReactor reactor = (IButtonReactor)tile;
|
||||
reactor.onButtonPressed(message.buttonID, (EntityPlayer)world.getEntityByID(message.playerID));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* This file ("PacketGuiNumber.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.network.gui;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
public class PacketGuiNumber implements IMessage{
|
||||
|
||||
private int tileX;
|
||||
private int tileY;
|
||||
private int tileZ;
|
||||
private int worldID;
|
||||
private int text;
|
||||
private int textID;
|
||||
private int playerID;
|
||||
|
||||
public PacketGuiNumber(){
|
||||
|
||||
}
|
||||
|
||||
public PacketGuiNumber(int x, int y, int z, World world, int text, int textID, EntityPlayer player){
|
||||
this.tileX = x;
|
||||
this.tileY = y;
|
||||
this.tileZ = z;
|
||||
this.worldID = world.provider.getDimension();
|
||||
this.text = text;
|
||||
this.textID = textID;
|
||||
this.playerID = player.getEntityId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf){
|
||||
this.tileX = buf.readInt();
|
||||
this.tileY = buf.readInt();
|
||||
this.tileZ = buf.readInt();
|
||||
this.worldID = buf.readInt();
|
||||
this.text = buf.readInt();
|
||||
this.textID = buf.readInt();
|
||||
this.playerID = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf){
|
||||
buf.writeInt(this.tileX);
|
||||
buf.writeInt(this.tileY);
|
||||
buf.writeInt(this.tileZ);
|
||||
buf.writeInt(this.worldID);
|
||||
buf.writeInt(this.text);
|
||||
buf.writeInt(this.textID);
|
||||
buf.writeInt(this.playerID);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<PacketGuiNumber, IMessage>{
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketGuiNumber message, MessageContext ctx){
|
||||
World world = DimensionManager.getWorld(message.worldID);
|
||||
TileEntity tile = world.getTileEntity(new BlockPos(message.tileX, message.tileY, message.tileZ));
|
||||
|
||||
if(tile instanceof INumberReactor){
|
||||
INumberReactor reactor = (INumberReactor)tile;
|
||||
reactor.onNumberReceived(message.text, message.textID, (EntityPlayer)world.getEntityByID(message.playerID));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
* This file ("PacketGuiString.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.network.gui;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
public class PacketGuiString implements IMessage{
|
||||
|
||||
private int tileX;
|
||||
private int tileY;
|
||||
private int tileZ;
|
||||
private int worldID;
|
||||
private String text;
|
||||
private int textID;
|
||||
private int playerID;
|
||||
|
||||
public PacketGuiString(){
|
||||
|
||||
}
|
||||
|
||||
public PacketGuiString(int x, int y, int z, World world, String text, int textID, EntityPlayer player){
|
||||
this.tileX = x;
|
||||
this.tileY = y;
|
||||
this.tileZ = z;
|
||||
this.worldID = world.provider.getDimension();
|
||||
this.text = text;
|
||||
this.textID = textID;
|
||||
this.playerID = player.getEntityId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf){
|
||||
this.tileX = buf.readInt();
|
||||
this.tileY = buf.readInt();
|
||||
this.tileZ = buf.readInt();
|
||||
this.worldID = buf.readInt();
|
||||
|
||||
this.text = "";
|
||||
int textLength = buf.readInt();
|
||||
for(int i = 0; i < textLength; i++){
|
||||
this.text += buf.readChar();
|
||||
}
|
||||
|
||||
this.textID = buf.readInt();
|
||||
this.playerID = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf){
|
||||
buf.writeInt(this.tileX);
|
||||
buf.writeInt(this.tileY);
|
||||
buf.writeInt(this.tileZ);
|
||||
buf.writeInt(this.worldID);
|
||||
|
||||
buf.writeInt(this.text.length());
|
||||
for(int i = 0; i < this.text.length(); i++){
|
||||
buf.writeChar(this.text.charAt(i));
|
||||
}
|
||||
|
||||
buf.writeInt(this.textID);
|
||||
buf.writeInt(this.playerID);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<PacketGuiString, IMessage>{
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketGuiString message, MessageContext ctx){
|
||||
World world = DimensionManager.getWorld(message.worldID);
|
||||
TileEntity tile = world.getTileEntity(new BlockPos(message.tileX, message.tileY, message.tileZ));
|
||||
|
||||
if(tile instanceof IStringReactor){
|
||||
IStringReactor reactor = (IStringReactor)tile;
|
||||
reactor.onTextReceived(message.text, message.textID, (EntityPlayer)world.getEntityByID(message.playerID));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -122,8 +122,6 @@ public class ClientProxy implements IProxy{
|
|||
ModUtil.LOGGER.warn("You have turned Seasonal Mode off. Therefore, you are evil.");
|
||||
}
|
||||
|
||||
ExtraClientData.setTheFile(new File(Minecraft.getMinecraft().mcDataDir, ModUtil.MOD_ID+"data.dat"));
|
||||
|
||||
for(Map.Entry<ItemStack, ModelResourceLocation> entry : MODEL_LOCATIONS_FOR_REGISTERING.entrySet()){
|
||||
ModelLoader.setCustomModelResourceLocation(entry.getKey().getItem(), entry.getKey().getItemDamage(), entry.getValue());
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import de.ellpeck.actuallyadditions.api.lens.Lens;
|
|||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
import de.ellpeck.actuallyadditions.mod.misc.SoundHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketParticle;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -49,7 +49,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
|||
if(!ConfigBoolValues.LESS_SOUND.isEnabled()){
|
||||
world.playSound(null, startX, startY, startZ, SoundHandler.reconstructor, SoundCategory.BLOCKS, 0.35F, 1.0F);
|
||||
}
|
||||
PacketHandler.theNetwork.sendToAllAround(new PacketParticle(startX, startY, startZ, endX, endY, endZ, currentLens.getColor(), ConfigBoolValues.LESS_PARTICLES.isEnabled() ? 2 : 8, 2F), new NetworkRegistry.TargetPoint(world.provider.getDimension(), startX, startY, startZ, 64));
|
||||
AssetUtil.shootParticles(world, startX, startY, startZ, endX, endY, endZ, currentLens.getColor(), ConfigBoolValues.LESS_PARTICLES.isEnabled() ? 2 : 8, 2F);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
|||
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketUpdateTileEntity;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -197,7 +197,12 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
|
|||
if(!this.worldObj.isRemote){
|
||||
NBTTagCompound compound = this.getUpdateTag();
|
||||
if(compound != null){
|
||||
PacketHandler.theNetwork.sendToAllAround(new PacketUpdateTileEntity(compound, this.getPos()), new NetworkRegistry.TargetPoint(this.worldObj.provider.getDimension(), this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), 64));
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setTag("Data", compound);
|
||||
data.setInteger("X", this.pos.getX());
|
||||
data.setInteger("Y", this.pos.getY());
|
||||
data.setInteger("Z", this.pos.getZ());
|
||||
PacketHandler.theNetwork.sendToAllAround(new PacketServerToClient(data, PacketHandler.TILE_ENTITY_HANDLER), new NetworkRegistry.TargetPoint(this.worldObj.provider.getDimension(), this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), 64));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
|||
import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench;
|
||||
import de.ellpeck.actuallyadditions.mod.misc.LaserRelayConnectionHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.misc.LaserRelayConnectionHandler.ConnectionPair;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketParticle;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
|
@ -104,7 +104,7 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{
|
|||
if(network != null){
|
||||
for(ConnectionPair aPair : network.connections){
|
||||
if(aPair.contains(this.pos) && PosUtil.areSamePos(this.pos, aPair.positions[0])){
|
||||
PacketParticle.renderParticlesFromAToB(aPair.positions[0].getX(), aPair.positions[0].getY(), aPair.positions[0].getZ(), aPair.positions[1].getX(), aPair.positions[1].getY(), aPair.positions[1].getZ(), ConfigBoolValues.LESS_PARTICLES.isEnabled() ? 1 : Util.RANDOM.nextInt(3)+1, 0.8F, this.isItem ? COLOR_ITEM : COLOR, 1F);
|
||||
AssetUtil.renderParticlesFromAToB(aPair.positions[0].getX(), aPair.positions[0].getY(), aPair.positions[0].getZ(), aPair.positions[1].getX(), aPair.positions[1].getY(), aPair.positions[1].getZ(), ConfigBoolValues.LESS_PARTICLES.isEnabled() ? 1 : Util.RANDOM.nextInt(3)+1, 0.8F, this.isItem ? COLOR_ITEM : COLOR, 1F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import cofh.api.energy.EnergyStorage;
|
|||
import cofh.api.energy.IEnergyProvider;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketParticle;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -90,7 +90,7 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr
|
|||
this.storage.receiveEnergy(ENERGY_PRODUCED, false);
|
||||
|
||||
if(!ConfigBoolValues.LESS_PARTICLES.isEnabled()){
|
||||
PacketHandler.theNetwork.sendToAllAround(new PacketParticle(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), theCoord.getX(), theCoord.getY(), theCoord.getZ(), new float[]{62F/255F, 163F/255F, 74F/255F}, 5, 1.0F), new NetworkRegistry.TargetPoint(this.worldObj.provider.getDimension(), this.pos.getX(), this.pos.getY(), this.pos.getZ(), 64));
|
||||
AssetUtil.shootParticles(this.worldObj, this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), theCoord.getX(), theCoord.getY(), theCoord.getZ(), new float[]{62F/255F, 163F/255F, 74F/255F}, 5, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,9 +14,8 @@ import cofh.api.energy.EnergyStorage;
|
|||
import cofh.api.energy.IEnergyReceiver;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketParticle;
|
||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||
|
@ -167,7 +166,7 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IEnergyR
|
|||
|
||||
private void shootParticles(int endX, int endY, int endZ){
|
||||
if(!ConfigBoolValues.LESS_PARTICLES.isEnabled()){
|
||||
PacketHandler.theNetwork.sendToAllAround(new PacketParticle(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), endX, endY, endZ, new float[]{62F/255F, 163F/255F, 74F/255F}, 5, 1.0F), new NetworkRegistry.TargetPoint(this.worldObj.provider.getDimension(), this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), 96));
|
||||
AssetUtil.shootParticles(this.worldObj, this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), endX, endY, endZ, new float[]{62F/255F, 163F/255F, 74F/255F}, 5, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,8 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
|||
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketParticle;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||
|
@ -162,7 +163,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
|||
}
|
||||
|
||||
if(this.ticksElapsed%80 == 0){
|
||||
PacketParticle.renderParticlesFromAToB(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), this.boundPosition.getX(), this.boundPosition.getY(), this.boundPosition.getZ(), 2, 0.35F, TileEntityPhantomface.COLORS, 3);
|
||||
AssetUtil.renderParticlesFromAToB(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), this.boundPosition.getX(), this.boundPosition.getY(), this.boundPosition.getZ(), 2, 0.35F, TileEntityPhantomface.COLORS, 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
|||
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketParticle;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -148,7 +148,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
|||
}
|
||||
|
||||
if(this.ticksElapsed%80 == 0){
|
||||
PacketParticle.renderParticlesFromAToB(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), this.boundPosition.getX(), this.boundPosition.getY(), this.boundPosition.getZ(), 2, 0.35F, COLORS, 3);
|
||||
AssetUtil.renderParticlesFromAToB(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), this.boundPosition.getX(), this.boundPosition.getY(), this.boundPosition.getZ(), 2, 0.35F, COLORS, 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.util;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.misc.ParticleColored;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
|
@ -20,7 +23,12 @@ import net.minecraft.client.renderer.VertexBuffer;
|
|||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
@ -147,4 +155,42 @@ public class AssetUtil{
|
|||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
public static void shootParticles(World world, double startX, double startY, double startZ, double endX, double endY, double endZ, float[] color, int particleAmount, float particleSize){
|
||||
if(!world.isRemote){
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setDouble("StartX", startX);
|
||||
data.setDouble("StartY", startY);
|
||||
data.setDouble("StartZ", startZ);
|
||||
data.setDouble("EndX", endX);
|
||||
data.setDouble("EndY", endY);
|
||||
data.setDouble("EndZ", endZ);
|
||||
data.setFloat("Color1", color[0]);
|
||||
data.setFloat("Color2", color[1]);
|
||||
data.setFloat("Color3", color[2]);
|
||||
data.setInteger("ParticleAmount", particleAmount);
|
||||
data.setFloat("ParticleSize", particleSize);
|
||||
data.setFloat("AgeMultiplier", 1F);
|
||||
PacketHandler.theNetwork.sendToAllAround(new PacketServerToClient(data, PacketHandler.PARTICLE_HANDLER), new NetworkRegistry.TargetPoint(world.provider.getDimension(), startX, startY, startZ, 96));
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void renderParticlesFromAToB(double startX, double startY, double startZ, double endX, double endY, double endZ, int particleAmount, float particleSize, float[] color, float ageMultiplier){
|
||||
World world = Minecraft.getMinecraft().theWorld;
|
||||
|
||||
if(Minecraft.getMinecraft().thePlayer.getDistance(startX, startY, startZ) <= 64 || Minecraft.getMinecraft().thePlayer.getDistance(endX, endY, endZ) <= 64){
|
||||
double difX = startX-endX;
|
||||
double difY = startY-endY;
|
||||
double difZ = startZ-endZ;
|
||||
double distance = new Vec3d(startX, startY, startZ).distanceTo(new Vec3d(endX, endY, endZ));
|
||||
|
||||
for(int times = 0; times < Math.max(particleAmount/2, 1); times++){
|
||||
for(double i = 0; i <= 1; i += 1/(distance*particleAmount)){
|
||||
ParticleColored fx = new ParticleColored(world, (difX*i)+endX+0.5, (difY*i)+endY+0.5, (difZ*i)+endZ+0.5, particleSize, color[0], color[1], color[2], ageMultiplier);
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect(fx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue