Compare commits

...
9 Commits
4 changed files with 44 additions and 38 deletions

No files matched your search

@@ -68,17 +68,21 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
}
public static void initIcons() {
initIcons(POSTFIX, ICONS);
}
protected static void initIcons(String[] postfix, Map<String, IIcon> icons) {
IconUtil.addIconProvider(new IconUtil.IIconProvider() {
@Override
public void registerIcons(IIconRegister register) {
for (String pf : POSTFIX) {
ICONS.put(ICON_KEY + pf, register.registerIcon(ICON_KEY + pf));
ICONS.put(ICON_KEY_INPUT + pf, register.registerIcon(ICON_KEY_INPUT));
ICONS.put(ICON_KEY_OUTPUT + pf, register.registerIcon(ICON_KEY_OUTPUT));
ICONS.put(ICON_CORE_KEY + pf, register.registerIcon(ICON_CORE_KEY + pf));
for (String pf : postfix) {
icons.put(ICON_KEY + pf, register.registerIcon(ICON_KEY + pf));
icons.put(ICON_KEY_INPUT + pf, register.registerIcon(ICON_KEY_INPUT));
icons.put(ICON_KEY_OUTPUT + pf, register.registerIcon(ICON_KEY_OUTPUT));
icons.put(ICON_CORE_KEY + pf, register.registerIcon(ICON_CORE_KEY + pf));
}
ICONS.put(ICON_TRANSMISSION_KEY, register.registerIcon(ICON_TRANSMISSION_KEY));
icons.put(ICON_TRANSMISSION_KEY, register.registerIcon(ICON_TRANSMISSION_KEY));
}
@Override
@@ -119,6 +123,10 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
this.subtype = meta;
}
protected int getSubtype() {
return subtype;
}
@Override
public boolean getConnectionsDirty() {
return connectionsDirty;
@@ -5,7 +5,6 @@ import static crazypants.enderio.config.Config.powerConduitEndergyTiers;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
@@ -46,71 +45,51 @@ public class PowerConduitEndergy extends PowerConduit {
}
public static void initIcons() {
IconUtil.addIconProvider(new IconUtil.IIconProvider() {
@Override
public void registerIcons(IIconRegister register) {
for (String pf : POSTFIX) {
ICONS.put(ICON_KEY + pf, register.registerIcon(ICON_KEY + pf));
ICONS.put(ICON_KEY_INPUT + pf, register.registerIcon(ICON_KEY_INPUT));
ICONS.put(ICON_KEY_OUTPUT + pf, register.registerIcon(ICON_KEY_OUTPUT));
ICONS.put(ICON_CORE_KEY + pf, register.registerIcon(ICON_CORE_KEY + pf));
}
ICONS.put(ICON_TRANSMISSION_KEY, register.registerIcon(ICON_TRANSMISSION_KEY));
}
@Override
public int getTextureType() {
return 0;
}
});
initIcons(POSTFIX, ICONS);
}
private int subtype;
public PowerConduitEndergy() {
super();
}
public PowerConduitEndergy(int meta) {
super(meta);
this.subtype = meta;
}
@Override
public ICapacitor getCapacitor() {
return getCapacitors()[subtype];
return getCapacitors()[getSubtype()];
}
@Override
public ItemStack createItem() {
return createItemStackForSubtype(subtype);
return createItemStackForSubtype(getSubtype());
}
// Rendering
@Override
public IIcon getTextureForState(CollidableComponent component) {
if (component.dir == ForgeDirection.UNKNOWN) {
return ICONS.get(ICON_CORE_KEY + POSTFIX[subtype]);
return ICONS.get(ICON_CORE_KEY + POSTFIX[getSubtype()]);
}
if (COLOR_CONTROLLER_ID.equals(component.data)) {
return IconUtil.whiteTexture;
}
return ICONS.get(ICON_KEY + POSTFIX[subtype]);
return ICONS.get(ICON_KEY + POSTFIX[getSubtype()]);
}
@Override
public IIcon getTextureForInputMode() {
return ICONS.get(ICON_KEY_INPUT + POSTFIX[subtype]);
return ICONS.get(ICON_KEY_INPUT + POSTFIX[getSubtype()]);
}
@Override
public IIcon getTextureForOutputMode() {
return ICONS.get(ICON_KEY_OUTPUT + POSTFIX[subtype]);
return ICONS.get(ICON_KEY_OUTPUT + POSTFIX[getSubtype()]);
}
@Override
public int getMaxEnergyStored() {
return getCapacitors()[subtype].getMaxEnergyStored();
return getCapacitors()[getSubtype()].getMaxEnergyStored();
}
}
@@ -84,6 +84,8 @@ public final class Config {
public static boolean reinforcedObsidianEnabled = true;
public static boolean reinforcedObsidianUseDarkSteelBlocks = false;
public static boolean enforceOfflinePlayerUUID = false;
public static boolean useAlternateBinderRecipe = false;
public static boolean useAlternateTesseractModel = false;
@@ -1031,6 +1033,13 @@ public final class Config {
"Enable per tick sampling on individual power inputs and outputs. This allows slightly more detailed messages from the RF Reader but has a negative impact on server performance.")
.getBoolean(detailedPowerTrackingEnabled);
enforceOfflinePlayerUUID = config.get(
sectionAdvanced.name,
"enforceOfflinePlayerUUID",
false,
"Enforces to use the players offline UUID. Recommendet to use before creating your world, otherwise it might breaks all secuity related things.")
.getBoolean(enforceOfflinePlayerUUID);
useSneakMouseWheelYetaWrench = config.get(
sectionPersonal.name,
"useSneakMouseWheelYetaWrench",
+13 -3
View File
@@ -6,12 +6,15 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.common.UsernameCache;
import com.enderio.core.common.util.PlayerUtil;
import com.google.common.base.Charsets;
import com.mojang.authlib.GameProfile;
import crazypants.enderio.Log;
import crazypants.enderio.config.Config;
public class UserIdent {
@@ -75,7 +78,7 @@ public class UserIdent {
* changes, implement them and write a log message.
*/
public static @Nonnull UserIdent create(@Nonnull String suuid, @Nullable String playerName) {
if (NONE_MARKER.equals(suuid)) {
if (NONE_MARKER.equals(suuid) || Config.enforceOfflinePlayerUUID) {
return new UserIdent(null, playerName);
}
try {
@@ -109,8 +112,7 @@ public class UserIdent {
*/
public static @Nonnull UserIdent create(@Nullable GameProfile gameProfile) {
if (gameProfile != null && (gameProfile.getId() != null || gameProfile.getName() != null)) {
if (gameProfile.getId() != null && gameProfile.getName() != null
&& gameProfile.getId().equals(offlineUUID(gameProfile.getName()))) {
if (gameProfile.getName() != null && (Config.enforceOfflinePlayerUUID || !isOnlineMode())) {
return new UserIdent(null, gameProfile.getName());
} else {
return new UserIdent(gameProfile.getId(), gameProfile.getName());
@@ -120,6 +122,11 @@ public class UserIdent {
}
}
private static boolean isOnlineMode() {
MinecraftServer server = MinecraftServer.getServer();
return server != null ? server.isServerInOnlineMode() : true;
}
private static @Nonnull UUID offlineUUID(String playerName) {
UUID result = UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes(Charsets.UTF_8));
return result != null ? result : new UUID(-1, -1);
@@ -220,6 +227,9 @@ public class UserIdent {
@Override
public boolean equals(Object obj) {
if (obj instanceof UUID) {
return getUUID().equals(obj);
}
return this == obj;
}