aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorkarpov.evgeniy <karpov-em@dartit.ru>2020-02-25 11:58:19 +0500
committerkarpov.evgeniy <karpov-em@dartit.ru>2020-02-25 12:17:58 +0500
commit5c8be4893ee303377629ae7404e5608eb4bd7c37 (patch)
tree087b121f0d40b58914411438574eaf0fe63ed8e0 /src/main
parent47564cf32742c9327051a57d8d6d1122de4696de (diff)
downloadGT5-Unofficial-5c8be4893ee303377629ae7404e5608eb4bd7c37.tar.gz
GT5-Unofficial-5c8be4893ee303377629ae7404e5608eb4bd7c37.tar.bz2
GT5-Unofficial-5c8be4893ee303377629ae7404e5608eb4bd7c37.zip
Provide owner's UUID to forge event bus for fake players. Second PR cuz line endings fixed.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java11
-rw-r--r--src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java11
-rw-r--r--src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java35
-rw-r--r--src/main/java/gregtech/api/util/GT_Utility.java5
-rw-r--r--src/main/java/gregtech/common/blocks/GT_Item_Machines.java1
5 files changed, 54 insertions, 9 deletions
diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java b/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java
index 953e3e5dc4..8bd8c5b678 100644
--- a/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java
+++ b/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java
@@ -12,6 +12,7 @@ import net.minecraftforge.fluids.IFluidHandler;
import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
/**
* A simple compound Interface for all my TileEntities.
@@ -93,6 +94,16 @@ public interface IGregTechTileEntity extends ITexturedTileEntity, IGearEnergyTil
public String getOwnerName();
/**
+ * Gets the UniqueID of the Machines Owner.
+ */
+ public UUID getOwnerUuid();
+
+ /**
+ * Sets the UniqueID of the Machines Owner.
+ */
+ public void setOwnerUuid(UUID uuid);
+
+ /**
* Sets initial Values from NBT
*
* @param aNBT is the NBTTag of readFromNBT
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java
index 6d9ce47ef2..257cc79adb 100644
--- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java
@@ -6,6 +6,7 @@ import static gregtech.api.enums.GT_Values.NW;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.UUID;
import gregtech.api.GregTech_API;
import gregtech.api.enums.Textures;
@@ -1176,6 +1177,16 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
}
@Override
+ public UUID getOwnerUuid() {
+ return GT_Utility.defaultUuid;
+ }
+
+ @Override
+ public void setOwnerUuid(UUID uuid) {
+
+ }
+
+ @Override
public byte getComparatorValue(byte aSide) {
return canAccessData() ? mMetaTileEntity.getComparatorValue(aSide) : 0;
}
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
index 1da2dffca9..58a97f644a 100644
--- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
@@ -39,6 +39,7 @@ import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.UUID;
import static gregtech.GT_Mod.GT_FML_LOGGER;
import static gregtech.api.enums.GT_Values.NW;
@@ -69,6 +70,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
public long mLastSoundTick = 0;
private long mLastCheckTick = 0;
private String mOwnerName = "";
+ private UUID mOwnerUuid = GT_Utility.defaultUuid;
private NBTTagCompound mRecipeStuff = new NBTTagCompound();
private static final Field ENTITY_ITEM_HEALTH_FIELD;
@@ -116,6 +118,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
aNBT.setByte("mStrongRedstone", mStrongRedstone);
aNBT.setShort("mFacing", mFacing);
aNBT.setString("mOwnerName", mOwnerName);
+ aNBT.setString("mOwnerUuid", mOwnerUuid == null ? "" : mOwnerUuid.toString());
aNBT.setBoolean("mLockUpgrade", mLockUpgrade);
aNBT.setBoolean("mMuffler", mMuffler);
aNBT.setBoolean("mSteamConverter", mSteamConverter);
@@ -181,6 +184,11 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
mStrongRedstone = aNBT.getByte("mStrongRedstone");
mFacing = oFacing = (byte) aNBT.getShort("mFacing");
mOwnerName = aNBT.getString("mOwnerName");
+ try {
+ mOwnerUuid = UUID.fromString(aNBT.getString("mOwnerUuid"));
+ } catch (IllegalArgumentException e){
+ mOwnerUuid = null;
+ }
mLockUpgrade = aNBT.getBoolean("mLockUpgrade");
mMuffler = aNBT.getBoolean("mMuffler");
mSteamConverter = aNBT.getBoolean("mSteamConverter");
@@ -541,7 +549,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
oTexturePage = (hasValidMetaTileEntity() && mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) ? ((GT_MetaTileEntity_Hatch) mMetaTileEntity).getTexturePage() : 0,
oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0,
oRedstoneData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)),
- oColor = mColor),
+ oColor = mColor),
xCoord, zCoord);
mSendClientData = false;
}
@@ -1191,8 +1199,10 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
public boolean playerOwnsThis(EntityPlayer aPlayer, boolean aCheckPrecicely) {
if (!canAccessData()) return false;
if (aCheckPrecicely || privateAccess() || (mOwnerName.length() == 0))
- if ((mOwnerName.length() == 0) && isServerSide()) setOwnerName(aPlayer.getDisplayName());
- else if (privateAccess() && !aPlayer.getDisplayName().equals("Player") && !mOwnerName.equals("Player") && !mOwnerName.equals(aPlayer.getDisplayName()))
+ if ((mOwnerName.length() == 0) && isServerSide()) {
+ setOwnerName(aPlayer.getDisplayName());
+ setOwnerUuid(aPlayer.getUniqueID());
+ } else if (privateAccess() && !aPlayer.getDisplayName().equals("Player") && !mOwnerName.equals("Player") && !mOwnerName.equals(aPlayer.getDisplayName()))
return false;
return true;
}
@@ -1244,7 +1254,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
mMetaTileEntity.doExplosion(aAmount);
}
}
-
+
public void dropItems(ItemStack tItem){
if(tItem==null)return;
EntityItem tItemEntity = new EntityItem(this.worldObj, this.xCoord + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, this.yCoord + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, this.zCoord + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage()));
@@ -1261,7 +1271,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
ENTITY_ITEM_HEALTH_FIELD.setInt(tItemEntity, 99999999);
} catch (Exception ignored) {}
this.worldObj.spawnEntityInWorld(tItemEntity);
- tItem.stackSize = 0;
+ tItem.stackSize = 0;
}
@Override
@@ -1365,7 +1375,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
doEnetUpdate();
return true;
}
-
+
if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWireCutterList)) {
byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ);
if (mMetaTileEntity.onWireCutterRightClick(aSide, tSide, aPlayer, aX, aY, aZ)) {
@@ -1421,6 +1431,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
if (isUpgradable() && !mLockUpgrade) {
mLockUpgrade = true;
setOwnerName(aPlayer.getDisplayName());
+ setOwnerUuid(aPlayer.getUniqueID());
GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(3), 1.0F, -1, xCoord, yCoord, zCoord);
if (!aPlayer.capabilities.isCreativeMode) aPlayer.inventory.getCurrentItem().stackSize--;
}
@@ -1527,7 +1538,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
public byte getOutputRedstoneSignal(byte aSide) {
return getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) ? mSidedRedstone[aSide] : getGeneralRS(aSide);
}
-
+
public byte getGeneralRS(byte aSide){
if(mMetaTileEntity==null)return 0;
return mMetaTileEntity.allowGeneralRedstoneOutput() ? mSidedRedstone[aSide] : 0;
@@ -1727,6 +1738,16 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
}
@Override
+ public UUID getOwnerUuid() {
+ return mOwnerUuid;
+ }
+
+ @Override
+ public void setOwnerUuid(UUID uuid) {
+ mOwnerUuid = uuid;
+ }
+
+ @Override
public byte getComparatorValue(byte aSide) {
return canAccessData() ? mMetaTileEntity.getComparatorValue(aSide) : 0;
}
diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java
index fa7bd78c4d..9e0589c2cb 100644
--- a/src/main/java/gregtech/api/util/GT_Utility.java
+++ b/src/main/java/gregtech/api/util/GT_Utility.java
@@ -95,6 +95,7 @@ public class GT_Utility {
public static boolean TE_CHECK = false, BC_CHECK = false, CHECK_ALL = true, RF_CHECK = false;
public static Map<GT_PlayedSound, Integer> sPlayedSoundMap = new /*Concurrent*/HashMap<GT_PlayedSound, Integer>();
private static int sBookCount = 0;
+ public static UUID defaultUuid = null; // maybe default non-null? UUID.fromString("00000000-0000-0000-0000-000000000000");
static {
GregTech_API.sItemStackMappings.add(sFilledContainerToData);
@@ -1974,7 +1975,7 @@ public class GT_Utility {
public static FakePlayer getFakePlayer(IGregTechTileEntity aBaseMetaTileEntity) {
if (aBaseMetaTileEntity.getWorld() instanceof WorldServer) {
- return FakePlayerFactory.get((WorldServer) aBaseMetaTileEntity.getWorld(), new GameProfile(null, aBaseMetaTileEntity.getOwnerName()));
+ return FakePlayerFactory.get((WorldServer) aBaseMetaTileEntity.getWorld(), new GameProfile(aBaseMetaTileEntity.getOwnerUuid(), aBaseMetaTileEntity.getOwnerName()));
}
return null;
}
@@ -2189,7 +2190,7 @@ public class GT_Utility {
+ "Oils: " + (tOils != null ? tOils.length : 0) + "\n\n"
+ "Ores within " + tRadius + " blocks\n\n"
+ "Location is center of orevein\n\n"
- + "Check NEI to confirm orevein type";
+ + "Check NEI to confirm orevein type";
tNBTList.appendTag(new NBTTagString(tPageText));
if (tOres != null)
diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java
index 1fa33e2a1d..773268d424 100644
--- a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java
+++ b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java
@@ -156,6 +156,7 @@ public class GT_Item_Machines
tTileEntity.setInitialValuesAsNBT(tTileEntity.isServerSide() ? aStack.getTagCompound() : null, tDamage);
if (aPlayer != null) {
tTileEntity.setOwnerName(aPlayer.getDisplayName());
+ tTileEntity.setOwnerUuid(aPlayer.getUniqueID());
}
tTileEntity.getMetaTileEntity().initDefaultModes(aStack.getTagCompound());
final byte aSide = GT_Utility.getOppositeSide(side);