base mod created
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
public class ActionResult<T>
|
||||
{
|
||||
private final EnumActionResult type;
|
||||
private final T result;
|
||||
|
||||
public ActionResult(EnumActionResult typeIn, T resultIn)
|
||||
{
|
||||
this.type = typeIn;
|
||||
this.result = resultIn;
|
||||
}
|
||||
|
||||
public EnumActionResult getType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public T getResult()
|
||||
{
|
||||
return this.result;
|
||||
}
|
||||
|
||||
//Just a generic helper function to make typecasing easier...
|
||||
public static <T> ActionResult<T> newResult(EnumActionResult result, T value)
|
||||
{
|
||||
return new ActionResult<T>(result, value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
public class BitArray
|
||||
{
|
||||
/** The long array that is used to store the data for this BitArray. */
|
||||
private final long[] longArray;
|
||||
/** Number of bits a single entry takes up */
|
||||
private final int bitsPerEntry;
|
||||
/**
|
||||
* The maximum value for a single entry. This also asks as a bitmask for a single entry.
|
||||
* For instance, if bitsPerEntry were 5, this value would be 31 (ie, {@code 0b00011111}).
|
||||
*/
|
||||
private final long maxEntryValue;
|
||||
/** Number of entries in this array (<b>not</b> the length of the long array that internally backs this array) */
|
||||
private final int arraySize;
|
||||
|
||||
public BitArray(int bitsPerEntryIn, int arraySizeIn)
|
||||
{
|
||||
Validate.inclusiveBetween(1L, 32L, (long)bitsPerEntryIn);
|
||||
this.arraySize = arraySizeIn;
|
||||
this.bitsPerEntry = bitsPerEntryIn;
|
||||
this.maxEntryValue = (1L << bitsPerEntryIn) - 1L;
|
||||
this.longArray = new long[MathHelper.roundUp(arraySizeIn * bitsPerEntryIn, 64) / 64];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the entry at the given location to the given value
|
||||
*/
|
||||
public void setAt(int index, int value)
|
||||
{
|
||||
Validate.inclusiveBetween(0L, (long)(this.arraySize - 1), (long)index);
|
||||
Validate.inclusiveBetween(0L, this.maxEntryValue, (long)value);
|
||||
int i = index * this.bitsPerEntry;
|
||||
int j = i / 64;
|
||||
int k = ((index + 1) * this.bitsPerEntry - 1) / 64;
|
||||
int l = i % 64;
|
||||
this.longArray[j] = this.longArray[j] & ~(this.maxEntryValue << l) | ((long)value & this.maxEntryValue) << l;
|
||||
|
||||
if (j != k)
|
||||
{
|
||||
int i1 = 64 - l;
|
||||
int j1 = this.bitsPerEntry - i1;
|
||||
this.longArray[k] = this.longArray[k] >>> j1 << j1 | ((long)value & this.maxEntryValue) >> i1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the entry at the given index
|
||||
*/
|
||||
public int getAt(int index)
|
||||
{
|
||||
Validate.inclusiveBetween(0L, (long)(this.arraySize - 1), (long)index);
|
||||
int i = index * this.bitsPerEntry;
|
||||
int j = i / 64;
|
||||
int k = ((index + 1) * this.bitsPerEntry - 1) / 64;
|
||||
int l = i % 64;
|
||||
|
||||
if (j == k)
|
||||
{
|
||||
return (int)(this.longArray[j] >>> l & this.maxEntryValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
int i1 = 64 - l;
|
||||
return (int)((this.longArray[j] >>> l | this.longArray[k] << i1) & this.maxEntryValue);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the long array that is used to store the data in this BitArray. This is useful for sending packet data.
|
||||
*/
|
||||
public long[] getBackingLongArray()
|
||||
{
|
||||
return this.longArray;
|
||||
}
|
||||
|
||||
public int size()
|
||||
{
|
||||
return this.arraySize;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
public enum BlockRenderLayer
|
||||
{
|
||||
SOLID("Solid"),
|
||||
CUTOUT_MIPPED("Mipped Cutout"),
|
||||
CUTOUT("Cutout"),
|
||||
TRANSLUCENT("Translucent");
|
||||
|
||||
private final String layerName;
|
||||
|
||||
private BlockRenderLayer(String layerNameIn)
|
||||
{
|
||||
this.layerName = layerNameIn;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return this.layerName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import io.netty.util.ResourceLeakDetector;
|
||||
import io.netty.util.ResourceLeakDetector.Level;
|
||||
|
||||
public class ChatAllowedCharacters
|
||||
{
|
||||
public static final Level NETTY_LEAK_DETECTION = Level.DISABLED;
|
||||
public static final char[] ILLEGAL_STRUCTURE_CHARACTERS = new char[] {'.', '\n', '\r', '\t', '\u0000', '\f', '`', '?', '*', '\\', '<', '>', '|', '"'};
|
||||
/** Array of the special characters that are allowed in any text drawing of Minecraft. */
|
||||
public static final char[] ILLEGAL_FILE_CHARACTERS = new char[] {'/', '\n', '\r', '\t', '\u0000', '\f', '`', '?', '*', '\\', '<', '>', '|', '"', ':'};
|
||||
|
||||
/**
|
||||
* Checks if the given character is allowed to be put into chat.
|
||||
*/
|
||||
public static boolean isAllowedCharacter(char character)
|
||||
{
|
||||
return character != 167 && character >= ' ' && character != 127;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter a string, keeping only characters for which {@link #isAllowedCharacter(char)} returns true.
|
||||
*
|
||||
* Note that this method strips line breaks, as {@link #isAllowedCharacter(char)} returns false for those.
|
||||
* @return A filtered version of the input string
|
||||
*/
|
||||
public static String filterAllowedCharacters(String input)
|
||||
{
|
||||
StringBuilder stringbuilder = new StringBuilder();
|
||||
|
||||
for (char c0 : input.toCharArray())
|
||||
{
|
||||
if (isAllowedCharacter(c0))
|
||||
{
|
||||
stringbuilder.append(c0);
|
||||
}
|
||||
}
|
||||
|
||||
return stringbuilder.toString();
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
ResourceLeakDetector.setLevel(NETTY_LEAK_DETECTION);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import java.util.AbstractSet;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class ClassInheritanceMultiMap<T> extends AbstractSet<T>
|
||||
{
|
||||
// Forge: Use concurrent collection to allow creating chunks from multiple threads safely
|
||||
private static final Set < Class<? >> ALL_KNOWN = java.util.Collections.newSetFromMap(new java.util.concurrent.ConcurrentHashMap<Class<?>, Boolean>());
|
||||
private final Map < Class<?>, List<T >> map = Maps. < Class<?>, List<T >> newHashMap();
|
||||
private final Set < Class<? >> knownKeys = Sets. < Class<? >> newIdentityHashSet();
|
||||
private final Class<T> baseClass;
|
||||
private final List<T> values = Lists.<T>newArrayList();
|
||||
|
||||
public ClassInheritanceMultiMap(Class<T> baseClassIn)
|
||||
{
|
||||
this.baseClass = baseClassIn;
|
||||
this.knownKeys.add(baseClassIn);
|
||||
this.map.put(baseClassIn, this.values);
|
||||
|
||||
for (Class<?> oclass : ALL_KNOWN)
|
||||
{
|
||||
this.createLookup(oclass);
|
||||
}
|
||||
}
|
||||
|
||||
protected void createLookup(Class<?> clazz)
|
||||
{
|
||||
ALL_KNOWN.add(clazz);
|
||||
|
||||
for (T t : this.values)
|
||||
{
|
||||
if (clazz.isAssignableFrom(t.getClass()))
|
||||
{
|
||||
this.addForClass(t, clazz);
|
||||
}
|
||||
}
|
||||
|
||||
this.knownKeys.add(clazz);
|
||||
}
|
||||
|
||||
protected Class<?> initializeClassLookup(Class<?> clazz)
|
||||
{
|
||||
if (this.baseClass.isAssignableFrom(clazz))
|
||||
{
|
||||
if (!this.knownKeys.contains(clazz))
|
||||
{
|
||||
this.createLookup(clazz);
|
||||
}
|
||||
|
||||
return clazz;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("Don't know how to search for " + clazz);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean add(T p_add_1_)
|
||||
{
|
||||
for (Class<?> oclass : this.knownKeys)
|
||||
{
|
||||
if (oclass.isAssignableFrom(p_add_1_.getClass()))
|
||||
{
|
||||
this.addForClass(p_add_1_, oclass);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void addForClass(T value, Class<?> parentClass)
|
||||
{
|
||||
List<T> list = (List)this.map.get(parentClass);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
this.map.put(parentClass, Lists.newArrayList(value));
|
||||
}
|
||||
else
|
||||
{
|
||||
list.add(value);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean remove(Object p_remove_1_)
|
||||
{
|
||||
T t = (T)p_remove_1_;
|
||||
boolean flag = false;
|
||||
|
||||
for (Class<?> oclass : this.knownKeys)
|
||||
{
|
||||
if (oclass.isAssignableFrom(t.getClass()))
|
||||
{
|
||||
List<T> list = (List)this.map.get(oclass);
|
||||
|
||||
if (list != null && list.remove(t))
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
public boolean contains(Object p_contains_1_)
|
||||
{
|
||||
return Iterators.contains(this.getByClass(p_contains_1_.getClass()).iterator(), p_contains_1_);
|
||||
}
|
||||
|
||||
public <S> Iterable<S> getByClass(final Class<S> clazz)
|
||||
{
|
||||
return new Iterable<S>()
|
||||
{
|
||||
public Iterator<S> iterator()
|
||||
{
|
||||
List<T> list = (List)ClassInheritanceMultiMap.this.map.get(ClassInheritanceMultiMap.this.initializeClassLookup(clazz));
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
return Collections.<S>emptyIterator();
|
||||
}
|
||||
else
|
||||
{
|
||||
Iterator<T> iterator = list.iterator();
|
||||
return Iterators.filter(iterator, clazz);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public Iterator<T> iterator()
|
||||
{
|
||||
return (Iterator<T>)(this.values.isEmpty() ? Collections.emptyIterator() : Iterators.unmodifiableIterator(this.values.iterator()));
|
||||
}
|
||||
|
||||
public int size()
|
||||
{
|
||||
return this.values.size();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class CombatEntry
|
||||
{
|
||||
private final DamageSource damageSrc;
|
||||
private final int time;
|
||||
private final float damage;
|
||||
private final float health;
|
||||
private final String fallSuffix;
|
||||
private final float fallDistance;
|
||||
|
||||
public CombatEntry(DamageSource damageSrcIn, int timeIn, float healthAmount, float damageAmount, String fallSuffixIn, float fallDistanceIn)
|
||||
{
|
||||
this.damageSrc = damageSrcIn;
|
||||
this.time = timeIn;
|
||||
this.damage = damageAmount;
|
||||
this.health = healthAmount;
|
||||
this.fallSuffix = fallSuffixIn;
|
||||
this.fallDistance = fallDistanceIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DamageSource of the CombatEntry instance.
|
||||
*/
|
||||
public DamageSource getDamageSrc()
|
||||
{
|
||||
return this.damageSrc;
|
||||
}
|
||||
|
||||
public float getDamage()
|
||||
{
|
||||
return this.damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if {@link net.minecraft.util.DamageSource#getEntity() damage source} is a living entity
|
||||
*/
|
||||
public boolean isLivingDamageSrc()
|
||||
{
|
||||
return this.damageSrc.getTrueSource() instanceof EntityLivingBase;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getFallSuffix()
|
||||
{
|
||||
return this.fallSuffix;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ITextComponent getDamageSrcDisplayName()
|
||||
{
|
||||
return this.getDamageSrc().getTrueSource() == null ? null : this.getDamageSrc().getTrueSource().getDisplayName();
|
||||
}
|
||||
|
||||
public float getDamageAmount()
|
||||
{
|
||||
return this.damageSrc == DamageSource.OUT_OF_WORLD ? Float.MAX_VALUE : this.fallDistance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
public class CombatRules
|
||||
{
|
||||
public static float getDamageAfterAbsorb(float damage, float totalArmor, float toughnessAttribute)
|
||||
{
|
||||
float f = 2.0F + toughnessAttribute / 4.0F;
|
||||
float f1 = MathHelper.clamp(totalArmor - damage / f, totalArmor * 0.2F, 20.0F);
|
||||
return damage * (1.0F - f1 / 25.0F);
|
||||
}
|
||||
|
||||
public static float getDamageAfterMagicAbsorb(float damage, float enchantModifiers)
|
||||
{
|
||||
float f = MathHelper.clamp(enchantModifiers, 0.0F, 20.0F);
|
||||
return damage * (1.0F - f / 25.0F);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
|
||||
public class CombatTracker
|
||||
{
|
||||
/** The CombatEntry objects that we've tracked so far. */
|
||||
private final List<CombatEntry> combatEntries = Lists.<CombatEntry>newArrayList();
|
||||
/** The entity tracked. */
|
||||
private final EntityLivingBase fighter;
|
||||
private int lastDamageTime;
|
||||
private int combatStartTime;
|
||||
private int combatEndTime;
|
||||
private boolean inCombat;
|
||||
private boolean takingDamage;
|
||||
private String fallSuffix;
|
||||
|
||||
public CombatTracker(EntityLivingBase fighterIn)
|
||||
{
|
||||
this.fighter = fighterIn;
|
||||
}
|
||||
|
||||
public void calculateFallSuffix()
|
||||
{
|
||||
this.resetFallSuffix();
|
||||
|
||||
if (this.fighter.isOnLadder())
|
||||
{
|
||||
Block block = this.fighter.world.getBlockState(new BlockPos(this.fighter.posX, this.fighter.getEntityBoundingBox().minY, this.fighter.posZ)).getBlock();
|
||||
|
||||
if (block == Blocks.LADDER)
|
||||
{
|
||||
this.fallSuffix = "ladder";
|
||||
}
|
||||
else if (block == Blocks.VINE)
|
||||
{
|
||||
this.fallSuffix = "vines";
|
||||
}
|
||||
}
|
||||
else if (this.fighter.isInWater())
|
||||
{
|
||||
this.fallSuffix = "water";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an entry for the combat tracker
|
||||
*/
|
||||
public void trackDamage(DamageSource damageSrc, float healthIn, float damageAmount)
|
||||
{
|
||||
this.reset();
|
||||
this.calculateFallSuffix();
|
||||
CombatEntry combatentry = new CombatEntry(damageSrc, this.fighter.ticksExisted, healthIn, damageAmount, this.fallSuffix, this.fighter.fallDistance);
|
||||
this.combatEntries.add(combatentry);
|
||||
this.lastDamageTime = this.fighter.ticksExisted;
|
||||
this.takingDamage = true;
|
||||
|
||||
if (combatentry.isLivingDamageSrc() && !this.inCombat && this.fighter.isEntityAlive())
|
||||
{
|
||||
this.inCombat = true;
|
||||
this.combatStartTime = this.fighter.ticksExisted;
|
||||
this.combatEndTime = this.combatStartTime;
|
||||
this.fighter.sendEnterCombat();
|
||||
}
|
||||
}
|
||||
|
||||
public ITextComponent getDeathMessage()
|
||||
{
|
||||
if (this.combatEntries.isEmpty())
|
||||
{
|
||||
return new TextComponentTranslation("death.attack.generic", new Object[] {this.fighter.getDisplayName()});
|
||||
}
|
||||
else
|
||||
{
|
||||
CombatEntry combatentry = this.getBestCombatEntry();
|
||||
CombatEntry combatentry1 = this.combatEntries.get(this.combatEntries.size() - 1);
|
||||
ITextComponent itextcomponent1 = combatentry1.getDamageSrcDisplayName();
|
||||
Entity entity = combatentry1.getDamageSrc().getTrueSource();
|
||||
ITextComponent itextcomponent;
|
||||
|
||||
if (combatentry != null && combatentry1.getDamageSrc() == DamageSource.FALL)
|
||||
{
|
||||
ITextComponent itextcomponent2 = combatentry.getDamageSrcDisplayName();
|
||||
|
||||
if (combatentry.getDamageSrc() != DamageSource.FALL && combatentry.getDamageSrc() != DamageSource.OUT_OF_WORLD)
|
||||
{
|
||||
if (itextcomponent2 != null && (itextcomponent1 == null || !itextcomponent2.equals(itextcomponent1)))
|
||||
{
|
||||
Entity entity1 = combatentry.getDamageSrc().getTrueSource();
|
||||
ItemStack itemstack1 = entity1 instanceof EntityLivingBase ? ((EntityLivingBase)entity1).getHeldItemMainhand() : ItemStack.EMPTY;
|
||||
|
||||
if (!itemstack1.isEmpty() && itemstack1.hasDisplayName())
|
||||
{
|
||||
itextcomponent = new TextComponentTranslation("death.fell.assist.item", new Object[] {this.fighter.getDisplayName(), itextcomponent2, itemstack1.getTextComponent()});
|
||||
}
|
||||
else
|
||||
{
|
||||
itextcomponent = new TextComponentTranslation("death.fell.assist", new Object[] {this.fighter.getDisplayName(), itextcomponent2});
|
||||
}
|
||||
}
|
||||
else if (itextcomponent1 != null)
|
||||
{
|
||||
ItemStack itemstack = entity instanceof EntityLivingBase ? ((EntityLivingBase)entity).getHeldItemMainhand() : ItemStack.EMPTY;
|
||||
|
||||
if (!itemstack.isEmpty() && itemstack.hasDisplayName())
|
||||
{
|
||||
itextcomponent = new TextComponentTranslation("death.fell.finish.item", new Object[] {this.fighter.getDisplayName(), itextcomponent1, itemstack.getTextComponent()});
|
||||
}
|
||||
else
|
||||
{
|
||||
itextcomponent = new TextComponentTranslation("death.fell.finish", new Object[] {this.fighter.getDisplayName(), itextcomponent1});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
itextcomponent = new TextComponentTranslation("death.fell.killer", new Object[] {this.fighter.getDisplayName()});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
itextcomponent = new TextComponentTranslation("death.fell.accident." + this.getFallSuffix(combatentry), new Object[] {this.fighter.getDisplayName()});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
itextcomponent = combatentry1.getDamageSrc().getDeathMessage(this.fighter);
|
||||
}
|
||||
|
||||
return itextcomponent;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EntityLivingBase getBestAttacker()
|
||||
{
|
||||
EntityLivingBase entitylivingbase = null;
|
||||
EntityPlayer entityplayer = null;
|
||||
float f = 0.0F;
|
||||
float f1 = 0.0F;
|
||||
|
||||
for (CombatEntry combatentry : this.combatEntries)
|
||||
{
|
||||
if (combatentry.getDamageSrc().getTrueSource() instanceof EntityPlayer && (entityplayer == null || combatentry.getDamage() > f1))
|
||||
{
|
||||
f1 = combatentry.getDamage();
|
||||
entityplayer = (EntityPlayer)combatentry.getDamageSrc().getTrueSource();
|
||||
}
|
||||
|
||||
if (combatentry.getDamageSrc().getTrueSource() instanceof EntityLivingBase && (entitylivingbase == null || combatentry.getDamage() > f))
|
||||
{
|
||||
f = combatentry.getDamage();
|
||||
entitylivingbase = (EntityLivingBase)combatentry.getDamageSrc().getTrueSource();
|
||||
}
|
||||
}
|
||||
|
||||
if (entityplayer != null && f1 >= f / 3.0F)
|
||||
{
|
||||
return entityplayer;
|
||||
}
|
||||
else
|
||||
{
|
||||
return entitylivingbase;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private CombatEntry getBestCombatEntry()
|
||||
{
|
||||
CombatEntry combatentry = null;
|
||||
CombatEntry combatentry1 = null;
|
||||
float f = 0.0F;
|
||||
float f1 = 0.0F;
|
||||
|
||||
for (int i = 0; i < this.combatEntries.size(); ++i)
|
||||
{
|
||||
CombatEntry combatentry2 = this.combatEntries.get(i);
|
||||
CombatEntry combatentry3 = i > 0 ? (CombatEntry)this.combatEntries.get(i - 1) : null;
|
||||
|
||||
if ((combatentry2.getDamageSrc() == DamageSource.FALL || combatentry2.getDamageSrc() == DamageSource.OUT_OF_WORLD) && combatentry2.getDamageAmount() > 0.0F && (combatentry == null || combatentry2.getDamageAmount() > f1))
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
combatentry = combatentry3;
|
||||
}
|
||||
else
|
||||
{
|
||||
combatentry = combatentry2;
|
||||
}
|
||||
|
||||
f1 = combatentry2.getDamageAmount();
|
||||
}
|
||||
|
||||
if (combatentry2.getFallSuffix() != null && (combatentry1 == null || combatentry2.getDamage() > f))
|
||||
{
|
||||
combatentry1 = combatentry2;
|
||||
f = combatentry2.getDamage();
|
||||
}
|
||||
}
|
||||
|
||||
if (f1 > 5.0F && combatentry != null)
|
||||
{
|
||||
return combatentry;
|
||||
}
|
||||
else if (f > 5.0F && combatentry1 != null)
|
||||
{
|
||||
return combatentry1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String getFallSuffix(CombatEntry entry)
|
||||
{
|
||||
return entry.getFallSuffix() == null ? "generic" : entry.getFallSuffix();
|
||||
}
|
||||
|
||||
public int getCombatDuration()
|
||||
{
|
||||
return this.inCombat ? this.fighter.ticksExisted - this.combatStartTime : this.combatEndTime - this.combatStartTime;
|
||||
}
|
||||
|
||||
private void resetFallSuffix()
|
||||
{
|
||||
this.fallSuffix = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets this trackers list of combat entries
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
int i = this.inCombat ? 300 : 100;
|
||||
|
||||
if (this.takingDamage && (!this.fighter.isEntityAlive() || this.fighter.ticksExisted - this.lastDamageTime > i))
|
||||
{
|
||||
boolean flag = this.inCombat;
|
||||
this.takingDamage = false;
|
||||
this.inCombat = false;
|
||||
this.combatEndTime = this.fighter.ticksExisted;
|
||||
|
||||
if (flag)
|
||||
{
|
||||
this.fighter.sendEndCombat();
|
||||
}
|
||||
|
||||
this.combatEntries.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns EntityLivingBase assigned for this CombatTracker
|
||||
*/
|
||||
public EntityLivingBase getFighter()
|
||||
{
|
||||
return this.fighter;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CooldownTracker
|
||||
{
|
||||
private final Map<Item, CooldownTracker.Cooldown> cooldowns = Maps.<Item, CooldownTracker.Cooldown>newHashMap();
|
||||
private int ticks;
|
||||
|
||||
public boolean hasCooldown(Item itemIn)
|
||||
{
|
||||
return this.getCooldown(itemIn, 0.0F) > 0.0F;
|
||||
}
|
||||
|
||||
public float getCooldown(Item itemIn, float partialTicks)
|
||||
{
|
||||
CooldownTracker.Cooldown cooldowntracker$cooldown = this.cooldowns.get(itemIn);
|
||||
|
||||
if (cooldowntracker$cooldown != null)
|
||||
{
|
||||
float f = (float)(cooldowntracker$cooldown.expireTicks - cooldowntracker$cooldown.createTicks);
|
||||
float f1 = (float)cooldowntracker$cooldown.expireTicks - ((float)this.ticks + partialTicks);
|
||||
return MathHelper.clamp(f1 / f, 0.0F, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0.0F;
|
||||
}
|
||||
}
|
||||
|
||||
public void tick()
|
||||
{
|
||||
++this.ticks;
|
||||
|
||||
if (!this.cooldowns.isEmpty())
|
||||
{
|
||||
Iterator<Entry<Item, CooldownTracker.Cooldown>> iterator = this.cooldowns.entrySet().iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Entry<Item, CooldownTracker.Cooldown> entry = (Entry)iterator.next();
|
||||
|
||||
if ((entry.getValue()).expireTicks <= this.ticks)
|
||||
{
|
||||
iterator.remove();
|
||||
this.notifyOnRemove(entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCooldown(Item itemIn, int ticksIn)
|
||||
{
|
||||
this.cooldowns.put(itemIn, new CooldownTracker.Cooldown(this.ticks, this.ticks + ticksIn));
|
||||
this.notifyOnSet(itemIn, ticksIn);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void removeCooldown(Item itemIn)
|
||||
{
|
||||
this.cooldowns.remove(itemIn);
|
||||
this.notifyOnRemove(itemIn);
|
||||
}
|
||||
|
||||
protected void notifyOnSet(Item itemIn, int ticksIn)
|
||||
{
|
||||
}
|
||||
|
||||
protected void notifyOnRemove(Item itemIn)
|
||||
{
|
||||
}
|
||||
|
||||
class Cooldown
|
||||
{
|
||||
final int createTicks;
|
||||
final int expireTicks;
|
||||
|
||||
private Cooldown(int createTicksIn, int expireTicksIn)
|
||||
{
|
||||
this.createTicks = createTicksIn;
|
||||
this.expireTicks = expireTicksIn;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.network.play.server.SPacketCooldown;
|
||||
|
||||
public class CooldownTrackerServer extends CooldownTracker
|
||||
{
|
||||
private final EntityPlayerMP player;
|
||||
|
||||
public CooldownTrackerServer(EntityPlayerMP playerIn)
|
||||
{
|
||||
this.player = playerIn;
|
||||
}
|
||||
|
||||
protected void notifyOnSet(Item itemIn, int ticksIn)
|
||||
{
|
||||
super.notifyOnSet(itemIn, ticksIn);
|
||||
this.player.connection.sendPacket(new SPacketCooldown(itemIn, ticksIn));
|
||||
}
|
||||
|
||||
protected void notifyOnRemove(Item itemIn)
|
||||
{
|
||||
super.notifyOnRemove(itemIn);
|
||||
this.player.connection.sendPacket(new SPacketCooldown(itemIn, 0));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.Key;
|
||||
import java.security.KeyFactory;
|
||||
import java.security.KeyPair;
|
||||
import java.security.KeyPairGenerator;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
import java.security.spec.EncodedKeySpec;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class CryptManager
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* Generate a new shared secret AES key from a secure random source
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static SecretKey createNewSharedKey()
|
||||
{
|
||||
try
|
||||
{
|
||||
KeyGenerator keygenerator = KeyGenerator.getInstance("AES");
|
||||
keygenerator.init(128);
|
||||
return keygenerator.generateKey();
|
||||
}
|
||||
catch (NoSuchAlgorithmException nosuchalgorithmexception)
|
||||
{
|
||||
throw new Error(nosuchalgorithmexception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates RSA KeyPair
|
||||
*/
|
||||
public static KeyPair generateKeyPair()
|
||||
{
|
||||
try
|
||||
{
|
||||
KeyPairGenerator keypairgenerator = KeyPairGenerator.getInstance("RSA");
|
||||
keypairgenerator.initialize(1024);
|
||||
return keypairgenerator.generateKeyPair();
|
||||
}
|
||||
catch (NoSuchAlgorithmException nosuchalgorithmexception)
|
||||
{
|
||||
nosuchalgorithmexception.printStackTrace();
|
||||
LOGGER.error("Key pair generation failed!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute a serverId hash for use by sendSessionRequest()
|
||||
*/
|
||||
public static byte[] getServerIdHash(String serverId, PublicKey publicKey, SecretKey secretKey)
|
||||
{
|
||||
try
|
||||
{
|
||||
return digestOperation("SHA-1", serverId.getBytes("ISO_8859_1"), secretKey.getEncoded(), publicKey.getEncoded());
|
||||
}
|
||||
catch (UnsupportedEncodingException unsupportedencodingexception)
|
||||
{
|
||||
unsupportedencodingexception.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute a message digest on arbitrary byte[] data
|
||||
*/
|
||||
private static byte[] digestOperation(String algorithm, byte[]... data)
|
||||
{
|
||||
try
|
||||
{
|
||||
MessageDigest messagedigest = MessageDigest.getInstance(algorithm);
|
||||
|
||||
for (byte[] abyte : data)
|
||||
{
|
||||
messagedigest.update(abyte);
|
||||
}
|
||||
|
||||
return messagedigest.digest();
|
||||
}
|
||||
catch (NoSuchAlgorithmException nosuchalgorithmexception)
|
||||
{
|
||||
nosuchalgorithmexception.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new PublicKey from encoded X.509 data
|
||||
*/
|
||||
public static PublicKey decodePublicKey(byte[] encodedKey)
|
||||
{
|
||||
try
|
||||
{
|
||||
EncodedKeySpec encodedkeyspec = new X509EncodedKeySpec(encodedKey);
|
||||
KeyFactory keyfactory = KeyFactory.getInstance("RSA");
|
||||
return keyfactory.generatePublic(encodedkeyspec);
|
||||
}
|
||||
catch (NoSuchAlgorithmException var3)
|
||||
{
|
||||
;
|
||||
}
|
||||
catch (InvalidKeySpecException var4)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
LOGGER.error("Public key reconstitute failed!");
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypt shared secret AES key using RSA private key
|
||||
*/
|
||||
public static SecretKey decryptSharedKey(PrivateKey key, byte[] secretKeyEncrypted)
|
||||
{
|
||||
return new SecretKeySpec(decryptData(key, secretKeyEncrypted), "AES");
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypt byte[] data with RSA public key
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static byte[] encryptData(Key key, byte[] data)
|
||||
{
|
||||
return cipherOperation(1, key, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypt byte[] data with RSA private key
|
||||
*/
|
||||
public static byte[] decryptData(Key key, byte[] data)
|
||||
{
|
||||
return cipherOperation(2, key, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypt or decrypt byte[] data using the specified key
|
||||
*/
|
||||
private static byte[] cipherOperation(int opMode, Key key, byte[] data)
|
||||
{
|
||||
try
|
||||
{
|
||||
return createTheCipherInstance(opMode, key.getAlgorithm(), key).doFinal(data);
|
||||
}
|
||||
catch (IllegalBlockSizeException illegalblocksizeexception)
|
||||
{
|
||||
illegalblocksizeexception.printStackTrace();
|
||||
}
|
||||
catch (BadPaddingException badpaddingexception)
|
||||
{
|
||||
badpaddingexception.printStackTrace();
|
||||
}
|
||||
|
||||
LOGGER.error("Cipher data failed!");
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the Cipher Instance.
|
||||
*/
|
||||
private static Cipher createTheCipherInstance(int opMode, String transformation, Key key)
|
||||
{
|
||||
try
|
||||
{
|
||||
Cipher cipher = Cipher.getInstance(transformation);
|
||||
cipher.init(opMode, key);
|
||||
return cipher;
|
||||
}
|
||||
catch (InvalidKeyException invalidkeyexception)
|
||||
{
|
||||
invalidkeyexception.printStackTrace();
|
||||
}
|
||||
catch (NoSuchAlgorithmException nosuchalgorithmexception)
|
||||
{
|
||||
nosuchalgorithmexception.printStackTrace();
|
||||
}
|
||||
catch (NoSuchPaddingException nosuchpaddingexception)
|
||||
{
|
||||
nosuchpaddingexception.printStackTrace();
|
||||
}
|
||||
|
||||
LOGGER.error("Cipher creation failed!");
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an Cipher instance using the AES/CFB8/NoPadding algorithm. Used for protocol encryption.
|
||||
*/
|
||||
public static Cipher createNetCipherInstance(int opMode, Key key)
|
||||
{
|
||||
try
|
||||
{
|
||||
Cipher cipher = Cipher.getInstance("AES/CFB8/NoPadding");
|
||||
cipher.init(opMode, key, new IvParameterSpec(key.getEncoded()));
|
||||
return cipher;
|
||||
}
|
||||
catch (GeneralSecurityException generalsecurityexception)
|
||||
{
|
||||
throw new RuntimeException(generalsecurityexception);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.entity.projectile.EntityFireball;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraft.world.Explosion;
|
||||
|
||||
public class DamageSource
|
||||
{
|
||||
public static final DamageSource IN_FIRE = (new DamageSource("inFire")).setFireDamage();
|
||||
public static final DamageSource LIGHTNING_BOLT = new DamageSource("lightningBolt");
|
||||
public static final DamageSource ON_FIRE = (new DamageSource("onFire")).setDamageBypassesArmor().setFireDamage();
|
||||
public static final DamageSource LAVA = (new DamageSource("lava")).setFireDamage();
|
||||
public static final DamageSource HOT_FLOOR = (new DamageSource("hotFloor")).setFireDamage();
|
||||
public static final DamageSource IN_WALL = (new DamageSource("inWall")).setDamageBypassesArmor();
|
||||
public static final DamageSource CRAMMING = (new DamageSource("cramming")).setDamageBypassesArmor();
|
||||
public static final DamageSource DROWN = (new DamageSource("drown")).setDamageBypassesArmor();
|
||||
public static final DamageSource STARVE = (new DamageSource("starve")).setDamageBypassesArmor().setDamageIsAbsolute();
|
||||
public static final DamageSource CACTUS = new DamageSource("cactus");
|
||||
public static final DamageSource FALL = (new DamageSource("fall")).setDamageBypassesArmor();
|
||||
public static final DamageSource FLY_INTO_WALL = (new DamageSource("flyIntoWall")).setDamageBypassesArmor();
|
||||
public static final DamageSource OUT_OF_WORLD = (new DamageSource("outOfWorld")).setDamageBypassesArmor().setDamageAllowedInCreativeMode();
|
||||
public static final DamageSource GENERIC = (new DamageSource("generic")).setDamageBypassesArmor();
|
||||
public static final DamageSource MAGIC = (new DamageSource("magic")).setDamageBypassesArmor().setMagicDamage();
|
||||
public static final DamageSource WITHER = (new DamageSource("wither")).setDamageBypassesArmor();
|
||||
public static final DamageSource ANVIL = new DamageSource("anvil");
|
||||
public static final DamageSource FALLING_BLOCK = new DamageSource("fallingBlock");
|
||||
public static final DamageSource DRAGON_BREATH = (new DamageSource("dragonBreath")).setDamageBypassesArmor();
|
||||
public static final DamageSource FIREWORKS = (new DamageSource("fireworks")).setExplosion();
|
||||
/** This kind of damage can be blocked or not. */
|
||||
private boolean isUnblockable;
|
||||
private boolean isDamageAllowedInCreativeMode;
|
||||
/** Whether or not the damage ignores modification by potion effects or enchantments. */
|
||||
private boolean damageIsAbsolute;
|
||||
private float hungerDamage = 0.1F;
|
||||
/** This kind of damage is based on fire or not. */
|
||||
private boolean fireDamage;
|
||||
/** This kind of damage is based on a projectile or not. */
|
||||
private boolean projectile;
|
||||
/** Whether this damage source will have its damage amount scaled based on the current difficulty. */
|
||||
private boolean difficultyScaled;
|
||||
/** Whether the damage is magic based. */
|
||||
private boolean magicDamage;
|
||||
private boolean explosion;
|
||||
public String damageType;
|
||||
|
||||
public static DamageSource causeMobDamage(EntityLivingBase mob)
|
||||
{
|
||||
return new EntityDamageSource("mob", mob);
|
||||
}
|
||||
|
||||
public static DamageSource causeIndirectDamage(Entity source, EntityLivingBase indirectEntityIn)
|
||||
{
|
||||
return new EntityDamageSourceIndirect("mob", source, indirectEntityIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns an EntityDamageSource of type player
|
||||
*/
|
||||
public static DamageSource causePlayerDamage(EntityPlayer player)
|
||||
{
|
||||
return new EntityDamageSource("player", player);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns EntityDamageSourceIndirect of an arrow
|
||||
*/
|
||||
public static DamageSource causeArrowDamage(EntityArrow arrow, @Nullable Entity indirectEntityIn)
|
||||
{
|
||||
return (new EntityDamageSourceIndirect("arrow", arrow, indirectEntityIn)).setProjectile();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns EntityDamageSourceIndirect of a fireball
|
||||
*/
|
||||
public static DamageSource causeFireballDamage(EntityFireball fireball, @Nullable Entity indirectEntityIn)
|
||||
{
|
||||
return indirectEntityIn == null ? (new EntityDamageSourceIndirect("onFire", fireball, fireball)).setFireDamage().setProjectile() : (new EntityDamageSourceIndirect("fireball", fireball, indirectEntityIn)).setFireDamage().setProjectile();
|
||||
}
|
||||
|
||||
public static DamageSource causeThrownDamage(Entity source, @Nullable Entity indirectEntityIn)
|
||||
{
|
||||
return (new EntityDamageSourceIndirect("thrown", source, indirectEntityIn)).setProjectile();
|
||||
}
|
||||
|
||||
public static DamageSource causeIndirectMagicDamage(Entity source, @Nullable Entity indirectEntityIn)
|
||||
{
|
||||
return (new EntityDamageSourceIndirect("indirectMagic", source, indirectEntityIn)).setDamageBypassesArmor().setMagicDamage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the EntityDamageSource of the Thorns enchantment
|
||||
*/
|
||||
public static DamageSource causeThornsDamage(Entity source)
|
||||
{
|
||||
return (new EntityDamageSource("thorns", source)).setIsThornsDamage().setMagicDamage();
|
||||
}
|
||||
|
||||
public static DamageSource causeExplosionDamage(@Nullable Explosion explosionIn)
|
||||
{
|
||||
return explosionIn != null && explosionIn.getExplosivePlacedBy() != null ? (new EntityDamageSource("explosion.player", explosionIn.getExplosivePlacedBy())).setDifficultyScaled().setExplosion() : (new DamageSource("explosion")).setDifficultyScaled().setExplosion();
|
||||
}
|
||||
|
||||
public static DamageSource causeExplosionDamage(@Nullable EntityLivingBase entityLivingBaseIn)
|
||||
{
|
||||
return entityLivingBaseIn != null ? (new EntityDamageSource("explosion.player", entityLivingBaseIn)).setDifficultyScaled().setExplosion() : (new DamageSource("explosion")).setDifficultyScaled().setExplosion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the damage is projectile based.
|
||||
*/
|
||||
public boolean isProjectile()
|
||||
{
|
||||
return this.projectile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the damage type as projectile based.
|
||||
*/
|
||||
public DamageSource setProjectile()
|
||||
{
|
||||
this.projectile = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isExplosion()
|
||||
{
|
||||
return this.explosion;
|
||||
}
|
||||
|
||||
public DamageSource setExplosion()
|
||||
{
|
||||
this.explosion = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isUnblockable()
|
||||
{
|
||||
return this.isUnblockable;
|
||||
}
|
||||
|
||||
/**
|
||||
* How much satiate(food) is consumed by this DamageSource
|
||||
*/
|
||||
public float getHungerDamage()
|
||||
{
|
||||
return this.hungerDamage;
|
||||
}
|
||||
|
||||
public boolean canHarmInCreative()
|
||||
{
|
||||
return this.isDamageAllowedInCreativeMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not the damage ignores modification by potion effects or enchantments.
|
||||
*/
|
||||
public boolean isDamageAbsolute()
|
||||
{
|
||||
return this.damageIsAbsolute;
|
||||
}
|
||||
|
||||
public DamageSource(String damageTypeIn)
|
||||
{
|
||||
this.damageType = damageTypeIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the immediate causer of the damage, e.g. the arrow entity, not its shooter
|
||||
*/
|
||||
@Nullable
|
||||
public Entity getImmediateSource()
|
||||
{
|
||||
return this.getTrueSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the true causer of the damage, e.g. the player who fired an arrow, the shulker who fired the bullet,
|
||||
* etc.
|
||||
*/
|
||||
@Nullable
|
||||
public Entity getTrueSource()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public DamageSource setDamageBypassesArmor()
|
||||
{
|
||||
this.isUnblockable = true;
|
||||
this.hungerDamage = 0.0F;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DamageSource setDamageAllowedInCreativeMode()
|
||||
{
|
||||
this.isDamageAllowedInCreativeMode = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a value indicating whether the damage is absolute (ignores modification by potion effects or enchantments),
|
||||
* and also clears out hunger damage.
|
||||
*/
|
||||
public DamageSource setDamageIsAbsolute()
|
||||
{
|
||||
this.damageIsAbsolute = true;
|
||||
this.hungerDamage = 0.0F;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the damage type as fire based.
|
||||
*/
|
||||
public DamageSource setFireDamage()
|
||||
{
|
||||
this.fireDamage = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the death message that is displayed when the player dies
|
||||
*/
|
||||
public ITextComponent getDeathMessage(EntityLivingBase entityLivingBaseIn)
|
||||
{
|
||||
EntityLivingBase entitylivingbase = entityLivingBaseIn.getAttackingEntity();
|
||||
String s = "death.attack." + this.damageType;
|
||||
String s1 = s + ".player";
|
||||
return entitylivingbase != null && I18n.canTranslate(s1) ? new TextComponentTranslation(s1, new Object[] {entityLivingBaseIn.getDisplayName(), entitylivingbase.getDisplayName()}) : new TextComponentTranslation(s, new Object[] {entityLivingBaseIn.getDisplayName()});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the damage is fire based.
|
||||
*/
|
||||
public boolean isFireDamage()
|
||||
{
|
||||
return this.fireDamage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of damage type.
|
||||
*/
|
||||
public String getDamageType()
|
||||
{
|
||||
return this.damageType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether this damage source will have its damage amount scaled based on the current difficulty.
|
||||
*/
|
||||
public DamageSource setDifficultyScaled()
|
||||
{
|
||||
this.difficultyScaled = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this damage source will have its damage amount scaled based on the current difficulty.
|
||||
*/
|
||||
public boolean isDifficultyScaled()
|
||||
{
|
||||
return this.difficultyScaled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the damage is magic based.
|
||||
*/
|
||||
public boolean isMagicDamage()
|
||||
{
|
||||
return this.magicDamage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the damage type as magic based.
|
||||
*/
|
||||
public DamageSource setMagicDamage()
|
||||
{
|
||||
this.magicDamage = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isCreativePlayer()
|
||||
{
|
||||
Entity entity = this.getTrueSource();
|
||||
return entity instanceof EntityPlayer && ((EntityPlayer)entity).capabilities.isCreativeMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the location from which the damage originates.
|
||||
*/
|
||||
@Nullable
|
||||
public Vec3d getDamageLocation()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class EnchantmentNameParts
|
||||
{
|
||||
private static final EnchantmentNameParts INSTANCE = new EnchantmentNameParts();
|
||||
private final Random rand = new Random();
|
||||
private final String[] namePartsArray = "the elder scrolls klaatu berata niktu xyzzy bless curse light darkness fire air earth water hot dry cold wet ignite snuff embiggen twist shorten stretch fiddle destroy imbue galvanize enchant free limited range of towards inside sphere cube self other ball mental physical grow shrink demon elemental spirit animal creature beast humanoid undead fresh stale phnglui mglwnafh cthulhu rlyeh wgahnagl fhtagnbaguette".split(" ");
|
||||
|
||||
public static EnchantmentNameParts getInstance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Randomly generates a new name built up of 3 or 4 randomly selected words.
|
||||
*/
|
||||
public String generateNewRandomName(FontRenderer fontRendererIn, int length)
|
||||
{
|
||||
int i = this.rand.nextInt(2) + 3;
|
||||
String s = "";
|
||||
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
if (j > 0)
|
||||
{
|
||||
s = s + " ";
|
||||
}
|
||||
|
||||
s = s + this.namePartsArray[this.rand.nextInt(this.namePartsArray.length)];
|
||||
}
|
||||
|
||||
List<String> list = fontRendererIn.listFormattedStringToWidth(s, length);
|
||||
return org.apache.commons.lang3.StringUtils.join((Iterable)(list.size() >= 2 ? list.subList(0, 2) : list), " ");
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the underlying random number generator using a given seed.
|
||||
*/
|
||||
public void reseedRandomGenerator(long seed)
|
||||
{
|
||||
this.rand.setSeed(seed);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
public class EntityDamageSource extends DamageSource
|
||||
{
|
||||
@Nullable
|
||||
protected Entity damageSourceEntity;
|
||||
/** Whether this EntityDamageSource is from an entity wearing Thorns-enchanted armor. */
|
||||
private boolean isThornsDamage;
|
||||
|
||||
public EntityDamageSource(String damageTypeIn, @Nullable Entity damageSourceEntityIn)
|
||||
{
|
||||
super(damageTypeIn);
|
||||
this.damageSourceEntity = damageSourceEntityIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this EntityDamageSource as originating from Thorns armor
|
||||
*/
|
||||
public EntityDamageSource setIsThornsDamage()
|
||||
{
|
||||
this.isThornsDamage = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getIsThornsDamage()
|
||||
{
|
||||
return this.isThornsDamage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the true causer of the damage, e.g. the player who fired an arrow, the shulker who fired the bullet,
|
||||
* etc.
|
||||
*/
|
||||
@Nullable
|
||||
public Entity getTrueSource()
|
||||
{
|
||||
return this.damageSourceEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the death message that is displayed when the player dies
|
||||
*/
|
||||
public ITextComponent getDeathMessage(EntityLivingBase entityLivingBaseIn)
|
||||
{
|
||||
ItemStack itemstack = this.damageSourceEntity instanceof EntityLivingBase ? ((EntityLivingBase)this.damageSourceEntity).getHeldItemMainhand() : ItemStack.EMPTY;
|
||||
String s = "death.attack." + this.damageType;
|
||||
String s1 = s + ".item";
|
||||
return !itemstack.isEmpty() && itemstack.hasDisplayName() && I18n.canTranslate(s1) ? new TextComponentTranslation(s1, new Object[] {entityLivingBaseIn.getDisplayName(), this.damageSourceEntity.getDisplayName(), itemstack.getTextComponent()}) : new TextComponentTranslation(s, new Object[] {entityLivingBaseIn.getDisplayName(), this.damageSourceEntity.getDisplayName()});
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this damage source will have its damage amount scaled based on the current difficulty.
|
||||
*/
|
||||
public boolean isDifficultyScaled()
|
||||
{
|
||||
return this.damageSourceEntity != null && this.damageSourceEntity instanceof EntityLivingBase && !(this.damageSourceEntity instanceof EntityPlayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the location from which the damage originates.
|
||||
*/
|
||||
@Nullable
|
||||
public Vec3d getDamageLocation()
|
||||
{
|
||||
return new Vec3d(this.damageSourceEntity.posX, this.damageSourceEntity.posY, this.damageSourceEntity.posZ);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
public class EntityDamageSourceIndirect extends EntityDamageSource
|
||||
{
|
||||
/** The entity who created the direct source, e.g. the shooter of an arrow */
|
||||
private final Entity indirectEntity;
|
||||
|
||||
public EntityDamageSourceIndirect(String damageTypeIn, Entity source, @Nullable Entity indirectEntityIn)
|
||||
{
|
||||
super(damageTypeIn, source);
|
||||
this.indirectEntity = indirectEntityIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the immediate causer of the damage, e.g. the arrow entity, not its shooter
|
||||
*/
|
||||
@Nullable
|
||||
public Entity getImmediateSource()
|
||||
{
|
||||
return this.damageSourceEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the true causer of the damage, e.g. the player who fired an arrow, the shulker who fired the bullet,
|
||||
* etc.
|
||||
*/
|
||||
@Nullable
|
||||
public Entity getTrueSource()
|
||||
{
|
||||
return this.indirectEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the death message that is displayed when the player dies
|
||||
*/
|
||||
public ITextComponent getDeathMessage(EntityLivingBase entityLivingBaseIn)
|
||||
{
|
||||
ITextComponent itextcomponent = this.indirectEntity == null ? this.damageSourceEntity.getDisplayName() : this.indirectEntity.getDisplayName();
|
||||
ItemStack itemstack = this.indirectEntity instanceof EntityLivingBase ? ((EntityLivingBase)this.indirectEntity).getHeldItemMainhand() : ItemStack.EMPTY;
|
||||
String s = "death.attack." + this.damageType;
|
||||
String s1 = s + ".item";
|
||||
return !itemstack.isEmpty() && itemstack.hasDisplayName() && I18n.canTranslate(s1) ? new TextComponentTranslation(s1, new Object[] {entityLivingBaseIn.getDisplayName(), itextcomponent, itemstack.getTextComponent()}) : new TextComponentTranslation(s, new Object[] {entityLivingBaseIn.getDisplayName(), itextcomponent});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityArmorStand;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.scoreboard.Team;
|
||||
|
||||
public final class EntitySelectors
|
||||
{
|
||||
public static final Predicate<Entity> IS_ALIVE = new Predicate<Entity>()
|
||||
{
|
||||
public boolean apply(@Nullable Entity p_apply_1_)
|
||||
{
|
||||
return p_apply_1_.isEntityAlive();
|
||||
}
|
||||
};
|
||||
/** Selects only entities which are neither ridden by anything nor ride on anything */
|
||||
public static final Predicate<Entity> IS_STANDALONE = new Predicate<Entity>()
|
||||
{
|
||||
public boolean apply(@Nullable Entity p_apply_1_)
|
||||
{
|
||||
return p_apply_1_.isEntityAlive() && !p_apply_1_.isBeingRidden() && !p_apply_1_.isRiding();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Entity> HAS_INVENTORY = new Predicate<Entity>()
|
||||
{
|
||||
public boolean apply(@Nullable Entity p_apply_1_)
|
||||
{
|
||||
return p_apply_1_ instanceof IInventory && p_apply_1_.isEntityAlive();
|
||||
}
|
||||
};
|
||||
public static final Predicate<Entity> CAN_AI_TARGET = new Predicate<Entity>()
|
||||
{
|
||||
public boolean apply(@Nullable Entity p_apply_1_)
|
||||
{
|
||||
return !(p_apply_1_ instanceof EntityPlayer) || !((EntityPlayer)p_apply_1_).isSpectator() && !((EntityPlayer)p_apply_1_).isCreative();
|
||||
}
|
||||
};
|
||||
/** Selects entities which are either not players or players that are not spectating */
|
||||
public static final Predicate<Entity> NOT_SPECTATING = new Predicate<Entity>()
|
||||
{
|
||||
public boolean apply(@Nullable Entity p_apply_1_)
|
||||
{
|
||||
return !(p_apply_1_ instanceof EntityPlayer) || !((EntityPlayer)p_apply_1_).isSpectator();
|
||||
}
|
||||
};
|
||||
|
||||
public static <T extends Entity> Predicate<T> withinRange(final double x, final double y, final double z, double range)
|
||||
{
|
||||
final double d0 = range * range;
|
||||
return new Predicate<T>()
|
||||
{
|
||||
public boolean apply(@Nullable T p_apply_1_)
|
||||
{
|
||||
return p_apply_1_ != null && p_apply_1_.getDistanceSq(x, y, z) <= d0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static <T extends Entity> Predicate<T> getTeamCollisionPredicate(final Entity entityIn)
|
||||
{
|
||||
final Team team = entityIn.getTeam();
|
||||
final Team.CollisionRule team$collisionrule = team == null ? Team.CollisionRule.ALWAYS : team.getCollisionRule();
|
||||
Predicate<?> ret = team$collisionrule == Team.CollisionRule.NEVER ? Predicates.alwaysFalse() : Predicates.and(NOT_SPECTATING, new Predicate<Entity>()
|
||||
{
|
||||
public boolean apply(@Nullable Entity p_apply_1_)
|
||||
{
|
||||
if (!p_apply_1_.canBePushed())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!entityIn.world.isRemote || p_apply_1_ instanceof EntityPlayer && ((EntityPlayer)p_apply_1_).isUser())
|
||||
{
|
||||
Team team1 = p_apply_1_.getTeam();
|
||||
Team.CollisionRule team$collisionrule1 = team1 == null ? Team.CollisionRule.ALWAYS : team1.getCollisionRule();
|
||||
|
||||
if (team$collisionrule1 == Team.CollisionRule.NEVER)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean flag = team != null && team.isSameTeam(team1);
|
||||
|
||||
if ((team$collisionrule == Team.CollisionRule.HIDE_FOR_OWN_TEAM || team$collisionrule1 == Team.CollisionRule.HIDE_FOR_OWN_TEAM) && flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return team$collisionrule != Team.CollisionRule.HIDE_FOR_OTHER_TEAMS && team$collisionrule1 != Team.CollisionRule.HIDE_FOR_OTHER_TEAMS || flag;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
return (Predicate<T>)ret;
|
||||
}
|
||||
|
||||
public static Predicate<Entity> notRiding(final Entity p_191324_0_)
|
||||
{
|
||||
return new Predicate<Entity>()
|
||||
{
|
||||
public boolean apply(@Nullable Entity p_apply_1_)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (p_apply_1_.isRiding())
|
||||
{
|
||||
p_apply_1_ = p_apply_1_.getRidingEntity();
|
||||
|
||||
if (p_apply_1_ != p_191324_0_)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static class ArmoredMob implements Predicate<Entity>
|
||||
{
|
||||
private final ItemStack armor;
|
||||
|
||||
public ArmoredMob(ItemStack armor)
|
||||
{
|
||||
this.armor = armor;
|
||||
}
|
||||
|
||||
public boolean apply(@Nullable Entity p_apply_1_)
|
||||
{
|
||||
if (!p_apply_1_.isEntityAlive())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!(p_apply_1_ instanceof EntityLivingBase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
EntityLivingBase entitylivingbase = (EntityLivingBase)p_apply_1_;
|
||||
|
||||
if (!entitylivingbase.getItemStackFromSlot(EntityLiving.getSlotForItemStack(this.armor)).isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (entitylivingbase instanceof EntityLiving)
|
||||
{
|
||||
return ((EntityLiving)entitylivingbase).canPickUpLoot();
|
||||
}
|
||||
else if (entitylivingbase instanceof EntityArmorStand)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return entitylivingbase instanceof EntityPlayer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
public enum EnumActionResult
|
||||
{
|
||||
SUCCESS,
|
||||
PASS,
|
||||
FAIL;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
public enum EnumBlockRenderType
|
||||
{
|
||||
INVISIBLE,
|
||||
LIQUID,
|
||||
ENTITYBLOCK_ANIMATED,
|
||||
MODEL;
|
||||
}
|
||||
516
build/tmp/recompileMc/sources/net/minecraft/util/EnumFacing.java
Normal file
516
build/tmp/recompileMc/sources/net/minecraft/util/EnumFacing.java
Normal file
@@ -0,0 +1,516 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
|
||||
public enum EnumFacing implements IStringSerializable
|
||||
{
|
||||
DOWN(0, 1, -1, "down", EnumFacing.AxisDirection.NEGATIVE, EnumFacing.Axis.Y, new Vec3i(0, -1, 0)),
|
||||
UP(1, 0, -1, "up", EnumFacing.AxisDirection.POSITIVE, EnumFacing.Axis.Y, new Vec3i(0, 1, 0)),
|
||||
NORTH(2, 3, 2, "north", EnumFacing.AxisDirection.NEGATIVE, EnumFacing.Axis.Z, new Vec3i(0, 0, -1)),
|
||||
SOUTH(3, 2, 0, "south", EnumFacing.AxisDirection.POSITIVE, EnumFacing.Axis.Z, new Vec3i(0, 0, 1)),
|
||||
WEST(4, 5, 1, "west", EnumFacing.AxisDirection.NEGATIVE, EnumFacing.Axis.X, new Vec3i(-1, 0, 0)),
|
||||
EAST(5, 4, 3, "east", EnumFacing.AxisDirection.POSITIVE, EnumFacing.Axis.X, new Vec3i(1, 0, 0));
|
||||
|
||||
/** Ordering index for D-U-N-S-W-E */
|
||||
private final int index;
|
||||
/** Index of the opposite Facing in the VALUES array */
|
||||
private final int opposite;
|
||||
/** Ordering index for the HORIZONTALS field (S-W-N-E) */
|
||||
private final int horizontalIndex;
|
||||
private final String name;
|
||||
private final EnumFacing.Axis axis;
|
||||
private final EnumFacing.AxisDirection axisDirection;
|
||||
/** Normalized Vector that points in the direction of this Facing */
|
||||
private final Vec3i directionVec;
|
||||
/** All facings in D-U-N-S-W-E order */
|
||||
public static final EnumFacing[] VALUES = new EnumFacing[6];
|
||||
/** All Facings with horizontal axis in order S-W-N-E */
|
||||
public static final EnumFacing[] HORIZONTALS = new EnumFacing[4];
|
||||
private static final Map<String, EnumFacing> NAME_LOOKUP = Maps.<String, EnumFacing>newHashMap();
|
||||
|
||||
private EnumFacing(int indexIn, int oppositeIn, int horizontalIndexIn, String nameIn, EnumFacing.AxisDirection axisDirectionIn, EnumFacing.Axis axisIn, Vec3i directionVecIn)
|
||||
{
|
||||
this.index = indexIn;
|
||||
this.horizontalIndex = horizontalIndexIn;
|
||||
this.opposite = oppositeIn;
|
||||
this.name = nameIn;
|
||||
this.axis = axisIn;
|
||||
this.axisDirection = axisDirectionIn;
|
||||
this.directionVec = directionVecIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Index of this Facing (0-5). The order is D-U-N-S-W-E
|
||||
*/
|
||||
public int getIndex()
|
||||
{
|
||||
return this.index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the index of this horizontal facing (0-3). The order is S-W-N-E
|
||||
*/
|
||||
public int getHorizontalIndex()
|
||||
{
|
||||
return this.horizontalIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the AxisDirection of this Facing.
|
||||
*/
|
||||
public EnumFacing.AxisDirection getAxisDirection()
|
||||
{
|
||||
return this.axisDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the opposite Facing (e.g. DOWN => UP)
|
||||
*/
|
||||
public EnumFacing getOpposite()
|
||||
{
|
||||
return getFront(this.opposite);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate this Facing around the given axis clockwise. If this facing cannot be rotated around the given axis,
|
||||
* returns this facing without rotating.
|
||||
*/
|
||||
public EnumFacing rotateAround(EnumFacing.Axis axis)
|
||||
{
|
||||
switch (axis)
|
||||
{
|
||||
case X:
|
||||
|
||||
if (this != WEST && this != EAST)
|
||||
{
|
||||
return this.rotateX();
|
||||
}
|
||||
|
||||
return this;
|
||||
case Y:
|
||||
|
||||
if (this != UP && this != DOWN)
|
||||
{
|
||||
return this.rotateY();
|
||||
}
|
||||
|
||||
return this;
|
||||
case Z:
|
||||
|
||||
if (this != NORTH && this != SOUTH)
|
||||
{
|
||||
return this.rotateZ();
|
||||
}
|
||||
|
||||
return this;
|
||||
default:
|
||||
throw new IllegalStateException("Unable to get CW facing for axis " + axis);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate this Facing around the Y axis clockwise (NORTH => EAST => SOUTH => WEST => NORTH)
|
||||
*/
|
||||
public EnumFacing rotateY()
|
||||
{
|
||||
switch (this)
|
||||
{
|
||||
case NORTH:
|
||||
return EAST;
|
||||
case EAST:
|
||||
return SOUTH;
|
||||
case SOUTH:
|
||||
return WEST;
|
||||
case WEST:
|
||||
return NORTH;
|
||||
default:
|
||||
throw new IllegalStateException("Unable to get Y-rotated facing of " + this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate this Facing around the X axis (NORTH => DOWN => SOUTH => UP => NORTH)
|
||||
*/
|
||||
private EnumFacing rotateX()
|
||||
{
|
||||
switch (this)
|
||||
{
|
||||
case NORTH:
|
||||
return DOWN;
|
||||
case EAST:
|
||||
case WEST:
|
||||
default:
|
||||
throw new IllegalStateException("Unable to get X-rotated facing of " + this);
|
||||
case SOUTH:
|
||||
return UP;
|
||||
case UP:
|
||||
return NORTH;
|
||||
case DOWN:
|
||||
return SOUTH;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate this Facing around the Z axis (EAST => DOWN => WEST => UP => EAST)
|
||||
*/
|
||||
private EnumFacing rotateZ()
|
||||
{
|
||||
switch (this)
|
||||
{
|
||||
case EAST:
|
||||
return DOWN;
|
||||
case SOUTH:
|
||||
default:
|
||||
throw new IllegalStateException("Unable to get Z-rotated facing of " + this);
|
||||
case WEST:
|
||||
return UP;
|
||||
case UP:
|
||||
return EAST;
|
||||
case DOWN:
|
||||
return WEST;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate this Facing around the Y axis counter-clockwise (NORTH => WEST => SOUTH => EAST => NORTH)
|
||||
*/
|
||||
public EnumFacing rotateYCCW()
|
||||
{
|
||||
switch (this)
|
||||
{
|
||||
case NORTH:
|
||||
return WEST;
|
||||
case EAST:
|
||||
return NORTH;
|
||||
case SOUTH:
|
||||
return EAST;
|
||||
case WEST:
|
||||
return SOUTH;
|
||||
default:
|
||||
throw new IllegalStateException("Unable to get CCW facing of " + this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a offset that addresses the block in front of this facing.
|
||||
*/
|
||||
public int getFrontOffsetX()
|
||||
{
|
||||
return this.axis == EnumFacing.Axis.X ? this.axisDirection.getOffset() : 0;
|
||||
}
|
||||
|
||||
public int getFrontOffsetY()
|
||||
{
|
||||
return this.axis == EnumFacing.Axis.Y ? this.axisDirection.getOffset() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a offset that addresses the block in front of this facing.
|
||||
*/
|
||||
public int getFrontOffsetZ()
|
||||
{
|
||||
return this.axis == EnumFacing.Axis.Z ? this.axisDirection.getOffset() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as getName, but does not override the method from Enum.
|
||||
*/
|
||||
public String getName2()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public EnumFacing.Axis getAxis()
|
||||
{
|
||||
return this.axis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the facing specified by the given name
|
||||
*/
|
||||
@Nullable
|
||||
public static EnumFacing byName(String name)
|
||||
{
|
||||
return name == null ? null : (EnumFacing)NAME_LOOKUP.get(name.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Facing by it's index (0-5). The order is D-U-N-S-W-E. Named getFront for legacy reasons.
|
||||
*/
|
||||
public static EnumFacing getFront(int index)
|
||||
{
|
||||
return VALUES[MathHelper.abs(index % VALUES.length)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Facing by it's horizontal index (0-3). The order is S-W-N-E.
|
||||
*/
|
||||
public static EnumFacing getHorizontal(int horizontalIndexIn)
|
||||
{
|
||||
return HORIZONTALS[MathHelper.abs(horizontalIndexIn % HORIZONTALS.length)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Facing corresponding to the given angle (0-360). An angle of 0 is SOUTH, an angle of 90 would be WEST.
|
||||
*/
|
||||
public static EnumFacing fromAngle(double angle)
|
||||
{
|
||||
return getHorizontal(MathHelper.floor(angle / 90.0D + 0.5D) & 3);
|
||||
}
|
||||
|
||||
public float getHorizontalAngle()
|
||||
{
|
||||
return (float)((this.horizontalIndex & 3) * 90);
|
||||
}
|
||||
|
||||
/**
|
||||
* Choose a random Facing using the given Random
|
||||
*/
|
||||
public static EnumFacing random(Random rand)
|
||||
{
|
||||
return values()[rand.nextInt(values().length)];
|
||||
}
|
||||
|
||||
public static EnumFacing getFacingFromVector(float x, float y, float z)
|
||||
{
|
||||
EnumFacing enumfacing = NORTH;
|
||||
float f = Float.MIN_VALUE;
|
||||
|
||||
for (EnumFacing enumfacing1 : values())
|
||||
{
|
||||
float f1 = x * (float)enumfacing1.directionVec.getX() + y * (float)enumfacing1.directionVec.getY() + z * (float)enumfacing1.directionVec.getZ();
|
||||
|
||||
if (f1 > f)
|
||||
{
|
||||
f = f1;
|
||||
enumfacing = enumfacing1;
|
||||
}
|
||||
}
|
||||
|
||||
return enumfacing;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public static EnumFacing getFacingFromAxis(EnumFacing.AxisDirection axisDirectionIn, EnumFacing.Axis axisIn)
|
||||
{
|
||||
for (EnumFacing enumfacing : values())
|
||||
{
|
||||
if (enumfacing.getAxisDirection() == axisDirectionIn && enumfacing.getAxis() == axisIn)
|
||||
{
|
||||
return enumfacing;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("No such direction: " + axisDirectionIn + " " + axisIn);
|
||||
}
|
||||
|
||||
public static EnumFacing getDirectionFromEntityLiving(BlockPos pos, EntityLivingBase placer)
|
||||
{
|
||||
if (Math.abs(placer.posX - (double)((float)pos.getX() + 0.5F)) < 2.0D && Math.abs(placer.posZ - (double)((float)pos.getZ() + 0.5F)) < 2.0D)
|
||||
{
|
||||
double d0 = placer.posY + (double)placer.getEyeHeight();
|
||||
|
||||
if (d0 - (double)pos.getY() > 2.0D)
|
||||
{
|
||||
return UP;
|
||||
}
|
||||
|
||||
if ((double)pos.getY() - d0 > 0.0D)
|
||||
{
|
||||
return DOWN;
|
||||
}
|
||||
}
|
||||
|
||||
return placer.getHorizontalFacing().getOpposite();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a normalized Vector that points in the direction of this Facing.
|
||||
*/
|
||||
public Vec3i getDirectionVec()
|
||||
{
|
||||
return this.directionVec;
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
for (EnumFacing enumfacing : values())
|
||||
{
|
||||
VALUES[enumfacing.index] = enumfacing;
|
||||
|
||||
if (enumfacing.getAxis().isHorizontal())
|
||||
{
|
||||
HORIZONTALS[enumfacing.horizontalIndex] = enumfacing;
|
||||
}
|
||||
|
||||
NAME_LOOKUP.put(enumfacing.getName2().toLowerCase(Locale.ROOT), enumfacing);
|
||||
}
|
||||
}
|
||||
|
||||
public static enum Axis implements Predicate<EnumFacing>, IStringSerializable {
|
||||
X("x", EnumFacing.Plane.HORIZONTAL),
|
||||
Y("y", EnumFacing.Plane.VERTICAL),
|
||||
Z("z", EnumFacing.Plane.HORIZONTAL);
|
||||
|
||||
private static final Map<String, EnumFacing.Axis> NAME_LOOKUP = Maps.<String, EnumFacing.Axis>newHashMap();
|
||||
private final String name;
|
||||
private final EnumFacing.Plane plane;
|
||||
|
||||
private Axis(String name, EnumFacing.Plane plane)
|
||||
{
|
||||
this.name = name;
|
||||
this.plane = plane;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the axis specified by the given name
|
||||
*/
|
||||
@Nullable
|
||||
public static EnumFacing.Axis byName(String name)
|
||||
{
|
||||
return name == null ? null : (EnumFacing.Axis)NAME_LOOKUP.get(name.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Like getName but doesn't override the method from Enum.
|
||||
*/
|
||||
public String getName2()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this Axis is on the vertical plane (Only true for Y)
|
||||
*/
|
||||
public boolean isVertical()
|
||||
{
|
||||
return this.plane == EnumFacing.Plane.VERTICAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this Axis is on the horizontal plane (true for X and Z)
|
||||
*/
|
||||
public boolean isHorizontal()
|
||||
{
|
||||
return this.plane == EnumFacing.Plane.HORIZONTAL;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public boolean apply(@Nullable EnumFacing p_apply_1_)
|
||||
{
|
||||
return p_apply_1_ != null && p_apply_1_.getAxis() == this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this Axis' Plane (VERTICAL for Y, HORIZONTAL for X and Z)
|
||||
*/
|
||||
public EnumFacing.Plane getPlane()
|
||||
{
|
||||
return this.plane;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
for (EnumFacing.Axis enumfacing$axis : values())
|
||||
{
|
||||
NAME_LOOKUP.put(enumfacing$axis.getName2().toLowerCase(Locale.ROOT), enumfacing$axis);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static enum AxisDirection {
|
||||
POSITIVE(1, "Towards positive"),
|
||||
NEGATIVE(-1, "Towards negative");
|
||||
|
||||
private final int offset;
|
||||
private final String description;
|
||||
|
||||
private AxisDirection(int offset, String description)
|
||||
{
|
||||
this.offset = offset;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the offset for this AxisDirection. 1 for POSITIVE, -1 for NEGATIVE
|
||||
*/
|
||||
public int getOffset()
|
||||
{
|
||||
return this.offset;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return this.description;
|
||||
}
|
||||
}
|
||||
|
||||
public static enum Plane implements Predicate<EnumFacing>, Iterable<EnumFacing> {
|
||||
HORIZONTAL,
|
||||
VERTICAL;
|
||||
|
||||
/**
|
||||
* All EnumFacing values for this Plane
|
||||
*/
|
||||
public EnumFacing[] facings()
|
||||
{
|
||||
switch (this)
|
||||
{
|
||||
case HORIZONTAL:
|
||||
return new EnumFacing[] {EnumFacing.NORTH, EnumFacing.EAST, EnumFacing.SOUTH, EnumFacing.WEST};
|
||||
case VERTICAL:
|
||||
return new EnumFacing[] {EnumFacing.UP, EnumFacing.DOWN};
|
||||
default:
|
||||
throw new Error("Someone's been tampering with the universe!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Choose a random Facing from this Plane using the given Random
|
||||
*/
|
||||
public EnumFacing random(Random rand)
|
||||
{
|
||||
EnumFacing[] aenumfacing = this.facings();
|
||||
return aenumfacing[rand.nextInt(aenumfacing.length)];
|
||||
}
|
||||
|
||||
public boolean apply(@Nullable EnumFacing p_apply_1_)
|
||||
{
|
||||
return p_apply_1_ != null && p_apply_1_.getAxis().getPlane() == this;
|
||||
}
|
||||
|
||||
public Iterator<EnumFacing> iterator()
|
||||
{
|
||||
return Iterators.<EnumFacing>forArray(this.facings());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
public enum EnumHand
|
||||
{
|
||||
MAIN_HAND,
|
||||
OFF_HAND;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public enum EnumHandSide
|
||||
{
|
||||
LEFT(new TextComponentTranslation("options.mainHand.left", new Object[0])),
|
||||
RIGHT(new TextComponentTranslation("options.mainHand.right", new Object[0]));
|
||||
|
||||
private final ITextComponent handName;
|
||||
|
||||
private EnumHandSide(ITextComponent nameIn)
|
||||
{
|
||||
this.handName = nameIn;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public EnumHandSide opposite()
|
||||
{
|
||||
return this == LEFT ? RIGHT : LEFT;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return this.handName.getUnformattedText();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public enum EnumParticleTypes
|
||||
{
|
||||
EXPLOSION_NORMAL("explode", 0, true),
|
||||
EXPLOSION_LARGE("largeexplode", 1, true),
|
||||
EXPLOSION_HUGE("hugeexplosion", 2, true),
|
||||
FIREWORKS_SPARK("fireworksSpark", 3, false),
|
||||
WATER_BUBBLE("bubble", 4, false),
|
||||
WATER_SPLASH("splash", 5, false),
|
||||
WATER_WAKE("wake", 6, false),
|
||||
SUSPENDED("suspended", 7, false),
|
||||
SUSPENDED_DEPTH("depthsuspend", 8, false),
|
||||
CRIT("crit", 9, false),
|
||||
CRIT_MAGIC("magicCrit", 10, false),
|
||||
SMOKE_NORMAL("smoke", 11, false),
|
||||
SMOKE_LARGE("largesmoke", 12, false),
|
||||
SPELL("spell", 13, false),
|
||||
SPELL_INSTANT("instantSpell", 14, false),
|
||||
SPELL_MOB("mobSpell", 15, false),
|
||||
SPELL_MOB_AMBIENT("mobSpellAmbient", 16, false),
|
||||
SPELL_WITCH("witchMagic", 17, false),
|
||||
DRIP_WATER("dripWater", 18, false),
|
||||
DRIP_LAVA("dripLava", 19, false),
|
||||
VILLAGER_ANGRY("angryVillager", 20, false),
|
||||
VILLAGER_HAPPY("happyVillager", 21, false),
|
||||
TOWN_AURA("townaura", 22, false),
|
||||
NOTE("note", 23, false),
|
||||
PORTAL("portal", 24, false),
|
||||
ENCHANTMENT_TABLE("enchantmenttable", 25, false),
|
||||
FLAME("flame", 26, false),
|
||||
LAVA("lava", 27, false),
|
||||
FOOTSTEP("footstep", 28, false),
|
||||
CLOUD("cloud", 29, false),
|
||||
REDSTONE("reddust", 30, false),
|
||||
SNOWBALL("snowballpoof", 31, false),
|
||||
SNOW_SHOVEL("snowshovel", 32, false),
|
||||
SLIME("slime", 33, false),
|
||||
HEART("heart", 34, false),
|
||||
BARRIER("barrier", 35, false),
|
||||
ITEM_CRACK("iconcrack", 36, false, 2),
|
||||
BLOCK_CRACK("blockcrack", 37, false, 1),
|
||||
BLOCK_DUST("blockdust", 38, false, 1),
|
||||
WATER_DROP("droplet", 39, false),
|
||||
ITEM_TAKE("take", 40, false),
|
||||
MOB_APPEARANCE("mobappearance", 41, true),
|
||||
DRAGON_BREATH("dragonbreath", 42, false),
|
||||
END_ROD("endRod", 43, false),
|
||||
DAMAGE_INDICATOR("damageIndicator", 44, true),
|
||||
SWEEP_ATTACK("sweepAttack", 45, true),
|
||||
FALLING_DUST("fallingdust", 46, false, 1),
|
||||
TOTEM("totem", 47, false),
|
||||
SPIT("spit", 48, true);
|
||||
|
||||
private final String particleName;
|
||||
private final int particleID;
|
||||
private final boolean shouldIgnoreRange;
|
||||
private final int argumentCount;
|
||||
private static final Map<Integer, EnumParticleTypes> PARTICLES = Maps.<Integer, EnumParticleTypes>newHashMap();
|
||||
private static final Map<String, EnumParticleTypes> BY_NAME = Maps.<String, EnumParticleTypes>newHashMap();
|
||||
|
||||
private EnumParticleTypes(String particleNameIn, int particleIDIn, boolean shouldIgnoreRangeIn, int argumentCountIn)
|
||||
{
|
||||
this.particleName = particleNameIn;
|
||||
this.particleID = particleIDIn;
|
||||
this.shouldIgnoreRange = shouldIgnoreRangeIn;
|
||||
this.argumentCount = argumentCountIn;
|
||||
}
|
||||
|
||||
private EnumParticleTypes(String particleNameIn, int particleIDIn, boolean shouldIgnoreRangeIn)
|
||||
{
|
||||
this(particleNameIn, particleIDIn, shouldIgnoreRangeIn, 0);
|
||||
}
|
||||
|
||||
public static Set<String> getParticleNames()
|
||||
{
|
||||
return BY_NAME.keySet();
|
||||
}
|
||||
|
||||
public String getParticleName()
|
||||
{
|
||||
return this.particleName;
|
||||
}
|
||||
|
||||
public int getParticleID()
|
||||
{
|
||||
return this.particleID;
|
||||
}
|
||||
|
||||
public int getArgumentCount()
|
||||
{
|
||||
return this.argumentCount;
|
||||
}
|
||||
|
||||
public boolean getShouldIgnoreRange()
|
||||
{
|
||||
return this.shouldIgnoreRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the relative EnumParticleTypes by id.
|
||||
*/
|
||||
@Nullable
|
||||
public static EnumParticleTypes getParticleFromId(int particleId)
|
||||
{
|
||||
return PARTICLES.get(Integer.valueOf(particleId));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static EnumParticleTypes getByName(String nameIn)
|
||||
{
|
||||
return BY_NAME.get(nameIn);
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
for (EnumParticleTypes enumparticletypes : values())
|
||||
{
|
||||
PARTICLES.put(Integer.valueOf(enumparticletypes.getParticleID()), enumparticletypes);
|
||||
BY_NAME.put(enumparticletypes.getParticleName(), enumparticletypes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class EnumTypeAdapterFactory implements TypeAdapterFactory
|
||||
{
|
||||
@Nullable
|
||||
public <T> TypeAdapter<T> create(Gson p_create_1_, TypeToken<T> p_create_2_)
|
||||
{
|
||||
Class<T> oclass = (Class<T>)p_create_2_.getRawType();
|
||||
|
||||
if (!oclass.isEnum())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
final Map<String, T> map = Maps.<String, T>newHashMap();
|
||||
|
||||
for (T t : oclass.getEnumConstants())
|
||||
{
|
||||
map.put(this.getName(t), t);
|
||||
}
|
||||
|
||||
return new TypeAdapter<T>()
|
||||
{
|
||||
public void write(JsonWriter p_write_1_, T p_write_2_) throws IOException
|
||||
{
|
||||
if (p_write_2_ == null)
|
||||
{
|
||||
p_write_1_.nullValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
p_write_1_.value(EnumTypeAdapterFactory.this.getName(p_write_2_));
|
||||
}
|
||||
}
|
||||
@Nullable
|
||||
public T read(JsonReader p_read_1_) throws IOException
|
||||
{
|
||||
if (p_read_1_.peek() == JsonToken.NULL)
|
||||
{
|
||||
p_read_1_.nextNull();
|
||||
return (T)null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return map.get(p_read_1_.nextString());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private String getName(Object objectIn)
|
||||
{
|
||||
return objectIn instanceof Enum ? ((Enum)objectIn).name().toLowerCase(Locale.ROOT) : objectIn.toString().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
171
build/tmp/recompileMc/sources/net/minecraft/util/FoodStats.java
Normal file
171
build/tmp/recompileMc/sources/net/minecraft/util/FoodStats.java
Normal file
@@ -0,0 +1,171 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemFood;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.EnumDifficulty;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class FoodStats
|
||||
{
|
||||
/** The player's food level. */
|
||||
private int foodLevel = 20;
|
||||
/** The player's food saturation. */
|
||||
private float foodSaturationLevel = 5.0F;
|
||||
/** The player's food exhaustion. */
|
||||
private float foodExhaustionLevel;
|
||||
/** The player's food timer value. */
|
||||
private int foodTimer;
|
||||
private int prevFoodLevel = 20;
|
||||
|
||||
/**
|
||||
* Add food stats.
|
||||
*/
|
||||
public void addStats(int foodLevelIn, float foodSaturationModifier)
|
||||
{
|
||||
this.foodLevel = Math.min(foodLevelIn + this.foodLevel, 20);
|
||||
this.foodSaturationLevel = Math.min(this.foodSaturationLevel + (float)foodLevelIn * foodSaturationModifier * 2.0F, (float)this.foodLevel);
|
||||
}
|
||||
|
||||
public void addStats(ItemFood foodItem, ItemStack stack)
|
||||
{
|
||||
this.addStats(foodItem.getHealAmount(stack), foodItem.getSaturationModifier(stack));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the food game logic.
|
||||
*/
|
||||
public void onUpdate(EntityPlayer player)
|
||||
{
|
||||
EnumDifficulty enumdifficulty = player.world.getDifficulty();
|
||||
this.prevFoodLevel = this.foodLevel;
|
||||
|
||||
if (this.foodExhaustionLevel > 4.0F)
|
||||
{
|
||||
this.foodExhaustionLevel -= 4.0F;
|
||||
|
||||
if (this.foodSaturationLevel > 0.0F)
|
||||
{
|
||||
this.foodSaturationLevel = Math.max(this.foodSaturationLevel - 1.0F, 0.0F);
|
||||
}
|
||||
else if (enumdifficulty != EnumDifficulty.PEACEFUL)
|
||||
{
|
||||
this.foodLevel = Math.max(this.foodLevel - 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
boolean flag = player.world.getGameRules().getBoolean("naturalRegeneration");
|
||||
|
||||
if (flag && this.foodSaturationLevel > 0.0F && player.shouldHeal() && this.foodLevel >= 20)
|
||||
{
|
||||
++this.foodTimer;
|
||||
|
||||
if (this.foodTimer >= 10)
|
||||
{
|
||||
float f = Math.min(this.foodSaturationLevel, 6.0F);
|
||||
player.heal(f / 6.0F);
|
||||
this.addExhaustion(f);
|
||||
this.foodTimer = 0;
|
||||
}
|
||||
}
|
||||
else if (flag && this.foodLevel >= 18 && player.shouldHeal())
|
||||
{
|
||||
++this.foodTimer;
|
||||
|
||||
if (this.foodTimer >= 80)
|
||||
{
|
||||
player.heal(1.0F);
|
||||
this.addExhaustion(6.0F);
|
||||
this.foodTimer = 0;
|
||||
}
|
||||
}
|
||||
else if (this.foodLevel <= 0)
|
||||
{
|
||||
++this.foodTimer;
|
||||
|
||||
if (this.foodTimer >= 80)
|
||||
{
|
||||
if (player.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || player.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL)
|
||||
{
|
||||
player.attackEntityFrom(DamageSource.STARVE, 1.0F);
|
||||
}
|
||||
|
||||
this.foodTimer = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.foodTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the food data for the player.
|
||||
*/
|
||||
public void readNBT(NBTTagCompound compound)
|
||||
{
|
||||
if (compound.hasKey("foodLevel", 99))
|
||||
{
|
||||
this.foodLevel = compound.getInteger("foodLevel");
|
||||
this.foodTimer = compound.getInteger("foodTickTimer");
|
||||
this.foodSaturationLevel = compound.getFloat("foodSaturationLevel");
|
||||
this.foodExhaustionLevel = compound.getFloat("foodExhaustionLevel");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the food data for the player.
|
||||
*/
|
||||
public void writeNBT(NBTTagCompound compound)
|
||||
{
|
||||
compound.setInteger("foodLevel", this.foodLevel);
|
||||
compound.setInteger("foodTickTimer", this.foodTimer);
|
||||
compound.setFloat("foodSaturationLevel", this.foodSaturationLevel);
|
||||
compound.setFloat("foodExhaustionLevel", this.foodExhaustionLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the player's food level.
|
||||
*/
|
||||
public int getFoodLevel()
|
||||
{
|
||||
return this.foodLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether the player must eat food.
|
||||
*/
|
||||
public boolean needFood()
|
||||
{
|
||||
return this.foodLevel < 20;
|
||||
}
|
||||
|
||||
/**
|
||||
* adds input to foodExhaustionLevel to a max of 40
|
||||
*/
|
||||
public void addExhaustion(float exhaustion)
|
||||
{
|
||||
this.foodExhaustionLevel = Math.min(this.foodExhaustionLevel + exhaustion, 40.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the player's food saturation level.
|
||||
*/
|
||||
public float getSaturationLevel()
|
||||
{
|
||||
return this.foodSaturationLevel;
|
||||
}
|
||||
|
||||
public void setFoodLevel(int foodLevelIn)
|
||||
{
|
||||
this.foodLevel = foodLevelIn;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void setFoodSaturationLevel(float foodSaturationLevelIn)
|
||||
{
|
||||
this.foodSaturationLevel = foodSaturationLevelIn;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class FrameTimer
|
||||
{
|
||||
/** An array with the last 240 frames */
|
||||
private final long[] frames = new long[240];
|
||||
/** The last index used when 240 frames have been set */
|
||||
private int lastIndex;
|
||||
/** A counter */
|
||||
private int counter;
|
||||
/** The next index to use in the array */
|
||||
private int index;
|
||||
|
||||
/**
|
||||
* Add a frame at the next index in the array frames
|
||||
*/
|
||||
public void addFrame(long runningTime)
|
||||
{
|
||||
this.frames[this.index] = runningTime;
|
||||
++this.index;
|
||||
|
||||
if (this.index == 240)
|
||||
{
|
||||
this.index = 0;
|
||||
}
|
||||
|
||||
if (this.counter < 240)
|
||||
{
|
||||
this.lastIndex = 0;
|
||||
++this.counter;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.lastIndex = this.parseIndex(this.index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a value from time and multiplier to display the lagometer
|
||||
*/
|
||||
public int getLagometerValue(long time, int multiplier)
|
||||
{
|
||||
double d0 = (double)time / 1.6666666E7D;
|
||||
return (int)(d0 * (double)multiplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the last index used when 240 frames have been set
|
||||
*/
|
||||
public int getLastIndex()
|
||||
{
|
||||
return this.lastIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the index of the next frame in the array
|
||||
*/
|
||||
public int getIndex()
|
||||
{
|
||||
return this.index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change 240 to 0
|
||||
*/
|
||||
public int parseIndex(int rawIndex)
|
||||
{
|
||||
return rawIndex % 240;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the array of frames
|
||||
*/
|
||||
public long[] getFrames()
|
||||
{
|
||||
return this.frames;
|
||||
}
|
||||
}
|
||||
324
build/tmp/recompileMc/sources/net/minecraft/util/HttpUtil.java
Normal file
324
build/tmp/recompileMc/sources/net/minecraft/util/HttpUtil.java
Normal file
@@ -0,0 +1,324 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.Proxy;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class HttpUtil
|
||||
{
|
||||
public static final ListeningExecutorService DOWNLOADER_EXECUTOR = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool((new ThreadFactoryBuilder()).setDaemon(true).setNameFormat("Downloader %d").build()));
|
||||
/** The number of download threads that we have started so far. */
|
||||
private static final AtomicInteger DOWNLOAD_THREADS_STARTED = new AtomicInteger(0);
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
/**
|
||||
* Builds an encoded HTTP POST content string from a string map
|
||||
*/
|
||||
public static String buildPostString(Map<String, Object> data)
|
||||
{
|
||||
StringBuilder stringbuilder = new StringBuilder();
|
||||
|
||||
for (Entry<String, Object> entry : data.entrySet())
|
||||
{
|
||||
if (stringbuilder.length() > 0)
|
||||
{
|
||||
stringbuilder.append('&');
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
stringbuilder.append(URLEncoder.encode(entry.getKey(), "UTF-8"));
|
||||
}
|
||||
catch (UnsupportedEncodingException unsupportedencodingexception1)
|
||||
{
|
||||
unsupportedencodingexception1.printStackTrace();
|
||||
}
|
||||
|
||||
if (entry.getValue() != null)
|
||||
{
|
||||
stringbuilder.append('=');
|
||||
|
||||
try
|
||||
{
|
||||
stringbuilder.append(URLEncoder.encode(entry.getValue().toString(), "UTF-8"));
|
||||
}
|
||||
catch (UnsupportedEncodingException unsupportedencodingexception)
|
||||
{
|
||||
unsupportedencodingexception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return stringbuilder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a POST to the given URL using the map as the POST args
|
||||
*/
|
||||
public static String postMap(URL url, Map<String, Object> data, boolean skipLoggingErrors, @Nullable Proxy proxyIn)
|
||||
{
|
||||
return post(url, buildPostString(data), skipLoggingErrors, proxyIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a POST to the given URL
|
||||
*/
|
||||
private static String post(URL url, String content, boolean skipLoggingErrors, @Nullable Proxy p_151225_3_)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (p_151225_3_ == null)
|
||||
{
|
||||
p_151225_3_ = Proxy.NO_PROXY;
|
||||
}
|
||||
|
||||
HttpURLConnection httpurlconnection = (HttpURLConnection)url.openConnection(p_151225_3_);
|
||||
httpurlconnection.setRequestMethod("POST");
|
||||
httpurlconnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||
httpurlconnection.setRequestProperty("Content-Length", "" + content.getBytes().length);
|
||||
httpurlconnection.setRequestProperty("Content-Language", "en-US");
|
||||
httpurlconnection.setUseCaches(false);
|
||||
httpurlconnection.setDoInput(true);
|
||||
httpurlconnection.setDoOutput(true);
|
||||
DataOutputStream dataoutputstream = new DataOutputStream(httpurlconnection.getOutputStream());
|
||||
dataoutputstream.writeBytes(content);
|
||||
dataoutputstream.flush();
|
||||
dataoutputstream.close();
|
||||
BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(httpurlconnection.getInputStream()));
|
||||
StringBuffer stringbuffer = new StringBuffer();
|
||||
String s;
|
||||
|
||||
while ((s = bufferedreader.readLine()) != null)
|
||||
{
|
||||
stringbuffer.append(s);
|
||||
stringbuffer.append('\r');
|
||||
}
|
||||
|
||||
bufferedreader.close();
|
||||
return stringbuffer.toString();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
if (!skipLoggingErrors)
|
||||
{
|
||||
LOGGER.error("Could not post to {}", url, exception);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static ListenableFuture<Object> downloadResourcePack(final File saveFile, final String packUrl, final Map<String, String> p_180192_2_, final int maxSize, @Nullable final IProgressUpdate p_180192_4_, final Proxy p_180192_5_)
|
||||
{
|
||||
ListenableFuture<?> listenablefuture = DOWNLOADER_EXECUTOR.submit(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
HttpURLConnection httpurlconnection = null;
|
||||
InputStream inputstream = null;
|
||||
OutputStream outputstream = null;
|
||||
|
||||
if (p_180192_4_ != null)
|
||||
{
|
||||
p_180192_4_.resetProgressAndMessage(I18n.translateToLocal("resourcepack.downloading"));
|
||||
p_180192_4_.displayLoadingString(I18n.translateToLocal("resourcepack.requesting"));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] abyte = new byte[4096];
|
||||
URL url = new URL(packUrl);
|
||||
httpurlconnection = (HttpURLConnection)url.openConnection(p_180192_5_);
|
||||
httpurlconnection.setInstanceFollowRedirects(true);
|
||||
float f = 0.0F;
|
||||
float f1 = (float)p_180192_2_.entrySet().size();
|
||||
|
||||
for (Entry<String, String> entry : p_180192_2_.entrySet())
|
||||
{
|
||||
httpurlconnection.setRequestProperty(entry.getKey(), entry.getValue());
|
||||
|
||||
if (p_180192_4_ != null)
|
||||
{
|
||||
p_180192_4_.setLoadingProgress((int)(++f / f1 * 100.0F));
|
||||
}
|
||||
}
|
||||
|
||||
inputstream = httpurlconnection.getInputStream();
|
||||
f1 = (float)httpurlconnection.getContentLength();
|
||||
int i = httpurlconnection.getContentLength();
|
||||
|
||||
if (p_180192_4_ != null)
|
||||
{
|
||||
p_180192_4_.displayLoadingString(I18n.translateToLocalFormatted("resourcepack.progress", String.format("%.2f", f1 / 1000.0F / 1000.0F)));
|
||||
}
|
||||
|
||||
if (saveFile.exists())
|
||||
{
|
||||
long j = saveFile.length();
|
||||
|
||||
if (j == (long)i)
|
||||
{
|
||||
if (p_180192_4_ != null)
|
||||
{
|
||||
p_180192_4_.setDoneWorking();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
HttpUtil.LOGGER.warn("Deleting {} as it does not match what we currently have ({} vs our {}).", saveFile, Integer.valueOf(i), Long.valueOf(j));
|
||||
FileUtils.deleteQuietly(saveFile);
|
||||
}
|
||||
else if (saveFile.getParentFile() != null)
|
||||
{
|
||||
saveFile.getParentFile().mkdirs();
|
||||
}
|
||||
|
||||
outputstream = new DataOutputStream(new FileOutputStream(saveFile));
|
||||
|
||||
if (maxSize > 0 && f1 > (float)maxSize)
|
||||
{
|
||||
if (p_180192_4_ != null)
|
||||
{
|
||||
p_180192_4_.setDoneWorking();
|
||||
}
|
||||
|
||||
throw new IOException("Filesize is bigger than maximum allowed (file is " + f + ", limit is " + maxSize + ")");
|
||||
}
|
||||
|
||||
int k;
|
||||
|
||||
while ((k = inputstream.read(abyte)) >= 0)
|
||||
{
|
||||
f += (float)k;
|
||||
|
||||
if (p_180192_4_ != null)
|
||||
{
|
||||
p_180192_4_.setLoadingProgress((int)(f / f1 * 100.0F));
|
||||
}
|
||||
|
||||
if (maxSize > 0 && f > (float)maxSize)
|
||||
{
|
||||
if (p_180192_4_ != null)
|
||||
{
|
||||
p_180192_4_.setDoneWorking();
|
||||
}
|
||||
|
||||
throw new IOException("Filesize was bigger than maximum allowed (got >= " + f + ", limit was " + maxSize + ")");
|
||||
}
|
||||
|
||||
if (Thread.interrupted())
|
||||
{
|
||||
HttpUtil.LOGGER.error("INTERRUPTED");
|
||||
|
||||
if (p_180192_4_ != null)
|
||||
{
|
||||
p_180192_4_.setDoneWorking();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
outputstream.write(abyte, 0, k);
|
||||
}
|
||||
|
||||
if (p_180192_4_ != null)
|
||||
{
|
||||
p_180192_4_.setDoneWorking();
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Throwable throwable)
|
||||
{
|
||||
throwable.printStackTrace();
|
||||
|
||||
if (httpurlconnection != null)
|
||||
{
|
||||
InputStream inputstream1 = httpurlconnection.getErrorStream();
|
||||
|
||||
try
|
||||
{
|
||||
HttpUtil.LOGGER.error(IOUtils.toString(inputstream1));
|
||||
}
|
||||
catch (IOException ioexception)
|
||||
{
|
||||
ioexception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (p_180192_4_ != null)
|
||||
{
|
||||
p_180192_4_.setDoneWorking();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(inputstream);
|
||||
IOUtils.closeQuietly(outputstream);
|
||||
}
|
||||
}
|
||||
});
|
||||
return (ListenableFuture<Object>) listenablefuture;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static int getSuitableLanPort() throws IOException
|
||||
{
|
||||
ServerSocket serversocket = null;
|
||||
int i = -1;
|
||||
|
||||
try
|
||||
{
|
||||
serversocket = new ServerSocket(0);
|
||||
i = serversocket.getLocalPort();
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (serversocket != null)
|
||||
{
|
||||
serversocket.close();
|
||||
}
|
||||
}
|
||||
catch (IOException var8)
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
public interface IJsonSerializable
|
||||
{
|
||||
void fromJson(JsonElement json);
|
||||
|
||||
/**
|
||||
* Gets the JsonElement that can be serialized.
|
||||
*/
|
||||
JsonElement getSerializableElement();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
public interface IObjectIntIterable<V> extends Iterable<V>
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public interface IProgressUpdate
|
||||
{
|
||||
/**
|
||||
* Shows the 'Saving level' string.
|
||||
*/
|
||||
void displaySavingString(String message);
|
||||
|
||||
/**
|
||||
* this string, followed by "working..." and then the "% complete" are the 3 lines shown. This resets progress to 0,
|
||||
* and the WorkingString to "working...".
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
void resetProgressAndMessage(String message);
|
||||
|
||||
/**
|
||||
* Displays a string on the loading screen supposed to indicate what is being done currently.
|
||||
*/
|
||||
void displayLoadingString(String message);
|
||||
|
||||
/**
|
||||
* Updates the progress bar on the loading screen to the specified amount.
|
||||
*/
|
||||
void setLoadingProgress(int progress);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void setDoneWorking();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
public interface IStringSerializable
|
||||
{
|
||||
String getName();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface ITabCompleter
|
||||
{
|
||||
/**
|
||||
* Sets the list of tab completions, as long as they were previously requested.
|
||||
*/
|
||||
void setCompletions(String... newCompletions);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
public interface IThreadListener
|
||||
{
|
||||
ListenableFuture<Object> addScheduledTask(Runnable runnableToSchedule);
|
||||
|
||||
boolean isCallingFromMinecraftThread();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
public interface ITickable
|
||||
{
|
||||
/**
|
||||
* Like the old updateEntity(), except more generic.
|
||||
*/
|
||||
void update();
|
||||
}
|
||||
300
build/tmp/recompileMc/sources/net/minecraft/util/IntHashMap.java
Normal file
300
build/tmp/recompileMc/sources/net/minecraft/util/IntHashMap.java
Normal file
@@ -0,0 +1,300 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class IntHashMap<V>
|
||||
{
|
||||
/** An array of HashEntries representing the heads of hash slot lists */
|
||||
private transient IntHashMap.Entry<V>[] slots = new IntHashMap.Entry[16];
|
||||
/** The number of items stored in this map */
|
||||
private transient int count;
|
||||
/** The grow threshold */
|
||||
private int threshold = 12;
|
||||
/** The scale factor used to determine when to grow the table */
|
||||
private final float growFactor = 0.75F;
|
||||
|
||||
/**
|
||||
* Makes the passed in integer suitable for hashing by a number of shifts
|
||||
*/
|
||||
private static int computeHash(int integer)
|
||||
{
|
||||
integer = integer ^ integer >>> 20 ^ integer >>> 12;
|
||||
return integer ^ integer >>> 7 ^ integer >>> 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the index of the slot for the hash and slot count passed in.
|
||||
*/
|
||||
private static int getSlotIndex(int hash, int slotCount)
|
||||
{
|
||||
return hash & slotCount - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the object associated to a key
|
||||
*/
|
||||
@Nullable
|
||||
public V lookup(int hashEntry)
|
||||
{
|
||||
int i = computeHash(hashEntry);
|
||||
|
||||
for (IntHashMap.Entry<V> entry = this.slots[getSlotIndex(i, this.slots.length)]; entry != null; entry = entry.nextEntry)
|
||||
{
|
||||
if (entry.hashEntry == hashEntry)
|
||||
{
|
||||
return entry.valueEntry;
|
||||
}
|
||||
}
|
||||
|
||||
return (V)null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this hash table contains the specified item.
|
||||
*/
|
||||
public boolean containsItem(int hashEntry)
|
||||
{
|
||||
return this.lookupEntry(hashEntry) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the internal entry for a key
|
||||
*/
|
||||
@Nullable
|
||||
final IntHashMap.Entry<V> lookupEntry(int hashEntry)
|
||||
{
|
||||
int i = computeHash(hashEntry);
|
||||
|
||||
for (IntHashMap.Entry<V> entry = this.slots[getSlotIndex(i, this.slots.length)]; entry != null; entry = entry.nextEntry)
|
||||
{
|
||||
if (entry.hashEntry == hashEntry)
|
||||
{
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a key and associated value to this map
|
||||
*/
|
||||
public void addKey(int hashEntry, V valueEntry)
|
||||
{
|
||||
int i = computeHash(hashEntry);
|
||||
int j = getSlotIndex(i, this.slots.length);
|
||||
|
||||
for (IntHashMap.Entry<V> entry = this.slots[j]; entry != null; entry = entry.nextEntry)
|
||||
{
|
||||
if (entry.hashEntry == hashEntry)
|
||||
{
|
||||
entry.valueEntry = valueEntry;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.insert(i, hashEntry, valueEntry, j);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increases the number of hash slots
|
||||
*/
|
||||
private void grow(int p_76047_1_)
|
||||
{
|
||||
IntHashMap.Entry<V>[] entry = this.slots;
|
||||
int i = entry.length;
|
||||
|
||||
if (i == 1073741824)
|
||||
{
|
||||
this.threshold = Integer.MAX_VALUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
IntHashMap.Entry<V>[] entry1 = new IntHashMap.Entry[p_76047_1_];
|
||||
this.copyTo(entry1);
|
||||
this.slots = entry1;
|
||||
this.threshold = (int)((float)p_76047_1_ * this.growFactor);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the hash slots to a new array
|
||||
*/
|
||||
private void copyTo(IntHashMap.Entry<V>[] p_76048_1_)
|
||||
{
|
||||
IntHashMap.Entry<V>[] entry = this.slots;
|
||||
int i = p_76048_1_.length;
|
||||
|
||||
for (int j = 0; j < entry.length; ++j)
|
||||
{
|
||||
IntHashMap.Entry<V> entry1 = entry[j];
|
||||
|
||||
if (entry1 != null)
|
||||
{
|
||||
entry[j] = null;
|
||||
|
||||
while (true)
|
||||
{
|
||||
IntHashMap.Entry<V> entry2 = entry1.nextEntry;
|
||||
int k = getSlotIndex(entry1.slotHash, i);
|
||||
entry1.nextEntry = p_76048_1_[k];
|
||||
p_76048_1_[k] = entry1;
|
||||
entry1 = entry2;
|
||||
|
||||
if (entry2 == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified object from the map and returns it
|
||||
*/
|
||||
@Nullable
|
||||
public V removeObject(int o)
|
||||
{
|
||||
IntHashMap.Entry<V> entry = this.removeEntry(o);
|
||||
return (V)(entry == null ? null : entry.valueEntry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified entry from the map and returns it
|
||||
*/
|
||||
@Nullable
|
||||
final IntHashMap.Entry<V> removeEntry(int p_76036_1_)
|
||||
{
|
||||
int i = computeHash(p_76036_1_);
|
||||
int j = getSlotIndex(i, this.slots.length);
|
||||
IntHashMap.Entry<V> entry = this.slots[j];
|
||||
IntHashMap.Entry<V> entry1;
|
||||
IntHashMap.Entry<V> entry2;
|
||||
|
||||
for (entry1 = entry; entry1 != null; entry1 = entry2)
|
||||
{
|
||||
entry2 = entry1.nextEntry;
|
||||
|
||||
if (entry1.hashEntry == p_76036_1_)
|
||||
{
|
||||
--this.count;
|
||||
|
||||
if (entry == entry1)
|
||||
{
|
||||
this.slots[j] = entry2;
|
||||
}
|
||||
else
|
||||
{
|
||||
entry.nextEntry = entry2;
|
||||
}
|
||||
|
||||
return entry1;
|
||||
}
|
||||
|
||||
entry = entry1;
|
||||
}
|
||||
|
||||
return entry1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all entries from the map
|
||||
*/
|
||||
public void clearMap()
|
||||
{
|
||||
IntHashMap.Entry<V>[] entry = this.slots;
|
||||
|
||||
for (int i = 0; i < entry.length; ++i)
|
||||
{
|
||||
entry[i] = null;
|
||||
}
|
||||
|
||||
this.count = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an object to a slot
|
||||
*/
|
||||
private void insert(int p_76040_1_, int p_76040_2_, V p_76040_3_, int p_76040_4_)
|
||||
{
|
||||
IntHashMap.Entry<V> entry = this.slots[p_76040_4_];
|
||||
this.slots[p_76040_4_] = new IntHashMap.Entry(p_76040_1_, p_76040_2_, p_76040_3_, entry);
|
||||
|
||||
if (this.count++ >= this.threshold)
|
||||
{
|
||||
this.grow(2 * this.slots.length);
|
||||
}
|
||||
}
|
||||
|
||||
static class Entry<V>
|
||||
{
|
||||
/** The hash code of this entry */
|
||||
final int hashEntry;
|
||||
/** The object stored in this entry */
|
||||
V valueEntry;
|
||||
/** The next entry in this slot */
|
||||
IntHashMap.Entry<V> nextEntry;
|
||||
/** The id of the hash slot computed from the hash */
|
||||
final int slotHash;
|
||||
|
||||
Entry(int p_i1552_1_, int p_i1552_2_, V p_i1552_3_, IntHashMap.Entry<V> p_i1552_4_)
|
||||
{
|
||||
this.valueEntry = p_i1552_3_;
|
||||
this.nextEntry = p_i1552_4_;
|
||||
this.hashEntry = p_i1552_2_;
|
||||
this.slotHash = p_i1552_1_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code for this entry
|
||||
*/
|
||||
public final int getHash()
|
||||
{
|
||||
return this.hashEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the object stored in this entry
|
||||
*/
|
||||
public final V getValue()
|
||||
{
|
||||
return this.valueEntry;
|
||||
}
|
||||
|
||||
public final boolean equals(Object p_equals_1_)
|
||||
{
|
||||
if (!(p_equals_1_ instanceof IntHashMap.Entry))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
IntHashMap.Entry<V> entry = (IntHashMap.Entry)p_equals_1_;
|
||||
|
||||
if (this.hashEntry == entry.hashEntry)
|
||||
{
|
||||
Object object = this.getValue();
|
||||
Object object1 = entry.getValue();
|
||||
|
||||
if (object == object1 || object != null && object.equals(object1))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public final int hashCode()
|
||||
{
|
||||
return IntHashMap.computeHash(this.hashEntry);
|
||||
}
|
||||
|
||||
public final String toString()
|
||||
{
|
||||
return this.getHash() + "=" + this.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterators;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class IntIdentityHashBiMap<K> implements IObjectIntIterable<K>
|
||||
{
|
||||
private static final Object EMPTY = null;
|
||||
private K[] values;
|
||||
private int[] intKeys;
|
||||
private K[] byId;
|
||||
private int nextFreeIndex;
|
||||
private int mapSize;
|
||||
|
||||
public IntIdentityHashBiMap(int initialCapacity)
|
||||
{
|
||||
initialCapacity = (int)((float)initialCapacity / 0.8F);
|
||||
this.values = (K[])(new Object[initialCapacity]);
|
||||
this.intKeys = new int[initialCapacity];
|
||||
this.byId = (K[])(new Object[initialCapacity]);
|
||||
}
|
||||
|
||||
public int getId(@Nullable K p_186815_1_)
|
||||
{
|
||||
return this.getValue(this.getIndex(p_186815_1_, this.hashObject(p_186815_1_)));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public K get(int idIn)
|
||||
{
|
||||
return (K)(idIn >= 0 && idIn < this.byId.length ? this.byId[idIn] : null);
|
||||
}
|
||||
|
||||
private int getValue(int p_186805_1_)
|
||||
{
|
||||
return p_186805_1_ == -1 ? -1 : this.intKeys[p_186805_1_];
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given object while expanding this map
|
||||
*/
|
||||
public int add(K objectIn)
|
||||
{
|
||||
int i = this.nextId();
|
||||
this.put(objectIn, i);
|
||||
return i;
|
||||
}
|
||||
|
||||
private int nextId()
|
||||
{
|
||||
while (this.nextFreeIndex < this.byId.length && this.byId[this.nextFreeIndex] != null)
|
||||
{
|
||||
++this.nextFreeIndex;
|
||||
}
|
||||
|
||||
return this.nextFreeIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rehashes the map to the new capacity
|
||||
*/
|
||||
private void grow(int capacity)
|
||||
{
|
||||
K[] ak = this.values;
|
||||
int[] aint = this.intKeys;
|
||||
this.values = (K[])(new Object[capacity]);
|
||||
this.intKeys = new int[capacity];
|
||||
this.byId = (K[])(new Object[capacity]);
|
||||
this.nextFreeIndex = 0;
|
||||
this.mapSize = 0;
|
||||
|
||||
for (int i = 0; i < ak.length; ++i)
|
||||
{
|
||||
if (ak[i] != null)
|
||||
{
|
||||
this.put(ak[i], aint[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the provided object value with the integer key.
|
||||
*/
|
||||
public void put(K objectIn, int intKey)
|
||||
{
|
||||
int i = Math.max(intKey, this.mapSize + 1);
|
||||
|
||||
if ((float)i >= (float)this.values.length * 0.8F)
|
||||
{
|
||||
int j;
|
||||
|
||||
for (j = this.values.length << 1; j < intKey; j <<= 1)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
this.grow(j);
|
||||
}
|
||||
|
||||
int k = this.findEmpty(this.hashObject(objectIn));
|
||||
this.values[k] = objectIn;
|
||||
this.intKeys[k] = intKey;
|
||||
this.byId[intKey] = objectIn;
|
||||
++this.mapSize;
|
||||
|
||||
if (intKey == this.nextFreeIndex)
|
||||
{
|
||||
++this.nextFreeIndex;
|
||||
}
|
||||
}
|
||||
|
||||
private int hashObject(@Nullable K obectIn)
|
||||
{
|
||||
return (MathHelper.hash(System.identityHashCode(obectIn)) & Integer.MAX_VALUE) % this.values.length;
|
||||
}
|
||||
|
||||
private int getIndex(@Nullable K objectIn, int p_186816_2_)
|
||||
{
|
||||
for (int i = p_186816_2_; i < this.values.length; ++i)
|
||||
{
|
||||
if (this.values[i] == objectIn)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
if (this.values[i] == EMPTY)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < p_186816_2_; ++j)
|
||||
{
|
||||
if (this.values[j] == objectIn)
|
||||
{
|
||||
return j;
|
||||
}
|
||||
|
||||
if (this.values[j] == EMPTY)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int findEmpty(int p_186806_1_)
|
||||
{
|
||||
for (int i = p_186806_1_; i < this.values.length; ++i)
|
||||
{
|
||||
if (this.values[i] == EMPTY)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < p_186806_1_; ++j)
|
||||
{
|
||||
if (this.values[j] == EMPTY)
|
||||
{
|
||||
return j;
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException("Overflowed :(");
|
||||
}
|
||||
|
||||
public Iterator<K> iterator()
|
||||
{
|
||||
return Iterators.filter(Iterators.forArray(this.byId), Predicates.notNull());
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
Arrays.fill(this.values, (Object)null);
|
||||
Arrays.fill(this.byId, (Object)null);
|
||||
this.nextFreeIndex = 0;
|
||||
this.mapSize = 0;
|
||||
}
|
||||
|
||||
public int size()
|
||||
{
|
||||
return this.mapSize;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class IntegerCache
|
||||
{
|
||||
private static final Integer[] CACHE = new Integer[65535];
|
||||
|
||||
/**
|
||||
* Get an Integer from the cache if it exists, otherwise return {@code Integer.valueOf()}
|
||||
*/
|
||||
public static Integer getInteger(int value)
|
||||
{
|
||||
return value > 0 && value < CACHE.length ? CACHE[value] : value;
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (int j = CACHE.length; i < j; ++i)
|
||||
{
|
||||
CACHE[i] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
493
build/tmp/recompileMc/sources/net/minecraft/util/JsonUtils.java
Normal file
493
build/tmp/recompileMc/sources/net/minecraft/util/JsonUtils.java
Normal file
@@ -0,0 +1,493 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.lang.reflect.Type;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class JsonUtils
|
||||
{
|
||||
/**
|
||||
* Does the given JsonObject contain a string field with the given name?
|
||||
*/
|
||||
public static boolean isString(JsonObject json, String memberName)
|
||||
{
|
||||
return !isJsonPrimitive(json, memberName) ? false : json.getAsJsonPrimitive(memberName).isString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the given JsonElement a string?
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static boolean isString(JsonElement json)
|
||||
{
|
||||
return !json.isJsonPrimitive() ? false : json.getAsJsonPrimitive().isString();
|
||||
}
|
||||
|
||||
public static boolean isNumber(JsonElement json)
|
||||
{
|
||||
return !json.isJsonPrimitive() ? false : json.getAsJsonPrimitive().isNumber();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static boolean isBoolean(JsonObject json, String memberName)
|
||||
{
|
||||
return !isJsonPrimitive(json, memberName) ? false : json.getAsJsonPrimitive(memberName).isBoolean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the given JsonObject contain an array field with the given name?
|
||||
*/
|
||||
public static boolean isJsonArray(JsonObject json, String memberName)
|
||||
{
|
||||
return !hasField(json, memberName) ? false : json.get(memberName).isJsonArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the given JsonObject contain a field with the given name whose type is primitive (String, Java primitive, or
|
||||
* Java primitive wrapper)?
|
||||
*/
|
||||
public static boolean isJsonPrimitive(JsonObject json, String memberName)
|
||||
{
|
||||
return !hasField(json, memberName) ? false : json.get(memberName).isJsonPrimitive();
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the given JsonObject contain a field with the given name?
|
||||
*/
|
||||
public static boolean hasField(JsonObject json, String memberName)
|
||||
{
|
||||
if (json == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return json.get(memberName) != null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string value of the given JsonElement. Expects the second parameter to be the name of the element's
|
||||
* field if an error message needs to be thrown.
|
||||
*/
|
||||
public static String getString(JsonElement json, String memberName)
|
||||
{
|
||||
if (json.isJsonPrimitive())
|
||||
{
|
||||
return json.getAsString();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JsonSyntaxException("Expected " + memberName + " to be a string, was " + toString(json));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string value of the field on the JsonObject with the given name.
|
||||
*/
|
||||
public static String getString(JsonObject json, String memberName)
|
||||
{
|
||||
if (json.has(memberName))
|
||||
{
|
||||
return getString(json.get(memberName), memberName);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JsonSyntaxException("Missing " + memberName + ", expected to find a string");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string value of the field on the JsonObject with the given name, or the given default value if the field
|
||||
* is missing.
|
||||
*/
|
||||
public static String getString(JsonObject json, String memberName, String fallback)
|
||||
{
|
||||
return json.has(memberName) ? getString(json.get(memberName), memberName) : fallback;
|
||||
}
|
||||
|
||||
public static Item getItem(JsonElement json, String memberName)
|
||||
{
|
||||
if (json.isJsonPrimitive())
|
||||
{
|
||||
String s = json.getAsString();
|
||||
Item item = Item.getByNameOrId(s);
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
throw new JsonSyntaxException("Expected " + memberName + " to be an item, was unknown string '" + s + "'");
|
||||
}
|
||||
else
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JsonSyntaxException("Expected " + memberName + " to be an item, was " + toString(json));
|
||||
}
|
||||
}
|
||||
|
||||
public static Item getItem(JsonObject json, String memberName)
|
||||
{
|
||||
if (json.has(memberName))
|
||||
{
|
||||
return getItem(json.get(memberName), memberName);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JsonSyntaxException("Missing " + memberName + ", expected to find an item");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the boolean value of the given JsonElement. Expects the second parameter to be the name of the element's
|
||||
* field if an error message needs to be thrown.
|
||||
*/
|
||||
public static boolean getBoolean(JsonElement json, String memberName)
|
||||
{
|
||||
if (json.isJsonPrimitive())
|
||||
{
|
||||
return json.getAsBoolean();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JsonSyntaxException("Expected " + memberName + " to be a Boolean, was " + toString(json));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the boolean value of the field on the JsonObject with the given name.
|
||||
*/
|
||||
public static boolean getBoolean(JsonObject json, String memberName)
|
||||
{
|
||||
if (json.has(memberName))
|
||||
{
|
||||
return getBoolean(json.get(memberName), memberName);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JsonSyntaxException("Missing " + memberName + ", expected to find a Boolean");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the boolean value of the field on the JsonObject with the given name, or the given default value if the
|
||||
* field is missing.
|
||||
*/
|
||||
public static boolean getBoolean(JsonObject json, String memberName, boolean fallback)
|
||||
{
|
||||
return json.has(memberName) ? getBoolean(json.get(memberName), memberName) : fallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the float value of the given JsonElement. Expects the second parameter to be the name of the element's
|
||||
* field if an error message needs to be thrown.
|
||||
*/
|
||||
public static float getFloat(JsonElement json, String memberName)
|
||||
{
|
||||
if (json.isJsonPrimitive() && json.getAsJsonPrimitive().isNumber())
|
||||
{
|
||||
return json.getAsFloat();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JsonSyntaxException("Expected " + memberName + " to be a Float, was " + toString(json));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the float value of the field on the JsonObject with the given name.
|
||||
*/
|
||||
public static float getFloat(JsonObject json, String memberName)
|
||||
{
|
||||
if (json.has(memberName))
|
||||
{
|
||||
return getFloat(json.get(memberName), memberName);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JsonSyntaxException("Missing " + memberName + ", expected to find a Float");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the float value of the field on the JsonObject with the given name, or the given default value if the field
|
||||
* is missing.
|
||||
*/
|
||||
public static float getFloat(JsonObject json, String memberName, float fallback)
|
||||
{
|
||||
return json.has(memberName) ? getFloat(json.get(memberName), memberName) : fallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the integer value of the given JsonElement. Expects the second parameter to be the name of the element's
|
||||
* field if an error message needs to be thrown.
|
||||
*/
|
||||
public static int getInt(JsonElement json, String memberName)
|
||||
{
|
||||
if (json.isJsonPrimitive() && json.getAsJsonPrimitive().isNumber())
|
||||
{
|
||||
return json.getAsInt();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JsonSyntaxException("Expected " + memberName + " to be a Int, was " + toString(json));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the integer value of the field on the JsonObject with the given name.
|
||||
*/
|
||||
public static int getInt(JsonObject json, String memberName)
|
||||
{
|
||||
if (json.has(memberName))
|
||||
{
|
||||
return getInt(json.get(memberName), memberName);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JsonSyntaxException("Missing " + memberName + ", expected to find a Int");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the integer value of the field on the JsonObject with the given name, or the given default value if the
|
||||
* field is missing.
|
||||
*/
|
||||
public static int getInt(JsonObject json, String memberName, int fallback)
|
||||
{
|
||||
return json.has(memberName) ? getInt(json.get(memberName), memberName) : fallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the given JsonElement as a JsonObject. Expects the second parameter to be the name of the element's field
|
||||
* if an error message needs to be thrown.
|
||||
*/
|
||||
public static JsonObject getJsonObject(JsonElement json, String memberName)
|
||||
{
|
||||
if (json.isJsonObject())
|
||||
{
|
||||
return json.getAsJsonObject();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JsonSyntaxException("Expected " + memberName + " to be a JsonObject, was " + toString(json));
|
||||
}
|
||||
}
|
||||
|
||||
public static JsonObject getJsonObject(JsonObject json, String memberName)
|
||||
{
|
||||
if (json.has(memberName))
|
||||
{
|
||||
return getJsonObject(json.get(memberName), memberName);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JsonSyntaxException("Missing " + memberName + ", expected to find a JsonObject");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the JsonObject field on the JsonObject with the given name, or the given default value if the field is
|
||||
* missing.
|
||||
*/
|
||||
public static JsonObject getJsonObject(JsonObject json, String memberName, JsonObject fallback)
|
||||
{
|
||||
return json.has(memberName) ? getJsonObject(json.get(memberName), memberName) : fallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the given JsonElement as a JsonArray. Expects the second parameter to be the name of the element's field if
|
||||
* an error message needs to be thrown.
|
||||
*/
|
||||
public static JsonArray getJsonArray(JsonElement json, String memberName)
|
||||
{
|
||||
if (json.isJsonArray())
|
||||
{
|
||||
return json.getAsJsonArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JsonSyntaxException("Expected " + memberName + " to be a JsonArray, was " + toString(json));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the JsonArray field on the JsonObject with the given name.
|
||||
*/
|
||||
public static JsonArray getJsonArray(JsonObject json, String memberName)
|
||||
{
|
||||
if (json.has(memberName))
|
||||
{
|
||||
return getJsonArray(json.get(memberName), memberName);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JsonSyntaxException("Missing " + memberName + ", expected to find a JsonArray");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the JsonArray field on the JsonObject with the given name, or the given default value if the field is
|
||||
* missing.
|
||||
*/
|
||||
public static JsonArray getJsonArray(JsonObject json, String memberName, @Nullable JsonArray fallback)
|
||||
{
|
||||
return json.has(memberName) ? getJsonArray(json.get(memberName), memberName) : fallback;
|
||||
}
|
||||
|
||||
public static <T> T deserializeClass(@Nullable JsonElement json, String memberName, JsonDeserializationContext context, Class <? extends T > adapter)
|
||||
{
|
||||
if (json != null)
|
||||
{
|
||||
return (T)context.deserialize(json, adapter);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JsonSyntaxException("Missing " + memberName);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T deserializeClass(JsonObject json, String memberName, JsonDeserializationContext context, Class <? extends T > adapter)
|
||||
{
|
||||
if (json.has(memberName))
|
||||
{
|
||||
return (T)deserializeClass(json.get(memberName), memberName, context, adapter);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JsonSyntaxException("Missing " + memberName);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T deserializeClass(JsonObject json, String memberName, T fallback, JsonDeserializationContext context, Class <? extends T > adapter)
|
||||
{
|
||||
return (T)(json.has(memberName) ? deserializeClass(json.get(memberName), memberName, context, adapter) : fallback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a human-readable description of the given JsonElement's type. For example: "a number (4)"
|
||||
*/
|
||||
public static String toString(JsonElement json)
|
||||
{
|
||||
String s = org.apache.commons.lang3.StringUtils.abbreviateMiddle(String.valueOf((Object)json), "...", 10);
|
||||
|
||||
if (json == null)
|
||||
{
|
||||
return "null (missing)";
|
||||
}
|
||||
else if (json.isJsonNull())
|
||||
{
|
||||
return "null (json)";
|
||||
}
|
||||
else if (json.isJsonArray())
|
||||
{
|
||||
return "an array (" + s + ")";
|
||||
}
|
||||
else if (json.isJsonObject())
|
||||
{
|
||||
return "an object (" + s + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (json.isJsonPrimitive())
|
||||
{
|
||||
JsonPrimitive jsonprimitive = json.getAsJsonPrimitive();
|
||||
|
||||
if (jsonprimitive.isNumber())
|
||||
{
|
||||
return "a number (" + s + ")";
|
||||
}
|
||||
|
||||
if (jsonprimitive.isBoolean())
|
||||
{
|
||||
return "a boolean (" + s + ")";
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static <T> T gsonDeserialize(Gson gsonIn, Reader readerIn, Class<T> adapter, boolean lenient)
|
||||
{
|
||||
try
|
||||
{
|
||||
JsonReader jsonreader = new JsonReader(readerIn);
|
||||
jsonreader.setLenient(lenient);
|
||||
return (T)gsonIn.getAdapter(adapter).read(jsonreader);
|
||||
}
|
||||
catch (IOException ioexception)
|
||||
{
|
||||
throw new JsonParseException(ioexception);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static <T> T fromJson(Gson p_193838_0_, Reader p_193838_1_, Type p_193838_2_, boolean p_193838_3_)
|
||||
{
|
||||
try
|
||||
{
|
||||
JsonReader jsonreader = new JsonReader(p_193838_1_);
|
||||
jsonreader.setLenient(p_193838_3_);
|
||||
return (T)p_193838_0_.getAdapter(TypeToken.get(p_193838_2_)).read(jsonreader);
|
||||
}
|
||||
catch (IOException ioexception)
|
||||
{
|
||||
throw new JsonParseException(ioexception);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static <T> T fromJson(Gson p_193837_0_, String p_193837_1_, Type p_193837_2_, boolean p_193837_3_)
|
||||
{
|
||||
return (T)fromJson(p_193837_0_, new StringReader(p_193837_1_), p_193837_2_, p_193837_3_);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static <T> T gsonDeserialize(Gson gsonIn, String json, Class<T> adapter, boolean lenient)
|
||||
{
|
||||
return (T)gsonDeserialize(gsonIn, new StringReader(json), adapter, lenient);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static <T> T fromJson(Gson p_193841_0_, Reader p_193841_1_, Type p_193841_2_)
|
||||
{
|
||||
return (T)fromJson(p_193841_0_, p_193841_1_, p_193841_2_, false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static <T> T gsonDeserialize(Gson p_193840_0_, String p_193840_1_, Type p_193840_2_)
|
||||
{
|
||||
return (T)fromJson(p_193840_0_, p_193840_1_, p_193840_2_, false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static <T> T fromJson(Gson p_193839_0_, Reader p_193839_1_, Class<T> p_193839_2_)
|
||||
{
|
||||
return (T)gsonDeserialize(p_193839_0_, p_193839_1_, p_193839_2_, false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static <T> T gsonDeserialize(Gson gsonIn, String json, Class<T> adapter)
|
||||
{
|
||||
return (T)gsonDeserialize(gsonIn, json, adapter, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
public abstract class LazyLoadBase<T>
|
||||
{
|
||||
private T value;
|
||||
private boolean isLoaded;
|
||||
|
||||
public T getValue()
|
||||
{
|
||||
if (!this.isLoaded)
|
||||
{
|
||||
this.isLoaded = true;
|
||||
this.value = (T)this.load();
|
||||
}
|
||||
|
||||
return this.value;
|
||||
}
|
||||
|
||||
protected abstract T load();
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class LoggingPrintStream extends PrintStream
|
||||
{
|
||||
protected static final Logger LOGGER = LogManager.getLogger();
|
||||
protected final String domain;
|
||||
|
||||
public LoggingPrintStream(String domainIn, OutputStream outStream)
|
||||
{
|
||||
super(outStream);
|
||||
this.domain = domainIn;
|
||||
}
|
||||
|
||||
public void println(String p_println_1_)
|
||||
{
|
||||
this.logString(p_println_1_);
|
||||
}
|
||||
|
||||
public void println(Object p_println_1_)
|
||||
{
|
||||
this.logString(String.valueOf(p_println_1_));
|
||||
}
|
||||
|
||||
protected void logString(String string)
|
||||
{
|
||||
LOGGER.info("[{}]: {}", this.domain, string);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class LowerStringMap<V> implements Map<String, V>
|
||||
{
|
||||
private final Map<String, V> internalMap = Maps.<String, V>newLinkedHashMap();
|
||||
|
||||
public int size()
|
||||
{
|
||||
return this.internalMap.size();
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return this.internalMap.isEmpty();
|
||||
}
|
||||
|
||||
public boolean containsKey(Object p_containsKey_1_)
|
||||
{
|
||||
return this.internalMap.containsKey(p_containsKey_1_.toString().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
public boolean containsValue(Object p_containsValue_1_)
|
||||
{
|
||||
return this.internalMap.containsKey(p_containsValue_1_);
|
||||
}
|
||||
|
||||
public V get(Object p_get_1_)
|
||||
{
|
||||
return this.internalMap.get(p_get_1_.toString().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
public V put(String p_put_1_, V p_put_2_)
|
||||
{
|
||||
return this.internalMap.put(p_put_1_.toLowerCase(Locale.ROOT), p_put_2_);
|
||||
}
|
||||
|
||||
public V remove(Object p_remove_1_)
|
||||
{
|
||||
return this.internalMap.remove(p_remove_1_.toString().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
public void putAll(Map <? extends String, ? extends V > p_putAll_1_)
|
||||
{
|
||||
for (Entry <? extends String, ? extends V > entry : p_putAll_1_.entrySet())
|
||||
{
|
||||
this.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
this.internalMap.clear();
|
||||
}
|
||||
|
||||
public Set<String> keySet()
|
||||
{
|
||||
return this.internalMap.keySet();
|
||||
}
|
||||
|
||||
public Collection<V> values()
|
||||
{
|
||||
return this.internalMap.values();
|
||||
}
|
||||
|
||||
public Set<Entry<String, V>> entrySet()
|
||||
{
|
||||
return this.internalMap.entrySet();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public class MapPopulator
|
||||
{
|
||||
/**
|
||||
* Create a Map from the given keys and values. This method creates a LinkedHashMap.
|
||||
*/
|
||||
public static <K, V> Map<K, V> createMap(Iterable<K> keys, Iterable<V> values)
|
||||
{
|
||||
return populateMap(keys, values, Maps.newLinkedHashMap());
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the given Map with the given keys and values.
|
||||
*/
|
||||
public static <K, V> Map<K, V> populateMap(Iterable<K> keys, Iterable<V> values, Map<K, V> map)
|
||||
{
|
||||
Iterator<V> iterator = values.iterator();
|
||||
|
||||
for (K k : keys)
|
||||
{
|
||||
map.put(k, iterator.next());
|
||||
}
|
||||
|
||||
if (iterator.hasNext())
|
||||
{
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
else
|
||||
{
|
||||
return map;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class MinecraftError extends Error
|
||||
{
|
||||
}
|
||||
99
build/tmp/recompileMc/sources/net/minecraft/util/Mirror.java
Normal file
99
build/tmp/recompileMc/sources/net/minecraft/util/Mirror.java
Normal file
@@ -0,0 +1,99 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
public enum Mirror
|
||||
{
|
||||
NONE("no_mirror"),
|
||||
LEFT_RIGHT("mirror_left_right"),
|
||||
FRONT_BACK("mirror_front_back");
|
||||
|
||||
private final String name;
|
||||
private static final String[] mirrorNames = new String[values().length];
|
||||
|
||||
private Mirror(String nameIn)
|
||||
{
|
||||
this.name = nameIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirrors the given rotation like specified by this mirror. rotations start at 0 and go up to rotationCount-1. 0 is
|
||||
* front, rotationCount/2 is back.
|
||||
*/
|
||||
public int mirrorRotation(int rotationIn, int rotationCount)
|
||||
{
|
||||
int i = rotationCount / 2;
|
||||
int j = rotationIn > i ? rotationIn - rotationCount : rotationIn;
|
||||
|
||||
switch (this)
|
||||
{
|
||||
case FRONT_BACK:
|
||||
return (rotationCount - j) % rotationCount;
|
||||
case LEFT_RIGHT:
|
||||
return (i - j + rotationCount) % rotationCount;
|
||||
default:
|
||||
return rotationIn;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the rotation that is equivalent to this mirror if the rotating object faces in the given direction
|
||||
*/
|
||||
public Rotation toRotation(EnumFacing facing)
|
||||
{
|
||||
EnumFacing.Axis enumfacing$axis = facing.getAxis();
|
||||
return (this != LEFT_RIGHT || enumfacing$axis != EnumFacing.Axis.Z) && (this != FRONT_BACK || enumfacing$axis != EnumFacing.Axis.X) ? Rotation.NONE : Rotation.CLOCKWISE_180;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirror the given facing according to this mirror
|
||||
*/
|
||||
public EnumFacing mirror(EnumFacing facing)
|
||||
{
|
||||
switch (this)
|
||||
{
|
||||
case FRONT_BACK:
|
||||
|
||||
if (facing == EnumFacing.WEST)
|
||||
{
|
||||
return EnumFacing.EAST;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (facing == EnumFacing.EAST)
|
||||
{
|
||||
return EnumFacing.WEST;
|
||||
}
|
||||
|
||||
return facing;
|
||||
}
|
||||
|
||||
case LEFT_RIGHT:
|
||||
|
||||
if (facing == EnumFacing.NORTH)
|
||||
{
|
||||
return EnumFacing.SOUTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (facing == EnumFacing.SOUTH)
|
||||
{
|
||||
return EnumFacing.NORTH;
|
||||
}
|
||||
|
||||
return facing;
|
||||
}
|
||||
|
||||
default:
|
||||
return facing;
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (Mirror mirror : values())
|
||||
{
|
||||
mirrorNames[i++] = mirror.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class MouseFilter
|
||||
{
|
||||
private float targetValue;
|
||||
private float remainingValue;
|
||||
private float lastAmount;
|
||||
|
||||
/**
|
||||
* Smooths mouse input
|
||||
*/
|
||||
public float smooth(float p_76333_1_, float p_76333_2_)
|
||||
{
|
||||
this.targetValue += p_76333_1_;
|
||||
p_76333_1_ = (this.targetValue - this.remainingValue) * p_76333_2_;
|
||||
this.lastAmount += (p_76333_1_ - this.lastAmount) * 0.5F;
|
||||
|
||||
if (p_76333_1_ > 0.0F && p_76333_1_ > this.lastAmount || p_76333_1_ < 0.0F && p_76333_1_ < this.lastAmount)
|
||||
{
|
||||
p_76333_1_ = this.lastAmount;
|
||||
}
|
||||
|
||||
this.remainingValue += p_76333_1_;
|
||||
return p_76333_1_;
|
||||
}
|
||||
|
||||
public void reset()
|
||||
{
|
||||
this.targetValue = 0.0F;
|
||||
this.remainingValue = 0.0F;
|
||||
this.lastAmount = 0.0F;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.Display;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class MouseHelper
|
||||
{
|
||||
/** Mouse delta X this frame */
|
||||
public int deltaX;
|
||||
/** Mouse delta Y this frame */
|
||||
public int deltaY;
|
||||
|
||||
/**
|
||||
* Grabs the mouse cursor it doesn't move and isn't seen.
|
||||
*/
|
||||
public void grabMouseCursor()
|
||||
{
|
||||
if (Boolean.parseBoolean(System.getProperty("fml.noGrab","false"))) return;
|
||||
Mouse.setGrabbed(true);
|
||||
this.deltaX = 0;
|
||||
this.deltaY = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ungrabs the mouse cursor so it can be moved and set it to the center of the screen
|
||||
*/
|
||||
public void ungrabMouseCursor()
|
||||
{
|
||||
Mouse.setCursorPosition(Display.getWidth() / 2, Display.getHeight() / 2);
|
||||
Mouse.setGrabbed(false);
|
||||
}
|
||||
|
||||
public void mouseXYChange()
|
||||
{
|
||||
this.deltaX = Mouse.getDX();
|
||||
this.deltaY = Mouse.getDY();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import net.minecraft.util.math.Vec2f;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class MovementInput
|
||||
{
|
||||
/** The speed at which the player is strafing. Postive numbers to the left and negative to the right. */
|
||||
public float moveStrafe;
|
||||
public float moveForward;
|
||||
public boolean forwardKeyDown;
|
||||
public boolean backKeyDown;
|
||||
public boolean leftKeyDown;
|
||||
public boolean rightKeyDown;
|
||||
public boolean jump;
|
||||
public boolean sneak;
|
||||
|
||||
public void updatePlayerMoveState()
|
||||
{
|
||||
}
|
||||
|
||||
public Vec2f getMoveVector()
|
||||
{
|
||||
return new Vec2f(this.moveStrafe, this.moveForward);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class MovementInputFromOptions extends MovementInput
|
||||
{
|
||||
private final GameSettings gameSettings;
|
||||
|
||||
public MovementInputFromOptions(GameSettings gameSettingsIn)
|
||||
{
|
||||
this.gameSettings = gameSettingsIn;
|
||||
}
|
||||
|
||||
public void updatePlayerMoveState()
|
||||
{
|
||||
this.moveStrafe = 0.0F;
|
||||
this.moveForward = 0.0F;
|
||||
|
||||
if (this.gameSettings.keyBindForward.isKeyDown())
|
||||
{
|
||||
++this.moveForward;
|
||||
this.forwardKeyDown = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.forwardKeyDown = false;
|
||||
}
|
||||
|
||||
if (this.gameSettings.keyBindBack.isKeyDown())
|
||||
{
|
||||
--this.moveForward;
|
||||
this.backKeyDown = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.backKeyDown = false;
|
||||
}
|
||||
|
||||
if (this.gameSettings.keyBindLeft.isKeyDown())
|
||||
{
|
||||
++this.moveStrafe;
|
||||
this.leftKeyDown = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.leftKeyDown = false;
|
||||
}
|
||||
|
||||
if (this.gameSettings.keyBindRight.isKeyDown())
|
||||
{
|
||||
--this.moveStrafe;
|
||||
this.rightKeyDown = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.rightKeyDown = false;
|
||||
}
|
||||
|
||||
this.jump = this.gameSettings.keyBindJump.isKeyDown();
|
||||
this.sneak = this.gameSettings.keyBindSneak.isKeyDown();
|
||||
|
||||
if (this.sneak)
|
||||
{
|
||||
this.moveStrafe = (float)((double)this.moveStrafe * 0.3D);
|
||||
this.moveForward = (float)((double)this.moveForward * 0.3D);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import java.util.AbstractList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
public class NonNullList<E> extends AbstractList<E>
|
||||
{
|
||||
private final List<E> delegate;
|
||||
private final E defaultElement;
|
||||
|
||||
public static <E> NonNullList<E> create()
|
||||
{
|
||||
return new NonNullList<E>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new NonNullList with <i>fixed</i> size, and filled with the object passed.
|
||||
*/
|
||||
public static <E> NonNullList<E> withSize(int size, E fill)
|
||||
{
|
||||
Validate.notNull(fill);
|
||||
Object[] aobject = new Object[size];
|
||||
Arrays.fill(aobject, fill);
|
||||
return new NonNullList<E>(Arrays.asList((E[])aobject), fill);
|
||||
}
|
||||
|
||||
public static <E> NonNullList<E> from(E defaultElementIn, E... elements)
|
||||
{
|
||||
return new NonNullList<E>(Arrays.asList(elements), defaultElementIn);
|
||||
}
|
||||
|
||||
protected NonNullList()
|
||||
{
|
||||
this(new ArrayList(), null);
|
||||
}
|
||||
|
||||
protected NonNullList(List<E> delegateIn, @Nullable E listType)
|
||||
{
|
||||
this.delegate = delegateIn;
|
||||
this.defaultElement = listType;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public E get(int p_get_1_)
|
||||
{
|
||||
return this.delegate.get(p_get_1_);
|
||||
}
|
||||
|
||||
public E set(int p_set_1_, E p_set_2_)
|
||||
{
|
||||
Validate.notNull(p_set_2_);
|
||||
return this.delegate.set(p_set_1_, p_set_2_);
|
||||
}
|
||||
|
||||
public void add(int p_add_1_, E p_add_2_)
|
||||
{
|
||||
Validate.notNull(p_add_2_);
|
||||
this.delegate.add(p_add_1_, p_add_2_);
|
||||
}
|
||||
|
||||
public E remove(int p_remove_1_)
|
||||
{
|
||||
return this.delegate.remove(p_remove_1_);
|
||||
}
|
||||
|
||||
public int size()
|
||||
{
|
||||
return this.delegate.size();
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
if (this.defaultElement == null)
|
||||
{
|
||||
super.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < this.size(); ++i)
|
||||
{
|
||||
this.set(i, this.defaultElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ObjectIntIdentityMap<T> implements IObjectIntIterable<T>
|
||||
{
|
||||
protected final IdentityHashMap<T, Integer> identityMap;
|
||||
protected final List<T> objectList;
|
||||
|
||||
public ObjectIntIdentityMap()
|
||||
{
|
||||
this(512);
|
||||
}
|
||||
|
||||
public ObjectIntIdentityMap(int expectedSize)
|
||||
{
|
||||
this.objectList = Lists.<T>newArrayListWithExpectedSize(expectedSize);
|
||||
this.identityMap = new IdentityHashMap<T, Integer>(expectedSize);
|
||||
}
|
||||
|
||||
public void put(T key, int value)
|
||||
{
|
||||
this.identityMap.put(key, Integer.valueOf(value));
|
||||
|
||||
while (this.objectList.size() <= value)
|
||||
{
|
||||
this.objectList.add(null);
|
||||
}
|
||||
|
||||
this.objectList.set(value, key);
|
||||
}
|
||||
|
||||
public int get(T key)
|
||||
{
|
||||
Integer integer = this.identityMap.get(key);
|
||||
return integer == null ? -1 : integer.intValue();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public final T getByValue(int value)
|
||||
{
|
||||
return (T)(value >= 0 && value < this.objectList.size() ? this.objectList.get(value) : null);
|
||||
}
|
||||
|
||||
public Iterator<T> iterator()
|
||||
{
|
||||
return Iterators.filter(this.objectList.iterator(), Predicates.notNull());
|
||||
}
|
||||
|
||||
public int size()
|
||||
{
|
||||
return this.identityMap.size();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import net.minecraft.crash.CrashReport;
|
||||
|
||||
public class ReportedException extends RuntimeException
|
||||
{
|
||||
/** The crash report associated with this exception */
|
||||
private final CrashReport crashReport;
|
||||
|
||||
public ReportedException(CrashReport report)
|
||||
{
|
||||
this.crashReport = report;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the CrashReport wrapped by this exception.
|
||||
*/
|
||||
public CrashReport getCrashReport()
|
||||
{
|
||||
return this.crashReport;
|
||||
}
|
||||
|
||||
public Throwable getCause()
|
||||
{
|
||||
return this.crashReport.getCrashCause();
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return this.crashReport.getDescription();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Locale;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
public class ResourceLocation implements Comparable<ResourceLocation>
|
||||
{
|
||||
protected final String resourceDomain;
|
||||
protected final String resourcePath;
|
||||
|
||||
protected ResourceLocation(int unused, String... resourceName)
|
||||
{
|
||||
this.resourceDomain = org.apache.commons.lang3.StringUtils.isEmpty(resourceName[0]) ? "minecraft" : resourceName[0].toLowerCase(Locale.ROOT);
|
||||
this.resourcePath = resourceName[1].toLowerCase(Locale.ROOT);
|
||||
Validate.notNull(this.resourcePath);
|
||||
}
|
||||
|
||||
public ResourceLocation(String resourceName)
|
||||
{
|
||||
this(0, splitObjectName(resourceName));
|
||||
}
|
||||
|
||||
public ResourceLocation(String resourceDomainIn, String resourcePathIn)
|
||||
{
|
||||
this(0, resourceDomainIn, resourcePathIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits an object name (such as minecraft:apple) into the domain and path parts and returns these as an array of
|
||||
* length 2. If no colon is present in the passed value the returned array will contain {null, toSplit}.
|
||||
*/
|
||||
public static String[] splitObjectName(String toSplit)
|
||||
{
|
||||
String[] astring = new String[] {"minecraft", toSplit};
|
||||
int i = toSplit.indexOf(58);
|
||||
|
||||
if (i >= 0)
|
||||
{
|
||||
astring[1] = toSplit.substring(i + 1, toSplit.length());
|
||||
|
||||
if (i > 1)
|
||||
{
|
||||
astring[0] = toSplit.substring(0, i);
|
||||
}
|
||||
}
|
||||
|
||||
return astring;
|
||||
}
|
||||
|
||||
public String getResourcePath()
|
||||
{
|
||||
return this.resourcePath;
|
||||
}
|
||||
|
||||
public String getResourceDomain()
|
||||
{
|
||||
return this.resourceDomain;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return this.resourceDomain + ':' + this.resourcePath;
|
||||
}
|
||||
|
||||
public boolean equals(Object p_equals_1_)
|
||||
{
|
||||
if (this == p_equals_1_)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (!(p_equals_1_ instanceof ResourceLocation))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ResourceLocation resourcelocation = (ResourceLocation)p_equals_1_;
|
||||
return this.resourceDomain.equals(resourcelocation.resourceDomain) && this.resourcePath.equals(resourcelocation.resourcePath);
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return 31 * this.resourceDomain.hashCode() + this.resourcePath.hashCode();
|
||||
}
|
||||
|
||||
public int compareTo(ResourceLocation p_compareTo_1_)
|
||||
{
|
||||
int i = this.resourceDomain.compareTo(p_compareTo_1_.resourceDomain);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
i = this.resourcePath.compareTo(p_compareTo_1_.resourcePath);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public static class Serializer implements JsonDeserializer<ResourceLocation>, JsonSerializer<ResourceLocation>
|
||||
{
|
||||
public ResourceLocation deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
|
||||
{
|
||||
return new ResourceLocation(JsonUtils.getString(p_deserialize_1_, "location"));
|
||||
}
|
||||
|
||||
public JsonElement serialize(ResourceLocation p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
|
||||
{
|
||||
return new JsonPrimitive(p_serialize_1_.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
115
build/tmp/recompileMc/sources/net/minecraft/util/Rotation.java
Normal file
115
build/tmp/recompileMc/sources/net/minecraft/util/Rotation.java
Normal file
@@ -0,0 +1,115 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
public enum Rotation
|
||||
{
|
||||
NONE("rotate_0"),
|
||||
CLOCKWISE_90("rotate_90"),
|
||||
CLOCKWISE_180("rotate_180"),
|
||||
COUNTERCLOCKWISE_90("rotate_270");
|
||||
|
||||
private final String name;
|
||||
private static final String[] rotationNames = new String[values().length];
|
||||
|
||||
private Rotation(String nameIn)
|
||||
{
|
||||
this.name = nameIn;
|
||||
}
|
||||
|
||||
public Rotation add(Rotation rotation)
|
||||
{
|
||||
switch (rotation)
|
||||
{
|
||||
case CLOCKWISE_180:
|
||||
|
||||
switch (this)
|
||||
{
|
||||
case NONE:
|
||||
return CLOCKWISE_180;
|
||||
case CLOCKWISE_90:
|
||||
return COUNTERCLOCKWISE_90;
|
||||
case CLOCKWISE_180:
|
||||
return NONE;
|
||||
case COUNTERCLOCKWISE_90:
|
||||
return CLOCKWISE_90;
|
||||
}
|
||||
|
||||
case COUNTERCLOCKWISE_90:
|
||||
|
||||
switch (this)
|
||||
{
|
||||
case NONE:
|
||||
return COUNTERCLOCKWISE_90;
|
||||
case CLOCKWISE_90:
|
||||
return NONE;
|
||||
case CLOCKWISE_180:
|
||||
return CLOCKWISE_90;
|
||||
case COUNTERCLOCKWISE_90:
|
||||
return CLOCKWISE_180;
|
||||
}
|
||||
|
||||
case CLOCKWISE_90:
|
||||
|
||||
switch (this)
|
||||
{
|
||||
case NONE:
|
||||
return CLOCKWISE_90;
|
||||
case CLOCKWISE_90:
|
||||
return CLOCKWISE_180;
|
||||
case CLOCKWISE_180:
|
||||
return COUNTERCLOCKWISE_90;
|
||||
case COUNTERCLOCKWISE_90:
|
||||
return NONE;
|
||||
}
|
||||
|
||||
default:
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public EnumFacing rotate(EnumFacing facing)
|
||||
{
|
||||
if (facing.getAxis() == EnumFacing.Axis.Y)
|
||||
{
|
||||
return facing;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (this)
|
||||
{
|
||||
case CLOCKWISE_90:
|
||||
return facing.rotateY();
|
||||
case CLOCKWISE_180:
|
||||
return facing.getOpposite();
|
||||
case COUNTERCLOCKWISE_90:
|
||||
return facing.rotateYCCW();
|
||||
default:
|
||||
return facing;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int rotate(int p_185833_1_, int p_185833_2_)
|
||||
{
|
||||
switch (this)
|
||||
{
|
||||
case CLOCKWISE_90:
|
||||
return (p_185833_1_ + p_185833_2_ / 4) % p_185833_2_;
|
||||
case CLOCKWISE_180:
|
||||
return (p_185833_1_ + p_185833_2_ / 2) % p_185833_2_;
|
||||
case COUNTERCLOCKWISE_90:
|
||||
return (p_185833_1_ + p_185833_2_ * 3 / 4) % p_185833_2_;
|
||||
default:
|
||||
return p_185833_1_;
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (Rotation rotation : values())
|
||||
{
|
||||
rotationNames[i++] = rotation.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.nio.IntBuffer;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.imageio.ImageIO;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.client.shader.Framebuffer;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.BufferUtils;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ScreenShotHelper
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss");
|
||||
/** A buffer to hold pixel values returned by OpenGL. */
|
||||
private static IntBuffer pixelBuffer;
|
||||
/** The built-up array that contains all the pixel values returned by OpenGL. */
|
||||
private static int[] pixelValues;
|
||||
|
||||
/**
|
||||
* Saves a screenshot in the game directory with a time-stamped filename.
|
||||
* Returns an ITextComponent indicating the success/failure of the saving.
|
||||
*/
|
||||
public static ITextComponent saveScreenshot(File gameDirectory, int width, int height, Framebuffer buffer)
|
||||
{
|
||||
return saveScreenshot(gameDirectory, (String)null, width, height, buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a screenshot in the game directory with the given file name (or null to generate a time-stamped name).
|
||||
* Returns an ITextComponent indicating the success/failure of the saving.
|
||||
*/
|
||||
public static ITextComponent saveScreenshot(File gameDirectory, @Nullable String screenshotName, int width, int height, Framebuffer buffer)
|
||||
{
|
||||
try
|
||||
{
|
||||
File file1 = new File(gameDirectory, "screenshots");
|
||||
file1.mkdir();
|
||||
BufferedImage bufferedimage = createScreenshot(width, height, buffer);
|
||||
File file2;
|
||||
|
||||
if (screenshotName == null)
|
||||
{
|
||||
file2 = getTimestampedPNGFileForDirectory(file1);
|
||||
}
|
||||
else
|
||||
{
|
||||
file2 = new File(file1, screenshotName);
|
||||
}
|
||||
|
||||
file2 = file2.getCanonicalFile(); // FORGE: Fix errors on Windows with paths that include \.\
|
||||
net.minecraftforge.client.event.ScreenshotEvent event = net.minecraftforge.client.ForgeHooksClient.onScreenshot(bufferedimage, file2);
|
||||
if (event.isCanceled()) return event.getCancelMessage(); else file2 = event.getScreenshotFile();
|
||||
ImageIO.write(bufferedimage, "png", file2);
|
||||
ITextComponent itextcomponent = new TextComponentString(file2.getName());
|
||||
itextcomponent.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, file2.getAbsolutePath()));
|
||||
itextcomponent.getStyle().setUnderlined(Boolean.valueOf(true));
|
||||
if (event.getResultMessage() != null) return event.getResultMessage();
|
||||
return new TextComponentTranslation("screenshot.success", new Object[] {itextcomponent});
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LOGGER.warn("Couldn't save screenshot", (Throwable)exception);
|
||||
return new TextComponentTranslation("screenshot.failure", new Object[] {exception.getMessage()});
|
||||
}
|
||||
}
|
||||
|
||||
public static BufferedImage createScreenshot(int width, int height, Framebuffer framebufferIn)
|
||||
{
|
||||
if (OpenGlHelper.isFramebufferEnabled())
|
||||
{
|
||||
width = framebufferIn.framebufferTextureWidth;
|
||||
height = framebufferIn.framebufferTextureHeight;
|
||||
}
|
||||
|
||||
int i = width * height;
|
||||
|
||||
if (pixelBuffer == null || pixelBuffer.capacity() < i)
|
||||
{
|
||||
pixelBuffer = BufferUtils.createIntBuffer(i);
|
||||
pixelValues = new int[i];
|
||||
}
|
||||
|
||||
GlStateManager.glPixelStorei(3333, 1);
|
||||
GlStateManager.glPixelStorei(3317, 1);
|
||||
pixelBuffer.clear();
|
||||
|
||||
if (OpenGlHelper.isFramebufferEnabled())
|
||||
{
|
||||
GlStateManager.bindTexture(framebufferIn.framebufferTexture);
|
||||
GlStateManager.glGetTexImage(3553, 0, 32993, 33639, pixelBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
GlStateManager.glReadPixels(0, 0, width, height, 32993, 33639, pixelBuffer);
|
||||
}
|
||||
|
||||
pixelBuffer.get(pixelValues);
|
||||
TextureUtil.processPixelValues(pixelValues, width, height);
|
||||
BufferedImage bufferedimage = new BufferedImage(width, height, 1);
|
||||
bufferedimage.setRGB(0, 0, width, height, pixelValues, 0, width);
|
||||
return bufferedimage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a unique PNG file in the given directory named by a timestamp. Handles cases where the timestamp alone
|
||||
* is not enough to create a uniquely named file, though it still might suffer from an unlikely race condition where
|
||||
* the filename was unique when this method was called, but another process or thread created a file at the same
|
||||
* path immediately after this method returned.
|
||||
*/
|
||||
private static File getTimestampedPNGFileForDirectory(File gameDirectory)
|
||||
{
|
||||
String s = DATE_FORMAT.format(new Date()).toString();
|
||||
int i = 1;
|
||||
|
||||
while (true)
|
||||
{
|
||||
File file1 = new File(gameDirectory, s + (i == 1 ? "" : "_" + i) + ".png");
|
||||
|
||||
if (!file1.exists())
|
||||
{
|
||||
return file1;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,312 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import it.unimi.dsi.fastutil.ints.IntListIterator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.util.RecipeItemHelper;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ContainerPlayer;
|
||||
import net.minecraft.inventory.ContainerWorkbench;
|
||||
import net.minecraft.inventory.InventoryCraftResult;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraft.network.play.server.SPacketPlaceGhostRecipe;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class ServerRecipeBookHelper
|
||||
{
|
||||
private final Logger field_194330_a = LogManager.getLogger();
|
||||
private final RecipeItemHelper field_194331_b = new RecipeItemHelper();
|
||||
private EntityPlayerMP field_194332_c;
|
||||
private IRecipe field_194333_d;
|
||||
private boolean field_194334_e;
|
||||
private InventoryCraftResult field_194335_f;
|
||||
private InventoryCrafting field_194336_g;
|
||||
private List<Slot> field_194337_h;
|
||||
|
||||
public void func_194327_a(EntityPlayerMP p_194327_1_, @Nullable IRecipe p_194327_2_, boolean p_194327_3_)
|
||||
{
|
||||
if (p_194327_2_ != null && p_194327_1_.getRecipeBook().isUnlocked(p_194327_2_))
|
||||
{
|
||||
this.field_194332_c = p_194327_1_;
|
||||
this.field_194333_d = p_194327_2_;
|
||||
this.field_194334_e = p_194327_3_;
|
||||
this.field_194337_h = p_194327_1_.openContainer.inventorySlots;
|
||||
Container container = p_194327_1_.openContainer;
|
||||
this.field_194335_f = null;
|
||||
this.field_194336_g = null;
|
||||
|
||||
if (container instanceof ContainerWorkbench)
|
||||
{
|
||||
this.field_194335_f = ((ContainerWorkbench)container).craftResult;
|
||||
this.field_194336_g = ((ContainerWorkbench)container).craftMatrix;
|
||||
}
|
||||
else if (container instanceof ContainerPlayer)
|
||||
{
|
||||
this.field_194335_f = ((ContainerPlayer)container).craftResult;
|
||||
this.field_194336_g = ((ContainerPlayer)container).craftMatrix;
|
||||
}
|
||||
else if (container instanceof net.minecraftforge.common.crafting.IRecipeContainer)
|
||||
{
|
||||
this.field_194335_f = ((net.minecraftforge.common.crafting.IRecipeContainer)container).getCraftResult();
|
||||
this.field_194336_g = ((net.minecraftforge.common.crafting.IRecipeContainer)container).getCraftMatrix();
|
||||
}
|
||||
|
||||
if (this.field_194335_f != null && this.field_194336_g != null)
|
||||
{
|
||||
if (this.func_194328_c() || p_194327_1_.isCreative())
|
||||
{
|
||||
this.field_194331_b.clear();
|
||||
p_194327_1_.inventory.fillStackedContents(this.field_194331_b, false);
|
||||
this.field_194336_g.fillStackedContents(this.field_194331_b);
|
||||
|
||||
if (this.field_194331_b.canCraft(p_194327_2_, (IntList)null))
|
||||
{
|
||||
this.func_194329_b();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.func_194326_a();
|
||||
p_194327_1_.connection.sendPacket(new SPacketPlaceGhostRecipe(p_194327_1_.openContainer.windowId, p_194327_2_));
|
||||
}
|
||||
|
||||
p_194327_1_.inventory.markDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void func_194326_a()
|
||||
{
|
||||
InventoryPlayer inventoryplayer = this.field_194332_c.inventory;
|
||||
|
||||
for (int i = 0; i < this.field_194336_g.getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack itemstack = this.field_194336_g.getStackInSlot(i);
|
||||
|
||||
if (!itemstack.isEmpty())
|
||||
{
|
||||
while (itemstack.getCount() > 0)
|
||||
{
|
||||
int j = inventoryplayer.storeItemStack(itemstack);
|
||||
|
||||
if (j == -1)
|
||||
{
|
||||
j = inventoryplayer.getFirstEmptyStack();
|
||||
}
|
||||
|
||||
ItemStack itemstack1 = itemstack.copy();
|
||||
itemstack1.setCount(1);
|
||||
inventoryplayer.add(j, itemstack1);
|
||||
this.field_194336_g.decrStackSize(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.field_194336_g.clear();
|
||||
this.field_194335_f.clear();
|
||||
}
|
||||
|
||||
private void func_194329_b()
|
||||
{
|
||||
boolean flag = this.field_194333_d.matches(this.field_194336_g, this.field_194332_c.world);
|
||||
int i = this.field_194331_b.getBiggestCraftableStack(this.field_194333_d, (IntList)null);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
boolean flag1 = true;
|
||||
|
||||
for (int j = 0; j < this.field_194336_g.getSizeInventory(); ++j)
|
||||
{
|
||||
ItemStack itemstack = this.field_194336_g.getStackInSlot(j);
|
||||
|
||||
if (!itemstack.isEmpty() && Math.min(i, itemstack.getMaxStackSize()) > itemstack.getCount())
|
||||
{
|
||||
flag1 = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int i1 = this.func_194324_a(i, flag);
|
||||
IntList intlist = new IntArrayList();
|
||||
|
||||
if (this.field_194331_b.canCraft(this.field_194333_d, intlist, i1))
|
||||
{
|
||||
int j1 = i1;
|
||||
IntListIterator intlistiterator = intlist.iterator();
|
||||
|
||||
while (intlistiterator.hasNext())
|
||||
{
|
||||
int k = ((Integer)intlistiterator.next()).intValue();
|
||||
int l = RecipeItemHelper.unpack(k).getMaxStackSize();
|
||||
|
||||
if (l < j1)
|
||||
{
|
||||
j1 = l;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.field_194331_b.canCraft(this.field_194333_d, intlist, j1))
|
||||
{
|
||||
this.func_194326_a();
|
||||
this.func_194323_a(j1, intlist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int func_194324_a(int p_194324_1_, boolean p_194324_2_)
|
||||
{
|
||||
int i = 1;
|
||||
|
||||
if (this.field_194334_e)
|
||||
{
|
||||
i = p_194324_1_;
|
||||
}
|
||||
else if (p_194324_2_)
|
||||
{
|
||||
i = 64;
|
||||
|
||||
for (int j = 0; j < this.field_194336_g.getSizeInventory(); ++j)
|
||||
{
|
||||
ItemStack itemstack = this.field_194336_g.getStackInSlot(j);
|
||||
|
||||
if (!itemstack.isEmpty() && i > itemstack.getCount())
|
||||
{
|
||||
i = itemstack.getCount();
|
||||
}
|
||||
}
|
||||
|
||||
if (i < 64)
|
||||
{
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
private void func_194323_a(int p_194323_1_, IntList p_194323_2_)
|
||||
{
|
||||
int i = this.field_194336_g.getWidth();
|
||||
int j = this.field_194336_g.getHeight();
|
||||
|
||||
if (this.field_194333_d instanceof net.minecraftforge.common.crafting.IShapedRecipe)
|
||||
{
|
||||
net.minecraftforge.common.crafting.IShapedRecipe shapedrecipes = (net.minecraftforge.common.crafting.IShapedRecipe)this.field_194333_d;
|
||||
i = shapedrecipes.getRecipeWidth();
|
||||
j = shapedrecipes.getRecipeHeight();
|
||||
}
|
||||
|
||||
int j1 = 1;
|
||||
Iterator<Integer> iterator = p_194323_2_.iterator();
|
||||
|
||||
for (int k = 0; k < this.field_194336_g.getWidth() && j != k; ++k)
|
||||
{
|
||||
for (int l = 0; l < this.field_194336_g.getHeight(); ++l)
|
||||
{
|
||||
if (i == l || !iterator.hasNext())
|
||||
{
|
||||
j1 += this.field_194336_g.getWidth() - l;
|
||||
break;
|
||||
}
|
||||
|
||||
Slot slot = this.field_194337_h.get(j1);
|
||||
ItemStack itemstack = RecipeItemHelper.unpack(((Integer)iterator.next()).intValue());
|
||||
|
||||
if (itemstack.isEmpty())
|
||||
{
|
||||
++j1;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i1 = 0; i1 < p_194323_1_; ++i1)
|
||||
{
|
||||
this.func_194325_a(slot, itemstack);
|
||||
}
|
||||
|
||||
++j1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!iterator.hasNext())
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void func_194325_a(Slot p_194325_1_, ItemStack p_194325_2_)
|
||||
{
|
||||
InventoryPlayer inventoryplayer = this.field_194332_c.inventory;
|
||||
int i = inventoryplayer.findSlotMatchingUnusedItem(p_194325_2_);
|
||||
|
||||
if (i != -1)
|
||||
{
|
||||
ItemStack itemstack = inventoryplayer.getStackInSlot(i).copy();
|
||||
|
||||
if (!itemstack.isEmpty())
|
||||
{
|
||||
if (itemstack.getCount() > 1)
|
||||
{
|
||||
inventoryplayer.decrStackSize(i, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
inventoryplayer.removeStackFromSlot(i);
|
||||
}
|
||||
|
||||
itemstack.setCount(1);
|
||||
|
||||
if (p_194325_1_.getStack().isEmpty())
|
||||
{
|
||||
p_194325_1_.putStack(itemstack);
|
||||
}
|
||||
else
|
||||
{
|
||||
p_194325_1_.getStack().grow(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean func_194328_c()
|
||||
{
|
||||
InventoryPlayer inventoryplayer = this.field_194332_c.inventory;
|
||||
|
||||
for (int i = 0; i < this.field_194336_g.getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack itemstack = this.field_194336_g.getStackInSlot(i);
|
||||
|
||||
if (!itemstack.isEmpty())
|
||||
{
|
||||
int j = inventoryplayer.storeItemStack(itemstack);
|
||||
|
||||
if (j == -1)
|
||||
{
|
||||
j = inventoryplayer.getFirstEmptyStack();
|
||||
}
|
||||
|
||||
if (j == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
121
build/tmp/recompileMc/sources/net/minecraft/util/Session.java
Normal file
121
build/tmp/recompileMc/sources/net/minecraft/util/Session.java
Normal file
@@ -0,0 +1,121 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.util.UUIDTypeAdapter;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class Session
|
||||
{
|
||||
private final String username;
|
||||
private final String playerID;
|
||||
private final String token;
|
||||
private final Session.Type sessionType;
|
||||
/** Forge: Cache of the local session's GameProfile properties. */
|
||||
private com.mojang.authlib.properties.PropertyMap properties;
|
||||
|
||||
public Session(String usernameIn, String playerIDIn, String tokenIn, String sessionTypeIn)
|
||||
{
|
||||
if (usernameIn == null || usernameIn.isEmpty())
|
||||
{
|
||||
usernameIn = "MissingName";
|
||||
playerIDIn = tokenIn = "NotValid";
|
||||
org.apache.logging.log4j.Logger logger = net.minecraftforge.fml.common.FMLLog.log;
|
||||
logger.log(org.apache.logging.log4j.Level.WARN, "=========================================================");
|
||||
logger.log(org.apache.logging.log4j.Level.WARN, "WARNING!! the username was not set for this session, typically");
|
||||
logger.log(org.apache.logging.log4j.Level.WARN, "this means you installed Forge incorrectly. We have set your");
|
||||
logger.log(org.apache.logging.log4j.Level.WARN, "name to \"MissingName\" and your session to nothing. Please");
|
||||
logger.log(org.apache.logging.log4j.Level.WARN, "check your installation and post a console log from the launcher");
|
||||
logger.log(org.apache.logging.log4j.Level.WARN, "when asking for help!");
|
||||
logger.log(org.apache.logging.log4j.Level.WARN, "=========================================================");
|
||||
}
|
||||
|
||||
this.username = usernameIn;
|
||||
this.playerID = playerIDIn;
|
||||
this.token = tokenIn;
|
||||
this.sessionType = Session.Type.setSessionType(sessionTypeIn);
|
||||
}
|
||||
|
||||
public String getSessionID()
|
||||
{
|
||||
return "token:" + this.token + ":" + this.playerID;
|
||||
}
|
||||
|
||||
public String getPlayerID()
|
||||
{
|
||||
return this.playerID;
|
||||
}
|
||||
|
||||
public String getUsername()
|
||||
{
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public String getToken()
|
||||
{
|
||||
return this.token;
|
||||
}
|
||||
|
||||
public GameProfile getProfile()
|
||||
{
|
||||
try
|
||||
{
|
||||
UUID uuid = UUIDTypeAdapter.fromString(this.getPlayerID());
|
||||
GameProfile ret = new GameProfile(uuid, this.getUsername()); //Forge: Adds cached GameProfile properties to returned GameProfile.
|
||||
if (properties != null) ret.getProperties().putAll(properties); // Helps to cut down on calls to the session service,
|
||||
return ret; // which helps to fix MC-52974.
|
||||
}
|
||||
catch (IllegalArgumentException var2)
|
||||
{
|
||||
return new GameProfile(net.minecraft.entity.player.EntityPlayer.getUUID(new GameProfile((UUID)null, this.getUsername())), this.getUsername());
|
||||
}
|
||||
}
|
||||
|
||||
/* ======================================== FORGE START ===================================== */
|
||||
//For internal use only. Modders should never need to use this.
|
||||
public void setProperties(com.mojang.authlib.properties.PropertyMap properties)
|
||||
{
|
||||
if(this.properties == null) this.properties = properties;
|
||||
}
|
||||
|
||||
public boolean hasCachedProperties()
|
||||
{
|
||||
return properties != null;
|
||||
}
|
||||
/* ========================================= FORGE END ====================================== */
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static enum Type
|
||||
{
|
||||
LEGACY("legacy"),
|
||||
MOJANG("mojang");
|
||||
|
||||
private static final Map<String, Session.Type> SESSION_TYPES = Maps.<String, Session.Type>newHashMap();
|
||||
private final String sessionType;
|
||||
|
||||
private Type(String sessionTypeIn)
|
||||
{
|
||||
this.sessionType = sessionTypeIn;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Session.Type setSessionType(String sessionTypeIn)
|
||||
{
|
||||
return SESSION_TYPES.get(sessionTypeIn.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
for (Session.Type session$type : values())
|
||||
{
|
||||
SESSION_TYPES.put(session$type.sessionType, session$type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public enum SoundCategory
|
||||
{
|
||||
MASTER("master"),
|
||||
MUSIC("music"),
|
||||
RECORDS("record"),
|
||||
WEATHER("weather"),
|
||||
BLOCKS("block"),
|
||||
HOSTILE("hostile"),
|
||||
NEUTRAL("neutral"),
|
||||
PLAYERS("player"),
|
||||
AMBIENT("ambient"),
|
||||
VOICE("voice");
|
||||
|
||||
private static final Map<String, SoundCategory> SOUND_CATEGORIES = Maps.<String, SoundCategory>newHashMap();
|
||||
private final String name;
|
||||
|
||||
private SoundCategory(String nameIn)
|
||||
{
|
||||
this.name = nameIn;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public static SoundCategory getByName(String categoryName)
|
||||
{
|
||||
return SOUND_CATEGORIES.get(categoryName);
|
||||
}
|
||||
|
||||
public static Set<String> getSoundCategoryNames()
|
||||
{
|
||||
return SOUND_CATEGORIES.keySet();
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
for (SoundCategory soundcategory : values())
|
||||
{
|
||||
if (SOUND_CATEGORIES.containsKey(soundcategory.getName()))
|
||||
{
|
||||
throw new Error("Clash in Sound Category name pools! Cannot insert " + soundcategory);
|
||||
}
|
||||
|
||||
SOUND_CATEGORIES.put(soundcategory.getName(), soundcategory);
|
||||
}
|
||||
}
|
||||
}
|
||||
582
build/tmp/recompileMc/sources/net/minecraft/util/SoundEvent.java
Normal file
582
build/tmp/recompileMc/sources/net/minecraft/util/SoundEvent.java
Normal file
@@ -0,0 +1,582 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import net.minecraft.util.registry.RegistryNamespaced;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SoundEvent extends net.minecraftforge.registries.IForgeRegistryEntry.Impl<SoundEvent>
|
||||
{
|
||||
public static final RegistryNamespaced<ResourceLocation, SoundEvent> REGISTRY = net.minecraftforge.registries.GameData.getWrapper(SoundEvent.class);
|
||||
private final ResourceLocation soundName;
|
||||
private static int soundEventId;
|
||||
|
||||
public SoundEvent(ResourceLocation soundNameIn)
|
||||
{
|
||||
this.soundName = soundNameIn;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ResourceLocation getSoundName()
|
||||
{
|
||||
return this.soundName;
|
||||
}
|
||||
|
||||
public static void registerSounds()
|
||||
{
|
||||
registerSound("ambient.cave");
|
||||
registerSound("block.anvil.break");
|
||||
registerSound("block.anvil.destroy");
|
||||
registerSound("block.anvil.fall");
|
||||
registerSound("block.anvil.hit");
|
||||
registerSound("block.anvil.land");
|
||||
registerSound("block.anvil.place");
|
||||
registerSound("block.anvil.step");
|
||||
registerSound("block.anvil.use");
|
||||
registerSound("block.brewing_stand.brew");
|
||||
registerSound("block.chest.close");
|
||||
registerSound("block.chest.locked");
|
||||
registerSound("block.chest.open");
|
||||
registerSound("block.chorus_flower.death");
|
||||
registerSound("block.chorus_flower.grow");
|
||||
registerSound("block.cloth.break");
|
||||
registerSound("block.cloth.fall");
|
||||
registerSound("block.cloth.hit");
|
||||
registerSound("block.cloth.place");
|
||||
registerSound("block.cloth.step");
|
||||
registerSound("block.comparator.click");
|
||||
registerSound("block.dispenser.dispense");
|
||||
registerSound("block.dispenser.fail");
|
||||
registerSound("block.dispenser.launch");
|
||||
registerSound("block.enchantment_table.use");
|
||||
registerSound("block.end_gateway.spawn");
|
||||
registerSound("block.end_portal.spawn");
|
||||
registerSound("block.end_portal_frame.fill");
|
||||
registerSound("block.enderchest.close");
|
||||
registerSound("block.enderchest.open");
|
||||
registerSound("block.fence_gate.close");
|
||||
registerSound("block.fence_gate.open");
|
||||
registerSound("block.fire.ambient");
|
||||
registerSound("block.fire.extinguish");
|
||||
registerSound("block.furnace.fire_crackle");
|
||||
registerSound("block.glass.break");
|
||||
registerSound("block.glass.fall");
|
||||
registerSound("block.glass.hit");
|
||||
registerSound("block.glass.place");
|
||||
registerSound("block.glass.step");
|
||||
registerSound("block.grass.break");
|
||||
registerSound("block.grass.fall");
|
||||
registerSound("block.grass.hit");
|
||||
registerSound("block.grass.place");
|
||||
registerSound("block.grass.step");
|
||||
registerSound("block.gravel.break");
|
||||
registerSound("block.gravel.fall");
|
||||
registerSound("block.gravel.hit");
|
||||
registerSound("block.gravel.place");
|
||||
registerSound("block.gravel.step");
|
||||
registerSound("block.iron_door.close");
|
||||
registerSound("block.iron_door.open");
|
||||
registerSound("block.iron_trapdoor.close");
|
||||
registerSound("block.iron_trapdoor.open");
|
||||
registerSound("block.ladder.break");
|
||||
registerSound("block.ladder.fall");
|
||||
registerSound("block.ladder.hit");
|
||||
registerSound("block.ladder.place");
|
||||
registerSound("block.ladder.step");
|
||||
registerSound("block.lava.ambient");
|
||||
registerSound("block.lava.extinguish");
|
||||
registerSound("block.lava.pop");
|
||||
registerSound("block.lever.click");
|
||||
registerSound("block.metal.break");
|
||||
registerSound("block.metal.fall");
|
||||
registerSound("block.metal.hit");
|
||||
registerSound("block.metal.place");
|
||||
registerSound("block.metal.step");
|
||||
registerSound("block.metal_pressureplate.click_off");
|
||||
registerSound("block.metal_pressureplate.click_on");
|
||||
registerSound("block.note.basedrum");
|
||||
registerSound("block.note.bass");
|
||||
registerSound("block.note.bell");
|
||||
registerSound("block.note.chime");
|
||||
registerSound("block.note.flute");
|
||||
registerSound("block.note.guitar");
|
||||
registerSound("block.note.harp");
|
||||
registerSound("block.note.hat");
|
||||
registerSound("block.note.pling");
|
||||
registerSound("block.note.snare");
|
||||
registerSound("block.note.xylophone");
|
||||
registerSound("block.piston.contract");
|
||||
registerSound("block.piston.extend");
|
||||
registerSound("block.portal.ambient");
|
||||
registerSound("block.portal.travel");
|
||||
registerSound("block.portal.trigger");
|
||||
registerSound("block.redstone_torch.burnout");
|
||||
registerSound("block.sand.break");
|
||||
registerSound("block.sand.fall");
|
||||
registerSound("block.sand.hit");
|
||||
registerSound("block.sand.place");
|
||||
registerSound("block.sand.step");
|
||||
registerSound("block.shulker_box.close");
|
||||
registerSound("block.shulker_box.open");
|
||||
registerSound("block.slime.break");
|
||||
registerSound("block.slime.fall");
|
||||
registerSound("block.slime.hit");
|
||||
registerSound("block.slime.place");
|
||||
registerSound("block.slime.step");
|
||||
registerSound("block.snow.break");
|
||||
registerSound("block.snow.fall");
|
||||
registerSound("block.snow.hit");
|
||||
registerSound("block.snow.place");
|
||||
registerSound("block.snow.step");
|
||||
registerSound("block.stone.break");
|
||||
registerSound("block.stone.fall");
|
||||
registerSound("block.stone.hit");
|
||||
registerSound("block.stone.place");
|
||||
registerSound("block.stone.step");
|
||||
registerSound("block.stone_button.click_off");
|
||||
registerSound("block.stone_button.click_on");
|
||||
registerSound("block.stone_pressureplate.click_off");
|
||||
registerSound("block.stone_pressureplate.click_on");
|
||||
registerSound("block.tripwire.attach");
|
||||
registerSound("block.tripwire.click_off");
|
||||
registerSound("block.tripwire.click_on");
|
||||
registerSound("block.tripwire.detach");
|
||||
registerSound("block.water.ambient");
|
||||
registerSound("block.waterlily.place");
|
||||
registerSound("block.wood.break");
|
||||
registerSound("block.wood.fall");
|
||||
registerSound("block.wood.hit");
|
||||
registerSound("block.wood.place");
|
||||
registerSound("block.wood.step");
|
||||
registerSound("block.wood_button.click_off");
|
||||
registerSound("block.wood_button.click_on");
|
||||
registerSound("block.wood_pressureplate.click_off");
|
||||
registerSound("block.wood_pressureplate.click_on");
|
||||
registerSound("block.wooden_door.close");
|
||||
registerSound("block.wooden_door.open");
|
||||
registerSound("block.wooden_trapdoor.close");
|
||||
registerSound("block.wooden_trapdoor.open");
|
||||
registerSound("enchant.thorns.hit");
|
||||
registerSound("entity.armorstand.break");
|
||||
registerSound("entity.armorstand.fall");
|
||||
registerSound("entity.armorstand.hit");
|
||||
registerSound("entity.armorstand.place");
|
||||
registerSound("entity.arrow.hit");
|
||||
registerSound("entity.arrow.hit_player");
|
||||
registerSound("entity.arrow.shoot");
|
||||
registerSound("entity.bat.ambient");
|
||||
registerSound("entity.bat.death");
|
||||
registerSound("entity.bat.hurt");
|
||||
registerSound("entity.bat.loop");
|
||||
registerSound("entity.bat.takeoff");
|
||||
registerSound("entity.blaze.ambient");
|
||||
registerSound("entity.blaze.burn");
|
||||
registerSound("entity.blaze.death");
|
||||
registerSound("entity.blaze.hurt");
|
||||
registerSound("entity.blaze.shoot");
|
||||
registerSound("entity.boat.paddle_land");
|
||||
registerSound("entity.boat.paddle_water");
|
||||
registerSound("entity.bobber.retrieve");
|
||||
registerSound("entity.bobber.splash");
|
||||
registerSound("entity.bobber.throw");
|
||||
registerSound("entity.cat.ambient");
|
||||
registerSound("entity.cat.death");
|
||||
registerSound("entity.cat.hiss");
|
||||
registerSound("entity.cat.hurt");
|
||||
registerSound("entity.cat.purr");
|
||||
registerSound("entity.cat.purreow");
|
||||
registerSound("entity.chicken.ambient");
|
||||
registerSound("entity.chicken.death");
|
||||
registerSound("entity.chicken.egg");
|
||||
registerSound("entity.chicken.hurt");
|
||||
registerSound("entity.chicken.step");
|
||||
registerSound("entity.cow.ambient");
|
||||
registerSound("entity.cow.death");
|
||||
registerSound("entity.cow.hurt");
|
||||
registerSound("entity.cow.milk");
|
||||
registerSound("entity.cow.step");
|
||||
registerSound("entity.creeper.death");
|
||||
registerSound("entity.creeper.hurt");
|
||||
registerSound("entity.creeper.primed");
|
||||
registerSound("entity.donkey.ambient");
|
||||
registerSound("entity.donkey.angry");
|
||||
registerSound("entity.donkey.chest");
|
||||
registerSound("entity.donkey.death");
|
||||
registerSound("entity.donkey.hurt");
|
||||
registerSound("entity.egg.throw");
|
||||
registerSound("entity.elder_guardian.ambient");
|
||||
registerSound("entity.elder_guardian.ambient_land");
|
||||
registerSound("entity.elder_guardian.curse");
|
||||
registerSound("entity.elder_guardian.death");
|
||||
registerSound("entity.elder_guardian.death_land");
|
||||
registerSound("entity.elder_guardian.flop");
|
||||
registerSound("entity.elder_guardian.hurt");
|
||||
registerSound("entity.elder_guardian.hurt_land");
|
||||
registerSound("entity.enderdragon.ambient");
|
||||
registerSound("entity.enderdragon.death");
|
||||
registerSound("entity.enderdragon.flap");
|
||||
registerSound("entity.enderdragon.growl");
|
||||
registerSound("entity.enderdragon.hurt");
|
||||
registerSound("entity.enderdragon.shoot");
|
||||
registerSound("entity.enderdragon_fireball.explode");
|
||||
registerSound("entity.endereye.death");
|
||||
registerSound("entity.endereye.launch");
|
||||
registerSound("entity.endermen.ambient");
|
||||
registerSound("entity.endermen.death");
|
||||
registerSound("entity.endermen.hurt");
|
||||
registerSound("entity.endermen.scream");
|
||||
registerSound("entity.endermen.stare");
|
||||
registerSound("entity.endermen.teleport");
|
||||
registerSound("entity.endermite.ambient");
|
||||
registerSound("entity.endermite.death");
|
||||
registerSound("entity.endermite.hurt");
|
||||
registerSound("entity.endermite.step");
|
||||
registerSound("entity.enderpearl.throw");
|
||||
registerSound("entity.evocation_fangs.attack");
|
||||
registerSound("entity.evocation_illager.ambient");
|
||||
registerSound("entity.evocation_illager.cast_spell");
|
||||
registerSound("entity.evocation_illager.death");
|
||||
registerSound("entity.evocation_illager.hurt");
|
||||
registerSound("entity.evocation_illager.prepare_attack");
|
||||
registerSound("entity.evocation_illager.prepare_summon");
|
||||
registerSound("entity.evocation_illager.prepare_wololo");
|
||||
registerSound("entity.experience_bottle.throw");
|
||||
registerSound("entity.experience_orb.pickup");
|
||||
registerSound("entity.firework.blast");
|
||||
registerSound("entity.firework.blast_far");
|
||||
registerSound("entity.firework.large_blast");
|
||||
registerSound("entity.firework.large_blast_far");
|
||||
registerSound("entity.firework.launch");
|
||||
registerSound("entity.firework.shoot");
|
||||
registerSound("entity.firework.twinkle");
|
||||
registerSound("entity.firework.twinkle_far");
|
||||
registerSound("entity.generic.big_fall");
|
||||
registerSound("entity.generic.burn");
|
||||
registerSound("entity.generic.death");
|
||||
registerSound("entity.generic.drink");
|
||||
registerSound("entity.generic.eat");
|
||||
registerSound("entity.generic.explode");
|
||||
registerSound("entity.generic.extinguish_fire");
|
||||
registerSound("entity.generic.hurt");
|
||||
registerSound("entity.generic.small_fall");
|
||||
registerSound("entity.generic.splash");
|
||||
registerSound("entity.generic.swim");
|
||||
registerSound("entity.ghast.ambient");
|
||||
registerSound("entity.ghast.death");
|
||||
registerSound("entity.ghast.hurt");
|
||||
registerSound("entity.ghast.scream");
|
||||
registerSound("entity.ghast.shoot");
|
||||
registerSound("entity.ghast.warn");
|
||||
registerSound("entity.guardian.ambient");
|
||||
registerSound("entity.guardian.ambient_land");
|
||||
registerSound("entity.guardian.attack");
|
||||
registerSound("entity.guardian.death");
|
||||
registerSound("entity.guardian.death_land");
|
||||
registerSound("entity.guardian.flop");
|
||||
registerSound("entity.guardian.hurt");
|
||||
registerSound("entity.guardian.hurt_land");
|
||||
registerSound("entity.horse.ambient");
|
||||
registerSound("entity.horse.angry");
|
||||
registerSound("entity.horse.armor");
|
||||
registerSound("entity.horse.breathe");
|
||||
registerSound("entity.horse.death");
|
||||
registerSound("entity.horse.eat");
|
||||
registerSound("entity.horse.gallop");
|
||||
registerSound("entity.horse.hurt");
|
||||
registerSound("entity.horse.jump");
|
||||
registerSound("entity.horse.land");
|
||||
registerSound("entity.horse.saddle");
|
||||
registerSound("entity.horse.step");
|
||||
registerSound("entity.horse.step_wood");
|
||||
registerSound("entity.hostile.big_fall");
|
||||
registerSound("entity.hostile.death");
|
||||
registerSound("entity.hostile.hurt");
|
||||
registerSound("entity.hostile.small_fall");
|
||||
registerSound("entity.hostile.splash");
|
||||
registerSound("entity.hostile.swim");
|
||||
registerSound("entity.husk.ambient");
|
||||
registerSound("entity.husk.death");
|
||||
registerSound("entity.husk.hurt");
|
||||
registerSound("entity.husk.step");
|
||||
registerSound("entity.illusion_illager.ambient");
|
||||
registerSound("entity.illusion_illager.cast_spell");
|
||||
registerSound("entity.illusion_illager.death");
|
||||
registerSound("entity.illusion_illager.hurt");
|
||||
registerSound("entity.illusion_illager.mirror_move");
|
||||
registerSound("entity.illusion_illager.prepare_blindness");
|
||||
registerSound("entity.illusion_illager.prepare_mirror");
|
||||
registerSound("entity.irongolem.attack");
|
||||
registerSound("entity.irongolem.death");
|
||||
registerSound("entity.irongolem.hurt");
|
||||
registerSound("entity.irongolem.step");
|
||||
registerSound("entity.item.break");
|
||||
registerSound("entity.item.pickup");
|
||||
registerSound("entity.itemframe.add_item");
|
||||
registerSound("entity.itemframe.break");
|
||||
registerSound("entity.itemframe.place");
|
||||
registerSound("entity.itemframe.remove_item");
|
||||
registerSound("entity.itemframe.rotate_item");
|
||||
registerSound("entity.leashknot.break");
|
||||
registerSound("entity.leashknot.place");
|
||||
registerSound("entity.lightning.impact");
|
||||
registerSound("entity.lightning.thunder");
|
||||
registerSound("entity.lingeringpotion.throw");
|
||||
registerSound("entity.llama.ambient");
|
||||
registerSound("entity.llama.angry");
|
||||
registerSound("entity.llama.chest");
|
||||
registerSound("entity.llama.death");
|
||||
registerSound("entity.llama.eat");
|
||||
registerSound("entity.llama.hurt");
|
||||
registerSound("entity.llama.spit");
|
||||
registerSound("entity.llama.step");
|
||||
registerSound("entity.llama.swag");
|
||||
registerSound("entity.magmacube.death");
|
||||
registerSound("entity.magmacube.hurt");
|
||||
registerSound("entity.magmacube.jump");
|
||||
registerSound("entity.magmacube.squish");
|
||||
registerSound("entity.minecart.inside");
|
||||
registerSound("entity.minecart.riding");
|
||||
registerSound("entity.mooshroom.shear");
|
||||
registerSound("entity.mule.ambient");
|
||||
registerSound("entity.mule.chest");
|
||||
registerSound("entity.mule.death");
|
||||
registerSound("entity.mule.hurt");
|
||||
registerSound("entity.painting.break");
|
||||
registerSound("entity.painting.place");
|
||||
registerSound("entity.parrot.ambient");
|
||||
registerSound("entity.parrot.death");
|
||||
registerSound("entity.parrot.eat");
|
||||
registerSound("entity.parrot.fly");
|
||||
registerSound("entity.parrot.hurt");
|
||||
registerSound("entity.parrot.imitate.blaze");
|
||||
registerSound("entity.parrot.imitate.creeper");
|
||||
registerSound("entity.parrot.imitate.elder_guardian");
|
||||
registerSound("entity.parrot.imitate.enderdragon");
|
||||
registerSound("entity.parrot.imitate.enderman");
|
||||
registerSound("entity.parrot.imitate.endermite");
|
||||
registerSound("entity.parrot.imitate.evocation_illager");
|
||||
registerSound("entity.parrot.imitate.ghast");
|
||||
registerSound("entity.parrot.imitate.husk");
|
||||
registerSound("entity.parrot.imitate.illusion_illager");
|
||||
registerSound("entity.parrot.imitate.magmacube");
|
||||
registerSound("entity.parrot.imitate.polar_bear");
|
||||
registerSound("entity.parrot.imitate.shulker");
|
||||
registerSound("entity.parrot.imitate.silverfish");
|
||||
registerSound("entity.parrot.imitate.skeleton");
|
||||
registerSound("entity.parrot.imitate.slime");
|
||||
registerSound("entity.parrot.imitate.spider");
|
||||
registerSound("entity.parrot.imitate.stray");
|
||||
registerSound("entity.parrot.imitate.vex");
|
||||
registerSound("entity.parrot.imitate.vindication_illager");
|
||||
registerSound("entity.parrot.imitate.witch");
|
||||
registerSound("entity.parrot.imitate.wither");
|
||||
registerSound("entity.parrot.imitate.wither_skeleton");
|
||||
registerSound("entity.parrot.imitate.wolf");
|
||||
registerSound("entity.parrot.imitate.zombie");
|
||||
registerSound("entity.parrot.imitate.zombie_pigman");
|
||||
registerSound("entity.parrot.imitate.zombie_villager");
|
||||
registerSound("entity.parrot.step");
|
||||
registerSound("entity.pig.ambient");
|
||||
registerSound("entity.pig.death");
|
||||
registerSound("entity.pig.hurt");
|
||||
registerSound("entity.pig.saddle");
|
||||
registerSound("entity.pig.step");
|
||||
registerSound("entity.player.attack.crit");
|
||||
registerSound("entity.player.attack.knockback");
|
||||
registerSound("entity.player.attack.nodamage");
|
||||
registerSound("entity.player.attack.strong");
|
||||
registerSound("entity.player.attack.sweep");
|
||||
registerSound("entity.player.attack.weak");
|
||||
registerSound("entity.player.big_fall");
|
||||
registerSound("entity.player.breath");
|
||||
registerSound("entity.player.burp");
|
||||
registerSound("entity.player.death");
|
||||
registerSound("entity.player.hurt");
|
||||
registerSound("entity.player.hurt_drown");
|
||||
registerSound("entity.player.hurt_on_fire");
|
||||
registerSound("entity.player.levelup");
|
||||
registerSound("entity.player.small_fall");
|
||||
registerSound("entity.player.splash");
|
||||
registerSound("entity.player.swim");
|
||||
registerSound("entity.polar_bear.ambient");
|
||||
registerSound("entity.polar_bear.baby_ambient");
|
||||
registerSound("entity.polar_bear.death");
|
||||
registerSound("entity.polar_bear.hurt");
|
||||
registerSound("entity.polar_bear.step");
|
||||
registerSound("entity.polar_bear.warning");
|
||||
registerSound("entity.rabbit.ambient");
|
||||
registerSound("entity.rabbit.attack");
|
||||
registerSound("entity.rabbit.death");
|
||||
registerSound("entity.rabbit.hurt");
|
||||
registerSound("entity.rabbit.jump");
|
||||
registerSound("entity.sheep.ambient");
|
||||
registerSound("entity.sheep.death");
|
||||
registerSound("entity.sheep.hurt");
|
||||
registerSound("entity.sheep.shear");
|
||||
registerSound("entity.sheep.step");
|
||||
registerSound("entity.shulker.ambient");
|
||||
registerSound("entity.shulker.close");
|
||||
registerSound("entity.shulker.death");
|
||||
registerSound("entity.shulker.hurt");
|
||||
registerSound("entity.shulker.hurt_closed");
|
||||
registerSound("entity.shulker.open");
|
||||
registerSound("entity.shulker.shoot");
|
||||
registerSound("entity.shulker.teleport");
|
||||
registerSound("entity.shulker_bullet.hit");
|
||||
registerSound("entity.shulker_bullet.hurt");
|
||||
registerSound("entity.silverfish.ambient");
|
||||
registerSound("entity.silverfish.death");
|
||||
registerSound("entity.silverfish.hurt");
|
||||
registerSound("entity.silverfish.step");
|
||||
registerSound("entity.skeleton.ambient");
|
||||
registerSound("entity.skeleton.death");
|
||||
registerSound("entity.skeleton.hurt");
|
||||
registerSound("entity.skeleton.shoot");
|
||||
registerSound("entity.skeleton.step");
|
||||
registerSound("entity.skeleton_horse.ambient");
|
||||
registerSound("entity.skeleton_horse.death");
|
||||
registerSound("entity.skeleton_horse.hurt");
|
||||
registerSound("entity.slime.attack");
|
||||
registerSound("entity.slime.death");
|
||||
registerSound("entity.slime.hurt");
|
||||
registerSound("entity.slime.jump");
|
||||
registerSound("entity.slime.squish");
|
||||
registerSound("entity.small_magmacube.death");
|
||||
registerSound("entity.small_magmacube.hurt");
|
||||
registerSound("entity.small_magmacube.squish");
|
||||
registerSound("entity.small_slime.death");
|
||||
registerSound("entity.small_slime.hurt");
|
||||
registerSound("entity.small_slime.jump");
|
||||
registerSound("entity.small_slime.squish");
|
||||
registerSound("entity.snowball.throw");
|
||||
registerSound("entity.snowman.ambient");
|
||||
registerSound("entity.snowman.death");
|
||||
registerSound("entity.snowman.hurt");
|
||||
registerSound("entity.snowman.shoot");
|
||||
registerSound("entity.spider.ambient");
|
||||
registerSound("entity.spider.death");
|
||||
registerSound("entity.spider.hurt");
|
||||
registerSound("entity.spider.step");
|
||||
registerSound("entity.splash_potion.break");
|
||||
registerSound("entity.splash_potion.throw");
|
||||
registerSound("entity.squid.ambient");
|
||||
registerSound("entity.squid.death");
|
||||
registerSound("entity.squid.hurt");
|
||||
registerSound("entity.stray.ambient");
|
||||
registerSound("entity.stray.death");
|
||||
registerSound("entity.stray.hurt");
|
||||
registerSound("entity.stray.step");
|
||||
registerSound("entity.tnt.primed");
|
||||
registerSound("entity.vex.ambient");
|
||||
registerSound("entity.vex.charge");
|
||||
registerSound("entity.vex.death");
|
||||
registerSound("entity.vex.hurt");
|
||||
registerSound("entity.villager.ambient");
|
||||
registerSound("entity.villager.death");
|
||||
registerSound("entity.villager.hurt");
|
||||
registerSound("entity.villager.no");
|
||||
registerSound("entity.villager.trading");
|
||||
registerSound("entity.villager.yes");
|
||||
registerSound("entity.vindication_illager.ambient");
|
||||
registerSound("entity.vindication_illager.death");
|
||||
registerSound("entity.vindication_illager.hurt");
|
||||
registerSound("entity.witch.ambient");
|
||||
registerSound("entity.witch.death");
|
||||
registerSound("entity.witch.drink");
|
||||
registerSound("entity.witch.hurt");
|
||||
registerSound("entity.witch.throw");
|
||||
registerSound("entity.wither.ambient");
|
||||
registerSound("entity.wither.break_block");
|
||||
registerSound("entity.wither.death");
|
||||
registerSound("entity.wither.hurt");
|
||||
registerSound("entity.wither.shoot");
|
||||
registerSound("entity.wither.spawn");
|
||||
registerSound("entity.wither_skeleton.ambient");
|
||||
registerSound("entity.wither_skeleton.death");
|
||||
registerSound("entity.wither_skeleton.hurt");
|
||||
registerSound("entity.wither_skeleton.step");
|
||||
registerSound("entity.wolf.ambient");
|
||||
registerSound("entity.wolf.death");
|
||||
registerSound("entity.wolf.growl");
|
||||
registerSound("entity.wolf.howl");
|
||||
registerSound("entity.wolf.hurt");
|
||||
registerSound("entity.wolf.pant");
|
||||
registerSound("entity.wolf.shake");
|
||||
registerSound("entity.wolf.step");
|
||||
registerSound("entity.wolf.whine");
|
||||
registerSound("entity.zombie.ambient");
|
||||
registerSound("entity.zombie.attack_door_wood");
|
||||
registerSound("entity.zombie.attack_iron_door");
|
||||
registerSound("entity.zombie.break_door_wood");
|
||||
registerSound("entity.zombie.death");
|
||||
registerSound("entity.zombie.hurt");
|
||||
registerSound("entity.zombie.infect");
|
||||
registerSound("entity.zombie.step");
|
||||
registerSound("entity.zombie_horse.ambient");
|
||||
registerSound("entity.zombie_horse.death");
|
||||
registerSound("entity.zombie_horse.hurt");
|
||||
registerSound("entity.zombie_pig.ambient");
|
||||
registerSound("entity.zombie_pig.angry");
|
||||
registerSound("entity.zombie_pig.death");
|
||||
registerSound("entity.zombie_pig.hurt");
|
||||
registerSound("entity.zombie_villager.ambient");
|
||||
registerSound("entity.zombie_villager.converted");
|
||||
registerSound("entity.zombie_villager.cure");
|
||||
registerSound("entity.zombie_villager.death");
|
||||
registerSound("entity.zombie_villager.hurt");
|
||||
registerSound("entity.zombie_villager.step");
|
||||
registerSound("item.armor.equip_chain");
|
||||
registerSound("item.armor.equip_diamond");
|
||||
registerSound("item.armor.equip_elytra");
|
||||
registerSound("item.armor.equip_generic");
|
||||
registerSound("item.armor.equip_gold");
|
||||
registerSound("item.armor.equip_iron");
|
||||
registerSound("item.armor.equip_leather");
|
||||
registerSound("item.bottle.empty");
|
||||
registerSound("item.bottle.fill");
|
||||
registerSound("item.bottle.fill_dragonbreath");
|
||||
registerSound("item.bucket.empty");
|
||||
registerSound("item.bucket.empty_lava");
|
||||
registerSound("item.bucket.fill");
|
||||
registerSound("item.bucket.fill_lava");
|
||||
registerSound("item.chorus_fruit.teleport");
|
||||
registerSound("item.elytra.flying");
|
||||
registerSound("item.firecharge.use");
|
||||
registerSound("item.flintandsteel.use");
|
||||
registerSound("item.hoe.till");
|
||||
registerSound("item.shield.block");
|
||||
registerSound("item.shield.break");
|
||||
registerSound("item.shovel.flatten");
|
||||
registerSound("item.totem.use");
|
||||
registerSound("music.creative");
|
||||
registerSound("music.credits");
|
||||
registerSound("music.dragon");
|
||||
registerSound("music.end");
|
||||
registerSound("music.game");
|
||||
registerSound("music.menu");
|
||||
registerSound("music.nether");
|
||||
registerSound("record.11");
|
||||
registerSound("record.13");
|
||||
registerSound("record.blocks");
|
||||
registerSound("record.cat");
|
||||
registerSound("record.chirp");
|
||||
registerSound("record.far");
|
||||
registerSound("record.mall");
|
||||
registerSound("record.mellohi");
|
||||
registerSound("record.stal");
|
||||
registerSound("record.strad");
|
||||
registerSound("record.wait");
|
||||
registerSound("record.ward");
|
||||
registerSound("ui.button.click");
|
||||
registerSound("ui.toast.in");
|
||||
registerSound("ui.toast.out");
|
||||
registerSound("ui.toast.challenge_complete");
|
||||
registerSound("weather.rain");
|
||||
registerSound("weather.rain.above");
|
||||
}
|
||||
|
||||
private static void registerSound(String soundNameIn)
|
||||
{
|
||||
ResourceLocation resourcelocation = new ResourceLocation(soundNameIn);
|
||||
REGISTRY.register(soundEventId++, resourcelocation, new SoundEvent(resourcelocation));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class StringUtils
|
||||
{
|
||||
private static final Pattern PATTERN_CONTROL_CODE = Pattern.compile("(?i)\\u00A7[0-9A-FK-OR]");
|
||||
|
||||
/**
|
||||
* Returns the time elapsed for the given number of ticks, in "mm:ss" format.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static String ticksToElapsedTime(int ticks)
|
||||
{
|
||||
int i = ticks / 20;
|
||||
int j = i / 60;
|
||||
i = i % 60;
|
||||
return i < 10 ? j + ":0" + i : j + ":" + i;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static String stripControlCodes(String text)
|
||||
{
|
||||
return PATTERN_CONTROL_CODE.matcher(text).replaceAll("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value indicating whether the given string is null or empty.
|
||||
*/
|
||||
public static boolean isNullOrEmpty(@Nullable String string)
|
||||
{
|
||||
return org.apache.commons.lang3.StringUtils.isEmpty(string);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.network.play.client.CPacketTabComplete;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class TabCompleter
|
||||
{
|
||||
/** The {@link GuiTextField} that is backing this {@link TabCompleter} */
|
||||
protected final GuiTextField textField;
|
||||
protected final boolean hasTargetBlock;
|
||||
protected boolean didComplete;
|
||||
protected boolean requestedCompletions;
|
||||
protected int completionIdx;
|
||||
protected List<String> completions = Lists.<String>newArrayList();
|
||||
|
||||
public TabCompleter(GuiTextField textFieldIn, boolean hasTargetBlockIn)
|
||||
{
|
||||
this.textField = textFieldIn;
|
||||
this.hasTargetBlock = hasTargetBlockIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when tab key pressed. If it's the first time we tried to complete this string, we ask the server for
|
||||
* completions. When the server responds, this method gets called again (via setCompletions).
|
||||
*/
|
||||
public void complete()
|
||||
{
|
||||
if (this.didComplete)
|
||||
{
|
||||
this.textField.deleteFromCursor(0);
|
||||
this.textField.deleteFromCursor(this.textField.getNthWordFromPosWS(-1, this.textField.getCursorPosition(), false) - this.textField.getCursorPosition());
|
||||
|
||||
if (this.completionIdx >= this.completions.size())
|
||||
{
|
||||
this.completionIdx = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = this.textField.getNthWordFromPosWS(-1, this.textField.getCursorPosition(), false);
|
||||
this.completions.clear();
|
||||
this.completionIdx = 0;
|
||||
String s = this.textField.getText().substring(0, this.textField.getCursorPosition());
|
||||
this.requestCompletions(s);
|
||||
|
||||
if (this.completions.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.didComplete = true;
|
||||
this.textField.deleteFromCursor(i - this.textField.getCursorPosition());
|
||||
}
|
||||
|
||||
this.textField.writeText(net.minecraft.util.text.TextFormatting.getTextWithoutFormattingCodes(this.completions.get(this.completionIdx++)));
|
||||
}
|
||||
|
||||
private void requestCompletions(String prefix)
|
||||
{
|
||||
if (prefix.length() >= 1)
|
||||
{
|
||||
net.minecraftforge.client.ClientCommandHandler.instance.autoComplete(prefix);
|
||||
Minecraft.getMinecraft().player.connection.sendPacket(new CPacketTabComplete(prefix, this.getTargetBlockPos(), this.hasTargetBlock));
|
||||
this.requestedCompletions = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract BlockPos getTargetBlockPos();
|
||||
|
||||
/**
|
||||
* Only actually sets completions if they were requested (via requestCompletions)
|
||||
*/
|
||||
public void setCompletions(String... newCompl)
|
||||
{
|
||||
if (this.requestedCompletions)
|
||||
{
|
||||
this.didComplete = false;
|
||||
this.completions.clear();
|
||||
|
||||
String[] complete = net.minecraftforge.client.ClientCommandHandler.instance.latestAutoComplete;
|
||||
if (complete != null)
|
||||
{
|
||||
newCompl = com.google.common.collect.ObjectArrays.concat(complete, newCompl, String.class);
|
||||
}
|
||||
|
||||
for (String s : newCompl)
|
||||
{
|
||||
if (!s.isEmpty())
|
||||
{
|
||||
this.completions.add(s);
|
||||
}
|
||||
}
|
||||
|
||||
String s1 = this.textField.getText().substring(this.textField.getNthWordFromPosWS(-1, this.textField.getCursorPosition(), false));
|
||||
String s2 = org.apache.commons.lang3.StringUtils.getCommonPrefix(newCompl);
|
||||
s2 = net.minecraft.util.text.TextFormatting.getTextWithoutFormattingCodes(s2);
|
||||
|
||||
if (!s2.isEmpty() && !s1.equalsIgnoreCase(s2))
|
||||
{
|
||||
this.textField.deleteFromCursor(0);
|
||||
this.textField.deleteFromCursor(this.textField.getNthWordFromPosWS(-1, this.textField.getCursorPosition(), false) - this.textField.getCursorPosition());
|
||||
this.textField.writeText(s2);
|
||||
}
|
||||
else if (!this.completions.isEmpty())
|
||||
{
|
||||
this.didComplete = true;
|
||||
this.complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when new text is entered, or backspace pressed
|
||||
*/
|
||||
public void resetDidComplete()
|
||||
{
|
||||
this.didComplete = false;
|
||||
}
|
||||
|
||||
public void resetRequested()
|
||||
{
|
||||
this.requestedCompletions = false;
|
||||
}
|
||||
}
|
||||
42
build/tmp/recompileMc/sources/net/minecraft/util/Timer.java
Normal file
42
build/tmp/recompileMc/sources/net/minecraft/util/Timer.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class Timer
|
||||
{
|
||||
/** How many full ticks have turned over since the last call to updateTimer(), capped at 10. */
|
||||
public int elapsedTicks;
|
||||
/**
|
||||
* How much time has elapsed since the last tick, in ticks, for use by display rendering routines (range: 0.0 -
|
||||
* 1.0).
|
||||
*/
|
||||
public float renderPartialTicks;
|
||||
/** How much time has elapsed since the last tick, in ticks (range: 0.0 - 1.0). */
|
||||
public float elapsedPartialTicks;
|
||||
/** The time reported by the system clock at the last sync, in milliseconds */
|
||||
private long lastSyncSysClock;
|
||||
/** The Length of a single tick in milliseconds. Calculated as 1000/tps. At a default 20 TPS, tickLength is 50 ms */
|
||||
private float tickLength;
|
||||
|
||||
public Timer(float tps)
|
||||
{
|
||||
this.tickLength = 1000.0F / tps;
|
||||
this.lastSyncSysClock = Minecraft.getSystemTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates all fields of the Timer using the current time
|
||||
*/
|
||||
public void updateTimer()
|
||||
{
|
||||
long i = Minecraft.getSystemTime();
|
||||
this.elapsedPartialTicks = (float)(i - this.lastSyncSysClock) / this.tickLength;
|
||||
this.lastSyncSysClock = i;
|
||||
this.renderPartialTicks += this.elapsedPartialTicks;
|
||||
this.elapsedTicks = (int)this.renderPartialTicks;
|
||||
this.renderPartialTicks -= (float)this.elapsedTicks;
|
||||
}
|
||||
}
|
||||
29
build/tmp/recompileMc/sources/net/minecraft/util/Tuple.java
Normal file
29
build/tmp/recompileMc/sources/net/minecraft/util/Tuple.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
public class Tuple<A, B>
|
||||
{
|
||||
private A a;
|
||||
private B b;
|
||||
|
||||
public Tuple(A aIn, B bIn)
|
||||
{
|
||||
this.a = aIn;
|
||||
this.b = bIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first Object in the Tuple
|
||||
*/
|
||||
public A getFirst()
|
||||
{
|
||||
return this.a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the second Object in the Tuple
|
||||
*/
|
||||
public B getSecond()
|
||||
{
|
||||
return this.b;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
public class TupleIntJsonSerializable
|
||||
{
|
||||
private int integerValue;
|
||||
private IJsonSerializable jsonSerializableValue;
|
||||
|
||||
/**
|
||||
* Gets the integer value stored in this tuple.
|
||||
*/
|
||||
public int getIntegerValue()
|
||||
{
|
||||
return this.integerValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this tuple's integer value to the given value.
|
||||
*/
|
||||
public void setIntegerValue(int integerValueIn)
|
||||
{
|
||||
this.integerValue = integerValueIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the JsonSerializable value stored in this tuple.
|
||||
*/
|
||||
public <T extends IJsonSerializable> T getJsonSerializableValue()
|
||||
{
|
||||
return (T)this.jsonSerializableValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this tuple's JsonSerializable value to the given value.
|
||||
*/
|
||||
public void setJsonSerializableValue(IJsonSerializable jsonSerializableValueIn)
|
||||
{
|
||||
this.jsonSerializableValue = jsonSerializableValueIn;
|
||||
}
|
||||
}
|
||||
82
build/tmp/recompileMc/sources/net/minecraft/util/Util.java
Normal file
82
build/tmp/recompileMc/sources/net/minecraft/util/Util.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.FutureTask;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class Util
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static Util.EnumOS getOSType()
|
||||
{
|
||||
String s = System.getProperty("os.name").toLowerCase(Locale.ROOT);
|
||||
|
||||
if (s.contains("win"))
|
||||
{
|
||||
return Util.EnumOS.WINDOWS;
|
||||
}
|
||||
else if (s.contains("mac"))
|
||||
{
|
||||
return Util.EnumOS.OSX;
|
||||
}
|
||||
else if (s.contains("solaris"))
|
||||
{
|
||||
return Util.EnumOS.SOLARIS;
|
||||
}
|
||||
else if (s.contains("sunos"))
|
||||
{
|
||||
return Util.EnumOS.SOLARIS;
|
||||
}
|
||||
else if (s.contains("linux"))
|
||||
{
|
||||
return Util.EnumOS.LINUX;
|
||||
}
|
||||
else
|
||||
{
|
||||
return s.contains("unix") ? Util.EnumOS.LINUX : Util.EnumOS.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a task and return the result, catching any execution exceptions and logging them to the specified logger
|
||||
*/
|
||||
@Nullable
|
||||
public static <V> V runTask(FutureTask<V> task, Logger logger)
|
||||
{
|
||||
try
|
||||
{
|
||||
task.run();
|
||||
return task.get();
|
||||
}
|
||||
catch (ExecutionException executionexception)
|
||||
{
|
||||
logger.fatal("Error executing task", (Throwable)executionexception);
|
||||
}
|
||||
catch (InterruptedException interruptedexception)
|
||||
{
|
||||
logger.fatal("Error executing task", (Throwable)interruptedexception);
|
||||
}
|
||||
|
||||
return (V)null;
|
||||
}
|
||||
|
||||
public static <T> T getLastElement(List<T> list)
|
||||
{
|
||||
return list.get(list.size() - 1);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static enum EnumOS
|
||||
{
|
||||
LINUX,
|
||||
SOLARIS,
|
||||
WINDOWS,
|
||||
OSX,
|
||||
UNKNOWN;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class WeightedRandom
|
||||
{
|
||||
/**
|
||||
* Returns the total weight of all items in a collection.
|
||||
*/
|
||||
public static int getTotalWeight(List <? extends WeightedRandom.Item > collection)
|
||||
{
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
|
||||
for (int k = collection.size(); j < k; ++j)
|
||||
{
|
||||
WeightedRandom.Item weightedrandom$item = collection.get(j);
|
||||
i += weightedrandom$item.itemWeight;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a random choice from the input items, with a total weight value.
|
||||
*/
|
||||
public static <T extends WeightedRandom.Item> T getRandomItem(Random random, List<T> collection, int totalWeight)
|
||||
{
|
||||
if (totalWeight <= 0)
|
||||
{
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = random.nextInt(totalWeight);
|
||||
return (T)getRandomItem(collection, i);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T extends WeightedRandom.Item> T getRandomItem(List<T> collection, int weight)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (int j = collection.size(); i < j; ++i)
|
||||
{
|
||||
T t = collection.get(i);
|
||||
weight -= t.itemWeight;
|
||||
|
||||
if (weight < 0)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
return (T)null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a random choice from the input items.
|
||||
*/
|
||||
public static <T extends WeightedRandom.Item> T getRandomItem(Random random, List<T> collection)
|
||||
{
|
||||
return (T)getRandomItem(random, collection, getTotalWeight(collection));
|
||||
}
|
||||
|
||||
public static class Item
|
||||
{
|
||||
/** The Weight is how often the item is chosen(higher number is higher chance(lower is lower)) */
|
||||
public int itemWeight;
|
||||
|
||||
public Item(int itemWeightIn)
|
||||
{
|
||||
this.itemWeight = itemWeightIn;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class WeightedSpawnerEntity extends WeightedRandom.Item
|
||||
{
|
||||
private final NBTTagCompound nbt;
|
||||
|
||||
public WeightedSpawnerEntity()
|
||||
{
|
||||
super(1);
|
||||
this.nbt = new NBTTagCompound();
|
||||
this.nbt.setString("id", "minecraft:pig");
|
||||
}
|
||||
|
||||
public WeightedSpawnerEntity(NBTTagCompound nbtIn)
|
||||
{
|
||||
this(nbtIn.hasKey("Weight", 99) ? nbtIn.getInteger("Weight") : 1, nbtIn.getCompoundTag("Entity"));
|
||||
}
|
||||
|
||||
public WeightedSpawnerEntity(int itemWeightIn, NBTTagCompound nbtIn)
|
||||
{
|
||||
super(itemWeightIn);
|
||||
this.nbt = nbtIn;
|
||||
}
|
||||
|
||||
public NBTTagCompound toCompoundTag()
|
||||
{
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
|
||||
if (!this.nbt.hasKey("id", 8))
|
||||
{
|
||||
this.nbt.setString("id", "minecraft:pig");
|
||||
}
|
||||
else if (!this.nbt.getString("id").contains(":"))
|
||||
{
|
||||
this.nbt.setString("id", (new ResourceLocation(this.nbt.getString("id"))).toString());
|
||||
}
|
||||
|
||||
nbttagcompound.setTag("Entity", this.nbt);
|
||||
nbttagcompound.setInteger("Weight", this.itemWeight);
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
public NBTTagCompound getNbt()
|
||||
{
|
||||
return this.nbt;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package net.minecraft.util.datafix;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Util;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class DataFixer implements IDataFixer
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private final Map<IFixType, List<IDataWalker>> walkerMap = Maps.<IFixType, List<IDataWalker>>newHashMap();
|
||||
private final Map<IFixType, List<IFixableData>> fixMap = Maps.<IFixType, List<IFixableData>>newHashMap();
|
||||
public final int version;
|
||||
|
||||
public DataFixer(int versionIn)
|
||||
{
|
||||
this.version = versionIn;
|
||||
}
|
||||
|
||||
public NBTTagCompound process(IFixType type, NBTTagCompound compound)
|
||||
{
|
||||
int i = compound.hasKey("DataVersion", 99) ? compound.getInteger("DataVersion") : -1;
|
||||
return i >= 1343 ? compound : this.process(type, compound, i);
|
||||
}
|
||||
|
||||
public NBTTagCompound process(IFixType type, NBTTagCompound compound, int versionIn)
|
||||
{
|
||||
if (versionIn < this.version)
|
||||
{
|
||||
compound = this.processFixes(type, compound, versionIn);
|
||||
compound = this.processWalkers(type, compound, versionIn);
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
private NBTTagCompound processFixes(IFixType type, NBTTagCompound compound, int versionIn)
|
||||
{
|
||||
List<IFixableData> list = (List)this.fixMap.get(type);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
for (int i = 0; i < list.size(); ++i)
|
||||
{
|
||||
IFixableData ifixabledata = list.get(i);
|
||||
|
||||
if (ifixabledata.getFixVersion() > versionIn)
|
||||
{
|
||||
compound = ifixabledata.fixTagCompound(compound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
private NBTTagCompound processWalkers(IFixType type, NBTTagCompound compound, int versionIn)
|
||||
{
|
||||
List<IDataWalker> list = (List)this.walkerMap.get(type);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
for (int i = 0; i < list.size(); ++i)
|
||||
{
|
||||
compound = ((IDataWalker)list.get(i)).process(this, compound, versionIn);
|
||||
}
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
public void registerWalker(FixTypes type, IDataWalker walker)
|
||||
{
|
||||
this.registerVanillaWalker(type, walker);
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not invoke this method, use registerWalker instead. It is expected to be removed in future versions.
|
||||
*/
|
||||
public void registerVanillaWalker(IFixType type, IDataWalker walker)
|
||||
{
|
||||
this.getTypeList(this.walkerMap, type).add(walker);
|
||||
}
|
||||
|
||||
public void registerFix(IFixType type, IFixableData fixable)
|
||||
{
|
||||
List<IFixableData> list = this.<IFixableData>getTypeList(this.fixMap, type);
|
||||
int i = fixable.getFixVersion();
|
||||
|
||||
if (i > this.version)
|
||||
{
|
||||
LOGGER.warn("Ignored fix registered for version: {} as the DataVersion of the game is: {}", Integer.valueOf(i), Integer.valueOf(this.version));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!list.isEmpty() && ((IFixableData)Util.getLastElement(list)).getFixVersion() > i)
|
||||
{
|
||||
for (int j = 0; j < list.size(); ++j)
|
||||
{
|
||||
if (((IFixableData)list.get(j)).getFixVersion() > i)
|
||||
{
|
||||
list.add(j, fixable);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
list.add(fixable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private <V> List<V> getTypeList(Map<IFixType, List<V>> map, IFixType type)
|
||||
{
|
||||
List<V> list = (List)map.get(type);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
list = Lists.<V>newArrayList();
|
||||
map.put(type, list);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
package net.minecraft.util.datafix;
|
||||
|
||||
import net.minecraft.block.BlockJukebox;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.boss.EntityDragon;
|
||||
import net.minecraft.entity.boss.EntityWither;
|
||||
import net.minecraft.entity.item.EntityArmorStand;
|
||||
import net.minecraft.entity.item.EntityEnderPearl;
|
||||
import net.minecraft.entity.item.EntityExpBottle;
|
||||
import net.minecraft.entity.item.EntityFallingBlock;
|
||||
import net.minecraft.entity.item.EntityFireworkRocket;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.EntityItemFrame;
|
||||
import net.minecraft.entity.item.EntityMinecartChest;
|
||||
import net.minecraft.entity.item.EntityMinecartCommandBlock;
|
||||
import net.minecraft.entity.item.EntityMinecartEmpty;
|
||||
import net.minecraft.entity.item.EntityMinecartFurnace;
|
||||
import net.minecraft.entity.item.EntityMinecartHopper;
|
||||
import net.minecraft.entity.item.EntityMinecartMobSpawner;
|
||||
import net.minecraft.entity.item.EntityMinecartTNT;
|
||||
import net.minecraft.entity.monster.EntityBlaze;
|
||||
import net.minecraft.entity.monster.EntityCaveSpider;
|
||||
import net.minecraft.entity.monster.EntityCreeper;
|
||||
import net.minecraft.entity.monster.EntityElderGuardian;
|
||||
import net.minecraft.entity.monster.EntityEnderman;
|
||||
import net.minecraft.entity.monster.EntityEndermite;
|
||||
import net.minecraft.entity.monster.EntityEvoker;
|
||||
import net.minecraft.entity.monster.EntityGhast;
|
||||
import net.minecraft.entity.monster.EntityGiantZombie;
|
||||
import net.minecraft.entity.monster.EntityGuardian;
|
||||
import net.minecraft.entity.monster.EntityHusk;
|
||||
import net.minecraft.entity.monster.EntityIronGolem;
|
||||
import net.minecraft.entity.monster.EntityMagmaCube;
|
||||
import net.minecraft.entity.monster.EntityPigZombie;
|
||||
import net.minecraft.entity.monster.EntityShulker;
|
||||
import net.minecraft.entity.monster.EntitySilverfish;
|
||||
import net.minecraft.entity.monster.EntitySkeleton;
|
||||
import net.minecraft.entity.monster.EntitySlime;
|
||||
import net.minecraft.entity.monster.EntitySnowman;
|
||||
import net.minecraft.entity.monster.EntitySpider;
|
||||
import net.minecraft.entity.monster.EntityStray;
|
||||
import net.minecraft.entity.monster.EntityVex;
|
||||
import net.minecraft.entity.monster.EntityVindicator;
|
||||
import net.minecraft.entity.monster.EntityWitch;
|
||||
import net.minecraft.entity.monster.EntityWitherSkeleton;
|
||||
import net.minecraft.entity.monster.EntityZombie;
|
||||
import net.minecraft.entity.monster.EntityZombieVillager;
|
||||
import net.minecraft.entity.passive.EntityBat;
|
||||
import net.minecraft.entity.passive.EntityChicken;
|
||||
import net.minecraft.entity.passive.EntityCow;
|
||||
import net.minecraft.entity.passive.EntityDonkey;
|
||||
import net.minecraft.entity.passive.EntityHorse;
|
||||
import net.minecraft.entity.passive.EntityMooshroom;
|
||||
import net.minecraft.entity.passive.EntityMule;
|
||||
import net.minecraft.entity.passive.EntityOcelot;
|
||||
import net.minecraft.entity.passive.EntityPig;
|
||||
import net.minecraft.entity.passive.EntityRabbit;
|
||||
import net.minecraft.entity.passive.EntitySheep;
|
||||
import net.minecraft.entity.passive.EntitySkeletonHorse;
|
||||
import net.minecraft.entity.passive.EntitySquid;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.entity.passive.EntityWolf;
|
||||
import net.minecraft.entity.passive.EntityZombieHorse;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.entity.projectile.EntityDragonFireball;
|
||||
import net.minecraft.entity.projectile.EntityEgg;
|
||||
import net.minecraft.entity.projectile.EntityLargeFireball;
|
||||
import net.minecraft.entity.projectile.EntityPotion;
|
||||
import net.minecraft.entity.projectile.EntitySmallFireball;
|
||||
import net.minecraft.entity.projectile.EntitySnowball;
|
||||
import net.minecraft.entity.projectile.EntitySpectralArrow;
|
||||
import net.minecraft.entity.projectile.EntityTippedArrow;
|
||||
import net.minecraft.entity.projectile.EntityWitherSkull;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntityBrewingStand;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.tileentity.TileEntityDispenser;
|
||||
import net.minecraft.tileentity.TileEntityDropper;
|
||||
import net.minecraft.tileentity.TileEntityFlowerPot;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.tileentity.TileEntityHopper;
|
||||
import net.minecraft.tileentity.TileEntityMobSpawner;
|
||||
import net.minecraft.tileentity.TileEntityPiston;
|
||||
import net.minecraft.tileentity.TileEntityShulkerBox;
|
||||
import net.minecraft.util.datafix.fixes.AddBedTileEntity;
|
||||
import net.minecraft.util.datafix.fixes.ArmorStandSilent;
|
||||
import net.minecraft.util.datafix.fixes.BannerItemColor;
|
||||
import net.minecraft.util.datafix.fixes.BedItemColor;
|
||||
import net.minecraft.util.datafix.fixes.BookPagesStrictJSON;
|
||||
import net.minecraft.util.datafix.fixes.CookedFishIDTypo;
|
||||
import net.minecraft.util.datafix.fixes.ElderGuardianSplit;
|
||||
import net.minecraft.util.datafix.fixes.EntityArmorAndHeld;
|
||||
import net.minecraft.util.datafix.fixes.EntityHealth;
|
||||
import net.minecraft.util.datafix.fixes.EntityId;
|
||||
import net.minecraft.util.datafix.fixes.ForceVBOOn;
|
||||
import net.minecraft.util.datafix.fixes.HorseSaddle;
|
||||
import net.minecraft.util.datafix.fixes.HorseSplit;
|
||||
import net.minecraft.util.datafix.fixes.ItemIntIDToString;
|
||||
import net.minecraft.util.datafix.fixes.MinecartEntityTypes;
|
||||
import net.minecraft.util.datafix.fixes.OptionsLowerCaseLanguage;
|
||||
import net.minecraft.util.datafix.fixes.PaintingDirection;
|
||||
import net.minecraft.util.datafix.fixes.PotionItems;
|
||||
import net.minecraft.util.datafix.fixes.PotionWater;
|
||||
import net.minecraft.util.datafix.fixes.RedundantChanceTags;
|
||||
import net.minecraft.util.datafix.fixes.RidingToPassengers;
|
||||
import net.minecraft.util.datafix.fixes.ShulkerBoxEntityColor;
|
||||
import net.minecraft.util.datafix.fixes.ShulkerBoxItemColor;
|
||||
import net.minecraft.util.datafix.fixes.ShulkerBoxTileColor;
|
||||
import net.minecraft.util.datafix.fixes.SignStrictJSON;
|
||||
import net.minecraft.util.datafix.fixes.SkeletonSplit;
|
||||
import net.minecraft.util.datafix.fixes.SpawnEggNames;
|
||||
import net.minecraft.util.datafix.fixes.SpawnerEntityTypes;
|
||||
import net.minecraft.util.datafix.fixes.StringToUUID;
|
||||
import net.minecraft.util.datafix.fixes.TileEntityId;
|
||||
import net.minecraft.util.datafix.fixes.TotemItemRename;
|
||||
import net.minecraft.util.datafix.fixes.ZombieProfToType;
|
||||
import net.minecraft.util.datafix.fixes.ZombieSplit;
|
||||
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
|
||||
import net.minecraft.world.gen.structure.template.Template;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
|
||||
public class DataFixesManager
|
||||
{
|
||||
private static void registerFixes(DataFixer fixer)
|
||||
{
|
||||
fixer.registerFix(FixTypes.ENTITY, new EntityArmorAndHeld());
|
||||
fixer.registerFix(FixTypes.BLOCK_ENTITY, new SignStrictJSON());
|
||||
fixer.registerFix(FixTypes.ITEM_INSTANCE, new ItemIntIDToString());
|
||||
fixer.registerFix(FixTypes.ITEM_INSTANCE, new PotionItems());
|
||||
fixer.registerFix(FixTypes.ITEM_INSTANCE, new SpawnEggNames());
|
||||
fixer.registerFix(FixTypes.ENTITY, new MinecartEntityTypes());
|
||||
fixer.registerFix(FixTypes.BLOCK_ENTITY, new SpawnerEntityTypes());
|
||||
fixer.registerFix(FixTypes.ENTITY, new StringToUUID());
|
||||
fixer.registerFix(FixTypes.ENTITY, new EntityHealth());
|
||||
fixer.registerFix(FixTypes.ENTITY, new HorseSaddle());
|
||||
fixer.registerFix(FixTypes.ENTITY, new PaintingDirection());
|
||||
fixer.registerFix(FixTypes.ENTITY, new RedundantChanceTags());
|
||||
fixer.registerFix(FixTypes.ENTITY, new RidingToPassengers());
|
||||
fixer.registerFix(FixTypes.ENTITY, new ArmorStandSilent());
|
||||
fixer.registerFix(FixTypes.ITEM_INSTANCE, new BookPagesStrictJSON());
|
||||
fixer.registerFix(FixTypes.ITEM_INSTANCE, new CookedFishIDTypo());
|
||||
fixer.registerFix(FixTypes.ENTITY, new ZombieProfToType());
|
||||
fixer.registerFix(FixTypes.OPTIONS, new ForceVBOOn());
|
||||
fixer.registerFix(FixTypes.ENTITY, new ElderGuardianSplit());
|
||||
fixer.registerFix(FixTypes.ENTITY, new SkeletonSplit());
|
||||
fixer.registerFix(FixTypes.ENTITY, new ZombieSplit());
|
||||
fixer.registerFix(FixTypes.ENTITY, new HorseSplit());
|
||||
fixer.registerFix(FixTypes.BLOCK_ENTITY, new TileEntityId());
|
||||
fixer.registerFix(FixTypes.ENTITY, new EntityId());
|
||||
fixer.registerFix(FixTypes.ITEM_INSTANCE, new BannerItemColor());
|
||||
fixer.registerFix(FixTypes.ITEM_INSTANCE, new PotionWater());
|
||||
fixer.registerFix(FixTypes.ENTITY, new ShulkerBoxEntityColor());
|
||||
fixer.registerFix(FixTypes.ITEM_INSTANCE, new ShulkerBoxItemColor());
|
||||
fixer.registerFix(FixTypes.BLOCK_ENTITY, new ShulkerBoxTileColor());
|
||||
fixer.registerFix(FixTypes.OPTIONS, new OptionsLowerCaseLanguage());
|
||||
fixer.registerFix(FixTypes.ITEM_INSTANCE, new TotemItemRename());
|
||||
fixer.registerFix(FixTypes.CHUNK, new AddBedTileEntity());
|
||||
fixer.registerFix(FixTypes.ITEM_INSTANCE, new BedItemColor());
|
||||
}
|
||||
|
||||
public static DataFixer createFixer()
|
||||
{
|
||||
DataFixer datafixer = new DataFixer(1343);
|
||||
datafixer = new net.minecraftforge.common.util.CompoundDataFixer(datafixer);
|
||||
WorldInfo.registerFixes(datafixer);
|
||||
EntityPlayerMP.registerFixesPlayerMP(datafixer);
|
||||
EntityPlayer.registerFixesPlayer(datafixer);
|
||||
AnvilChunkLoader.registerFixes(datafixer);
|
||||
ItemStack.registerFixes(datafixer);
|
||||
Template.registerFixes(datafixer);
|
||||
Entity.registerFixes(datafixer);
|
||||
EntityArmorStand.registerFixesArmorStand(datafixer);
|
||||
EntityArrow.registerFixesArrow(datafixer);
|
||||
EntityBat.registerFixesBat(datafixer);
|
||||
EntityBlaze.registerFixesBlaze(datafixer);
|
||||
EntityCaveSpider.registerFixesCaveSpider(datafixer);
|
||||
EntityChicken.registerFixesChicken(datafixer);
|
||||
EntityCow.registerFixesCow(datafixer);
|
||||
EntityCreeper.registerFixesCreeper(datafixer);
|
||||
EntityDonkey.registerFixesDonkey(datafixer);
|
||||
EntityDragonFireball.registerFixesDragonFireball(datafixer);
|
||||
EntityElderGuardian.registerFixesElderGuardian(datafixer);
|
||||
EntityDragon.registerFixesDragon(datafixer);
|
||||
EntityEnderman.registerFixesEnderman(datafixer);
|
||||
EntityEndermite.registerFixesEndermite(datafixer);
|
||||
EntityEvoker.registerFixesEvoker(datafixer);
|
||||
EntityFallingBlock.registerFixesFallingBlock(datafixer);
|
||||
EntityFireworkRocket.registerFixesFireworkRocket(datafixer);
|
||||
EntityGhast.registerFixesGhast(datafixer);
|
||||
EntityGiantZombie.registerFixesGiantZombie(datafixer);
|
||||
EntityGuardian.registerFixesGuardian(datafixer);
|
||||
EntityHorse.registerFixesHorse(datafixer);
|
||||
EntityHusk.registerFixesHusk(datafixer);
|
||||
EntityItem.registerFixesItem(datafixer);
|
||||
EntityItemFrame.registerFixesItemFrame(datafixer);
|
||||
EntityLargeFireball.registerFixesLargeFireball(datafixer);
|
||||
EntityMagmaCube.registerFixesMagmaCube(datafixer);
|
||||
EntityMinecartChest.registerFixesMinecartChest(datafixer);
|
||||
EntityMinecartCommandBlock.registerFixesMinecartCommand(datafixer);
|
||||
EntityMinecartFurnace.registerFixesMinecartFurnace(datafixer);
|
||||
EntityMinecartHopper.registerFixesMinecartHopper(datafixer);
|
||||
EntityMinecartEmpty.registerFixesMinecartEmpty(datafixer);
|
||||
EntityMinecartMobSpawner.registerFixesMinecartMobSpawner(datafixer);
|
||||
EntityMinecartTNT.registerFixesMinecartTNT(datafixer);
|
||||
EntityMule.registerFixesMule(datafixer);
|
||||
EntityMooshroom.registerFixesMooshroom(datafixer);
|
||||
EntityOcelot.registerFixesOcelot(datafixer);
|
||||
EntityPig.registerFixesPig(datafixer);
|
||||
EntityPigZombie.registerFixesPigZombie(datafixer);
|
||||
EntityRabbit.registerFixesRabbit(datafixer);
|
||||
EntitySheep.registerFixesSheep(datafixer);
|
||||
EntityShulker.registerFixesShulker(datafixer);
|
||||
EntitySilverfish.registerFixesSilverfish(datafixer);
|
||||
EntitySkeleton.registerFixesSkeleton(datafixer);
|
||||
EntitySkeletonHorse.registerFixesSkeletonHorse(datafixer);
|
||||
EntitySlime.registerFixesSlime(datafixer);
|
||||
EntitySmallFireball.registerFixesSmallFireball(datafixer);
|
||||
EntitySnowman.registerFixesSnowman(datafixer);
|
||||
EntitySnowball.registerFixesSnowball(datafixer);
|
||||
EntitySpectralArrow.registerFixesSpectralArrow(datafixer);
|
||||
EntitySpider.registerFixesSpider(datafixer);
|
||||
EntitySquid.registerFixesSquid(datafixer);
|
||||
EntityStray.registerFixesStray(datafixer);
|
||||
EntityEgg.registerFixesEgg(datafixer);
|
||||
EntityEnderPearl.registerFixesEnderPearl(datafixer);
|
||||
EntityExpBottle.registerFixesExpBottle(datafixer);
|
||||
EntityPotion.registerFixesPotion(datafixer);
|
||||
EntityTippedArrow.registerFixesTippedArrow(datafixer);
|
||||
EntityVex.registerFixesVex(datafixer);
|
||||
EntityVillager.registerFixesVillager(datafixer);
|
||||
EntityIronGolem.registerFixesIronGolem(datafixer);
|
||||
EntityVindicator.registerFixesVindicator(datafixer);
|
||||
EntityWitch.registerFixesWitch(datafixer);
|
||||
EntityWither.registerFixesWither(datafixer);
|
||||
EntityWitherSkeleton.registerFixesWitherSkeleton(datafixer);
|
||||
EntityWitherSkull.registerFixesWitherSkull(datafixer);
|
||||
EntityWolf.registerFixesWolf(datafixer);
|
||||
EntityZombie.registerFixesZombie(datafixer);
|
||||
EntityZombieHorse.registerFixesZombieHorse(datafixer);
|
||||
EntityZombieVillager.registerFixesZombieVillager(datafixer);
|
||||
TileEntityPiston.registerFixesPiston(datafixer);
|
||||
TileEntityFlowerPot.registerFixesFlowerPot(datafixer);
|
||||
TileEntityFurnace.registerFixesFurnace(datafixer);
|
||||
TileEntityChest.registerFixesChest(datafixer);
|
||||
TileEntityDispenser.registerFixes(datafixer);
|
||||
TileEntityDropper.registerFixesDropper(datafixer);
|
||||
TileEntityBrewingStand.registerFixesBrewingStand(datafixer);
|
||||
TileEntityHopper.registerFixesHopper(datafixer);
|
||||
BlockJukebox.registerFixesJukebox(datafixer);
|
||||
TileEntityMobSpawner.registerFixesMobSpawner(datafixer);
|
||||
TileEntityShulkerBox.registerFixesShulkerBox(datafixer);
|
||||
registerFixes(datafixer);
|
||||
return datafixer;
|
||||
}
|
||||
|
||||
public static NBTTagCompound processItemStack(IDataFixer fixer, NBTTagCompound compound, int version, String key)
|
||||
{
|
||||
if (compound.hasKey(key, 10))
|
||||
{
|
||||
compound.setTag(key, fixer.process(FixTypes.ITEM_INSTANCE, compound.getCompoundTag(key), version));
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
public static NBTTagCompound processInventory(IDataFixer fixer, NBTTagCompound compound, int version, String key)
|
||||
{
|
||||
if (compound.hasKey(key, 9))
|
||||
{
|
||||
NBTTagList nbttaglist = compound.getTagList(key, 10);
|
||||
|
||||
for (int i = 0; i < nbttaglist.tagCount(); ++i)
|
||||
{
|
||||
nbttaglist.set(i, fixer.process(FixTypes.ITEM_INSTANCE, nbttaglist.getCompoundTagAt(i), version));
|
||||
}
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.minecraft.util.datafix;
|
||||
|
||||
public enum FixTypes implements IFixType
|
||||
{
|
||||
LEVEL,
|
||||
PLAYER,
|
||||
CHUNK,
|
||||
BLOCK_ENTITY,
|
||||
ENTITY,
|
||||
ITEM_INSTANCE,
|
||||
OPTIONS,
|
||||
STRUCTURE;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package net.minecraft.util.datafix;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public interface IDataFixer
|
||||
{
|
||||
NBTTagCompound process(IFixType type, NBTTagCompound compound, int versionIn);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package net.minecraft.util.datafix;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public interface IDataWalker
|
||||
{
|
||||
NBTTagCompound process(IDataFixer fixer, NBTTagCompound compound, int versionIn);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package net.minecraft.util.datafix;
|
||||
|
||||
public interface IFixType
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.minecraft.util.datafix;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public interface IFixableData
|
||||
{
|
||||
int getFixVersion();
|
||||
|
||||
NBTTagCompound fixTagCompound(NBTTagCompound compound);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class AddBedTileEntity implements IFixableData
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 1125;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
int i = 416;
|
||||
|
||||
try
|
||||
{
|
||||
NBTTagCompound nbttagcompound = compound.getCompoundTag("Level");
|
||||
int j = nbttagcompound.getInteger("xPos");
|
||||
int k = nbttagcompound.getInteger("zPos");
|
||||
NBTTagList nbttaglist = nbttagcompound.getTagList("TileEntities", 10);
|
||||
NBTTagList nbttaglist1 = nbttagcompound.getTagList("Sections", 10);
|
||||
|
||||
for (int l = 0; l < nbttaglist1.tagCount(); ++l)
|
||||
{
|
||||
NBTTagCompound nbttagcompound1 = nbttaglist1.getCompoundTagAt(l);
|
||||
int i1 = nbttagcompound1.getByte("Y");
|
||||
byte[] abyte = nbttagcompound1.getByteArray("Blocks");
|
||||
|
||||
for (int j1 = 0; j1 < abyte.length; ++j1)
|
||||
{
|
||||
if (416 == (abyte[j1] & 255) << 4)
|
||||
{
|
||||
int k1 = j1 & 15;
|
||||
int l1 = j1 >> 8 & 15;
|
||||
int i2 = j1 >> 4 & 15;
|
||||
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
|
||||
nbttagcompound2.setString("id", "bed");
|
||||
nbttagcompound2.setInteger("x", k1 + (j << 4));
|
||||
nbttagcompound2.setInteger("y", l1 + (i1 << 4));
|
||||
nbttagcompound2.setInteger("z", i2 + (k << 4));
|
||||
nbttaglist.appendTag(nbttagcompound2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception var17)
|
||||
{
|
||||
LOGGER.warn("Unable to datafix Bed blocks, level format may be missing tags.");
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class ArmorStandSilent implements IFixableData
|
||||
{
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 147;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
if ("ArmorStand".equals(compound.getString("id")) && compound.getBoolean("Silent") && !compound.getBoolean("Marker"))
|
||||
{
|
||||
compound.removeTag("Silent");
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class BannerItemColor implements IFixableData
|
||||
{
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 804;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
if ("minecraft:banner".equals(compound.getString("id")) && compound.hasKey("tag", 10))
|
||||
{
|
||||
NBTTagCompound nbttagcompound = compound.getCompoundTag("tag");
|
||||
|
||||
if (nbttagcompound.hasKey("BlockEntityTag", 10))
|
||||
{
|
||||
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("BlockEntityTag");
|
||||
|
||||
if (nbttagcompound1.hasKey("Base", 99))
|
||||
{
|
||||
compound.setShort("Damage", (short)(nbttagcompound1.getShort("Base") & 15));
|
||||
|
||||
if (nbttagcompound.hasKey("display", 10))
|
||||
{
|
||||
NBTTagCompound nbttagcompound2 = nbttagcompound.getCompoundTag("display");
|
||||
|
||||
if (nbttagcompound2.hasKey("Lore", 9))
|
||||
{
|
||||
NBTTagList nbttaglist = nbttagcompound2.getTagList("Lore", 8);
|
||||
|
||||
if (nbttaglist.tagCount() == 1 && "(+NBT)".equals(nbttaglist.getStringTagAt(0)))
|
||||
{
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nbttagcompound1.removeTag("Base");
|
||||
|
||||
if (nbttagcompound1.hasNoTags())
|
||||
{
|
||||
nbttagcompound.removeTag("BlockEntityTag");
|
||||
}
|
||||
|
||||
if (nbttagcompound.hasNoTags())
|
||||
{
|
||||
compound.removeTag("tag");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class BedItemColor implements IFixableData
|
||||
{
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 1125;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
if ("minecraft:bed".equals(compound.getString("id")) && compound.getShort("Damage") == 0)
|
||||
{
|
||||
compound.setShort("Damage", (short)EnumDyeColor.RED.getMetadata());
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import com.google.gson.JsonParseException;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraft.util.StringUtils;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
|
||||
public class BookPagesStrictJSON implements IFixableData
|
||||
{
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 165;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
if ("minecraft:written_book".equals(compound.getString("id")))
|
||||
{
|
||||
NBTTagCompound nbttagcompound = compound.getCompoundTag("tag");
|
||||
|
||||
if (nbttagcompound.hasKey("pages", 9))
|
||||
{
|
||||
NBTTagList nbttaglist = nbttagcompound.getTagList("pages", 8);
|
||||
|
||||
for (int i = 0; i < nbttaglist.tagCount(); ++i)
|
||||
{
|
||||
String s = nbttaglist.getStringTagAt(i);
|
||||
ITextComponent itextcomponent = null;
|
||||
|
||||
if (!"null".equals(s) && !StringUtils.isNullOrEmpty(s))
|
||||
{
|
||||
if (s.charAt(0) == '"' && s.charAt(s.length() - 1) == '"' || s.charAt(0) == '{' && s.charAt(s.length() - 1) == '}')
|
||||
{
|
||||
try
|
||||
{
|
||||
itextcomponent = (ITextComponent)JsonUtils.gsonDeserialize(SignStrictJSON.GSON_INSTANCE, s, ITextComponent.class, true);
|
||||
|
||||
if (itextcomponent == null)
|
||||
{
|
||||
itextcomponent = new TextComponentString("");
|
||||
}
|
||||
}
|
||||
catch (JsonParseException var10)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
if (itextcomponent == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
itextcomponent = ITextComponent.Serializer.jsonToComponent(s);
|
||||
}
|
||||
catch (JsonParseException var9)
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if (itextcomponent == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
itextcomponent = ITextComponent.Serializer.fromJsonLenient(s);
|
||||
}
|
||||
catch (JsonParseException var8)
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if (itextcomponent == null)
|
||||
{
|
||||
itextcomponent = new TextComponentString(s);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
itextcomponent = new TextComponentString(s);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
itextcomponent = new TextComponentString("");
|
||||
}
|
||||
|
||||
nbttaglist.set(i, new NBTTagString(ITextComponent.Serializer.componentToJson(itextcomponent)));
|
||||
}
|
||||
|
||||
nbttagcompound.setTag("pages", nbttaglist);
|
||||
}
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class CookedFishIDTypo implements IFixableData
|
||||
{
|
||||
private static final ResourceLocation WRONG = new ResourceLocation("cooked_fished");
|
||||
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 502;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
if (compound.hasKey("id", 8) && WRONG.equals(new ResourceLocation(compound.getString("id"))))
|
||||
{
|
||||
compound.setString("id", "minecraft:cooked_fish");
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class ElderGuardianSplit implements IFixableData
|
||||
{
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 700;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
if ("Guardian".equals(compound.getString("id")))
|
||||
{
|
||||
if (compound.getBoolean("Elder"))
|
||||
{
|
||||
compound.setString("id", "ElderGuardian");
|
||||
}
|
||||
|
||||
compound.removeTag("Elder");
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagFloat;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class EntityArmorAndHeld implements IFixableData
|
||||
{
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
NBTTagList nbttaglist = compound.getTagList("Equipment", 10);
|
||||
|
||||
if (!nbttaglist.hasNoTags() && !compound.hasKey("HandItems", 10))
|
||||
{
|
||||
NBTTagList nbttaglist1 = new NBTTagList();
|
||||
nbttaglist1.appendTag(nbttaglist.get(0));
|
||||
nbttaglist1.appendTag(new NBTTagCompound());
|
||||
compound.setTag("HandItems", nbttaglist1);
|
||||
}
|
||||
|
||||
if (nbttaglist.tagCount() > 1 && !compound.hasKey("ArmorItem", 10))
|
||||
{
|
||||
NBTTagList nbttaglist3 = new NBTTagList();
|
||||
nbttaglist3.appendTag(nbttaglist.getCompoundTagAt(1));
|
||||
nbttaglist3.appendTag(nbttaglist.getCompoundTagAt(2));
|
||||
nbttaglist3.appendTag(nbttaglist.getCompoundTagAt(3));
|
||||
nbttaglist3.appendTag(nbttaglist.getCompoundTagAt(4));
|
||||
compound.setTag("ArmorItems", nbttaglist3);
|
||||
}
|
||||
|
||||
compound.removeTag("Equipment");
|
||||
|
||||
if (compound.hasKey("DropChances", 9))
|
||||
{
|
||||
NBTTagList nbttaglist4 = compound.getTagList("DropChances", 5);
|
||||
|
||||
if (!compound.hasKey("HandDropChances", 10))
|
||||
{
|
||||
NBTTagList nbttaglist2 = new NBTTagList();
|
||||
nbttaglist2.appendTag(new NBTTagFloat(nbttaglist4.getFloatAt(0)));
|
||||
nbttaglist2.appendTag(new NBTTagFloat(0.0F));
|
||||
compound.setTag("HandDropChances", nbttaglist2);
|
||||
}
|
||||
|
||||
if (!compound.hasKey("ArmorDropChances", 10))
|
||||
{
|
||||
NBTTagList nbttaglist5 = new NBTTagList();
|
||||
nbttaglist5.appendTag(new NBTTagFloat(nbttaglist4.getFloatAt(1)));
|
||||
nbttaglist5.appendTag(new NBTTagFloat(nbttaglist4.getFloatAt(2)));
|
||||
nbttaglist5.appendTag(new NBTTagFloat(nbttaglist4.getFloatAt(3)));
|
||||
nbttaglist5.appendTag(new NBTTagFloat(nbttaglist4.getFloatAt(4)));
|
||||
compound.setTag("ArmorDropChances", nbttaglist5);
|
||||
}
|
||||
|
||||
compound.removeTag("DropChances");
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import java.util.Set;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class EntityHealth implements IFixableData
|
||||
{
|
||||
private static final Set<String> ENTITY_LIST = Sets.newHashSet("ArmorStand", "Bat", "Blaze", "CaveSpider", "Chicken", "Cow", "Creeper", "EnderDragon", "Enderman", "Endermite", "EntityHorse", "Ghast", "Giant", "Guardian", "LavaSlime", "MushroomCow", "Ozelot", "Pig", "PigZombie", "Rabbit", "Sheep", "Shulker", "Silverfish", "Skeleton", "Slime", "SnowMan", "Spider", "Squid", "Villager", "VillagerGolem", "Witch", "WitherBoss", "Wolf", "Zombie");
|
||||
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 109;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
if (ENTITY_LIST.contains(compound.getString("id")))
|
||||
{
|
||||
float f;
|
||||
|
||||
if (compound.hasKey("HealF", 99))
|
||||
{
|
||||
f = compound.getFloat("HealF");
|
||||
compound.removeTag("HealF");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!compound.hasKey("Health", 99))
|
||||
{
|
||||
return compound;
|
||||
}
|
||||
|
||||
f = compound.getFloat("Health");
|
||||
}
|
||||
|
||||
compound.setFloat("Health", f);
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.Map;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class EntityId implements IFixableData
|
||||
{
|
||||
private static final Map<String, String> OLD_TO_NEW_ID_MAP = Maps.<String, String>newHashMap();
|
||||
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 704;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
String s = OLD_TO_NEW_ID_MAP.get(compound.getString("id"));
|
||||
|
||||
if (s != null)
|
||||
{
|
||||
compound.setString("id", s);
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
OLD_TO_NEW_ID_MAP.put("AreaEffectCloud", "minecraft:area_effect_cloud");
|
||||
OLD_TO_NEW_ID_MAP.put("ArmorStand", "minecraft:armor_stand");
|
||||
OLD_TO_NEW_ID_MAP.put("Arrow", "minecraft:arrow");
|
||||
OLD_TO_NEW_ID_MAP.put("Bat", "minecraft:bat");
|
||||
OLD_TO_NEW_ID_MAP.put("Blaze", "minecraft:blaze");
|
||||
OLD_TO_NEW_ID_MAP.put("Boat", "minecraft:boat");
|
||||
OLD_TO_NEW_ID_MAP.put("CaveSpider", "minecraft:cave_spider");
|
||||
OLD_TO_NEW_ID_MAP.put("Chicken", "minecraft:chicken");
|
||||
OLD_TO_NEW_ID_MAP.put("Cow", "minecraft:cow");
|
||||
OLD_TO_NEW_ID_MAP.put("Creeper", "minecraft:creeper");
|
||||
OLD_TO_NEW_ID_MAP.put("Donkey", "minecraft:donkey");
|
||||
OLD_TO_NEW_ID_MAP.put("DragonFireball", "minecraft:dragon_fireball");
|
||||
OLD_TO_NEW_ID_MAP.put("ElderGuardian", "minecraft:elder_guardian");
|
||||
OLD_TO_NEW_ID_MAP.put("EnderCrystal", "minecraft:ender_crystal");
|
||||
OLD_TO_NEW_ID_MAP.put("EnderDragon", "minecraft:ender_dragon");
|
||||
OLD_TO_NEW_ID_MAP.put("Enderman", "minecraft:enderman");
|
||||
OLD_TO_NEW_ID_MAP.put("Endermite", "minecraft:endermite");
|
||||
OLD_TO_NEW_ID_MAP.put("EyeOfEnderSignal", "minecraft:eye_of_ender_signal");
|
||||
OLD_TO_NEW_ID_MAP.put("FallingSand", "minecraft:falling_block");
|
||||
OLD_TO_NEW_ID_MAP.put("Fireball", "minecraft:fireball");
|
||||
OLD_TO_NEW_ID_MAP.put("FireworksRocketEntity", "minecraft:fireworks_rocket");
|
||||
OLD_TO_NEW_ID_MAP.put("Ghast", "minecraft:ghast");
|
||||
OLD_TO_NEW_ID_MAP.put("Giant", "minecraft:giant");
|
||||
OLD_TO_NEW_ID_MAP.put("Guardian", "minecraft:guardian");
|
||||
OLD_TO_NEW_ID_MAP.put("Horse", "minecraft:horse");
|
||||
OLD_TO_NEW_ID_MAP.put("Husk", "minecraft:husk");
|
||||
OLD_TO_NEW_ID_MAP.put("Item", "minecraft:item");
|
||||
OLD_TO_NEW_ID_MAP.put("ItemFrame", "minecraft:item_frame");
|
||||
OLD_TO_NEW_ID_MAP.put("LavaSlime", "minecraft:magma_cube");
|
||||
OLD_TO_NEW_ID_MAP.put("LeashKnot", "minecraft:leash_knot");
|
||||
OLD_TO_NEW_ID_MAP.put("MinecartChest", "minecraft:chest_minecart");
|
||||
OLD_TO_NEW_ID_MAP.put("MinecartCommandBlock", "minecraft:commandblock_minecart");
|
||||
OLD_TO_NEW_ID_MAP.put("MinecartFurnace", "minecraft:furnace_minecart");
|
||||
OLD_TO_NEW_ID_MAP.put("MinecartHopper", "minecraft:hopper_minecart");
|
||||
OLD_TO_NEW_ID_MAP.put("MinecartRideable", "minecraft:minecart");
|
||||
OLD_TO_NEW_ID_MAP.put("MinecartSpawner", "minecraft:spawner_minecart");
|
||||
OLD_TO_NEW_ID_MAP.put("MinecartTNT", "minecraft:tnt_minecart");
|
||||
OLD_TO_NEW_ID_MAP.put("Mule", "minecraft:mule");
|
||||
OLD_TO_NEW_ID_MAP.put("MushroomCow", "minecraft:mooshroom");
|
||||
OLD_TO_NEW_ID_MAP.put("Ozelot", "minecraft:ocelot");
|
||||
OLD_TO_NEW_ID_MAP.put("Painting", "minecraft:painting");
|
||||
OLD_TO_NEW_ID_MAP.put("Pig", "minecraft:pig");
|
||||
OLD_TO_NEW_ID_MAP.put("PigZombie", "minecraft:zombie_pigman");
|
||||
OLD_TO_NEW_ID_MAP.put("PolarBear", "minecraft:polar_bear");
|
||||
OLD_TO_NEW_ID_MAP.put("PrimedTnt", "minecraft:tnt");
|
||||
OLD_TO_NEW_ID_MAP.put("Rabbit", "minecraft:rabbit");
|
||||
OLD_TO_NEW_ID_MAP.put("Sheep", "minecraft:sheep");
|
||||
OLD_TO_NEW_ID_MAP.put("Shulker", "minecraft:shulker");
|
||||
OLD_TO_NEW_ID_MAP.put("ShulkerBullet", "minecraft:shulker_bullet");
|
||||
OLD_TO_NEW_ID_MAP.put("Silverfish", "minecraft:silverfish");
|
||||
OLD_TO_NEW_ID_MAP.put("Skeleton", "minecraft:skeleton");
|
||||
OLD_TO_NEW_ID_MAP.put("SkeletonHorse", "minecraft:skeleton_horse");
|
||||
OLD_TO_NEW_ID_MAP.put("Slime", "minecraft:slime");
|
||||
OLD_TO_NEW_ID_MAP.put("SmallFireball", "minecraft:small_fireball");
|
||||
OLD_TO_NEW_ID_MAP.put("SnowMan", "minecraft:snowman");
|
||||
OLD_TO_NEW_ID_MAP.put("Snowball", "minecraft:snowball");
|
||||
OLD_TO_NEW_ID_MAP.put("SpectralArrow", "minecraft:spectral_arrow");
|
||||
OLD_TO_NEW_ID_MAP.put("Spider", "minecraft:spider");
|
||||
OLD_TO_NEW_ID_MAP.put("Squid", "minecraft:squid");
|
||||
OLD_TO_NEW_ID_MAP.put("Stray", "minecraft:stray");
|
||||
OLD_TO_NEW_ID_MAP.put("ThrownEgg", "minecraft:egg");
|
||||
OLD_TO_NEW_ID_MAP.put("ThrownEnderpearl", "minecraft:ender_pearl");
|
||||
OLD_TO_NEW_ID_MAP.put("ThrownExpBottle", "minecraft:xp_bottle");
|
||||
OLD_TO_NEW_ID_MAP.put("ThrownPotion", "minecraft:potion");
|
||||
OLD_TO_NEW_ID_MAP.put("Villager", "minecraft:villager");
|
||||
OLD_TO_NEW_ID_MAP.put("VillagerGolem", "minecraft:villager_golem");
|
||||
OLD_TO_NEW_ID_MAP.put("Witch", "minecraft:witch");
|
||||
OLD_TO_NEW_ID_MAP.put("WitherBoss", "minecraft:wither");
|
||||
OLD_TO_NEW_ID_MAP.put("WitherSkeleton", "minecraft:wither_skeleton");
|
||||
OLD_TO_NEW_ID_MAP.put("WitherSkull", "minecraft:wither_skull");
|
||||
OLD_TO_NEW_ID_MAP.put("Wolf", "minecraft:wolf");
|
||||
OLD_TO_NEW_ID_MAP.put("XPOrb", "minecraft:xp_orb");
|
||||
OLD_TO_NEW_ID_MAP.put("Zombie", "minecraft:zombie");
|
||||
OLD_TO_NEW_ID_MAP.put("ZombieHorse", "minecraft:zombie_horse");
|
||||
OLD_TO_NEW_ID_MAP.put("ZombieVillager", "minecraft:zombie_villager");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class ForceVBOOn implements IFixableData
|
||||
{
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 505;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
compound.setString("useVbo", "true");
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class HorseSaddle implements IFixableData
|
||||
{
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 110;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
if ("EntityHorse".equals(compound.getString("id")) && !compound.hasKey("SaddleItem", 10) && compound.getBoolean("Saddle"))
|
||||
{
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setString("id", "minecraft:saddle");
|
||||
nbttagcompound.setByte("Count", (byte)1);
|
||||
nbttagcompound.setShort("Damage", (short)0);
|
||||
compound.setTag("SaddleItem", nbttagcompound);
|
||||
compound.removeTag("Saddle");
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class HorseSplit implements IFixableData
|
||||
{
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 703;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
if ("EntityHorse".equals(compound.getString("id")))
|
||||
{
|
||||
int i = compound.getInteger("Type");
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
default:
|
||||
compound.setString("id", "Horse");
|
||||
break;
|
||||
case 1:
|
||||
compound.setString("id", "Donkey");
|
||||
break;
|
||||
case 2:
|
||||
compound.setString("id", "Mule");
|
||||
break;
|
||||
case 3:
|
||||
compound.setString("id", "ZombieHorse");
|
||||
break;
|
||||
case 4:
|
||||
compound.setString("id", "SkeletonHorse");
|
||||
}
|
||||
|
||||
compound.removeTag("Type");
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,348 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class ItemIntIDToString implements IFixableData
|
||||
{
|
||||
private static final String[] ID_MAP = new String[2268];
|
||||
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 102;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
if (compound.hasKey("id", 99))
|
||||
{
|
||||
short short1 = compound.getShort("id");
|
||||
|
||||
if (short1 > 0 && short1 < ID_MAP.length && ID_MAP[short1] != null)
|
||||
{
|
||||
compound.setString("id", ID_MAP[short1]);
|
||||
}
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
ID_MAP[1] = "minecraft:stone";
|
||||
ID_MAP[2] = "minecraft:grass";
|
||||
ID_MAP[3] = "minecraft:dirt";
|
||||
ID_MAP[4] = "minecraft:cobblestone";
|
||||
ID_MAP[5] = "minecraft:planks";
|
||||
ID_MAP[6] = "minecraft:sapling";
|
||||
ID_MAP[7] = "minecraft:bedrock";
|
||||
ID_MAP[8] = "minecraft:flowing_water";
|
||||
ID_MAP[9] = "minecraft:water";
|
||||
ID_MAP[10] = "minecraft:flowing_lava";
|
||||
ID_MAP[11] = "minecraft:lava";
|
||||
ID_MAP[12] = "minecraft:sand";
|
||||
ID_MAP[13] = "minecraft:gravel";
|
||||
ID_MAP[14] = "minecraft:gold_ore";
|
||||
ID_MAP[15] = "minecraft:iron_ore";
|
||||
ID_MAP[16] = "minecraft:coal_ore";
|
||||
ID_MAP[17] = "minecraft:log";
|
||||
ID_MAP[18] = "minecraft:leaves";
|
||||
ID_MAP[19] = "minecraft:sponge";
|
||||
ID_MAP[20] = "minecraft:glass";
|
||||
ID_MAP[21] = "minecraft:lapis_ore";
|
||||
ID_MAP[22] = "minecraft:lapis_block";
|
||||
ID_MAP[23] = "minecraft:dispenser";
|
||||
ID_MAP[24] = "minecraft:sandstone";
|
||||
ID_MAP[25] = "minecraft:noteblock";
|
||||
ID_MAP[27] = "minecraft:golden_rail";
|
||||
ID_MAP[28] = "minecraft:detector_rail";
|
||||
ID_MAP[29] = "minecraft:sticky_piston";
|
||||
ID_MAP[30] = "minecraft:web";
|
||||
ID_MAP[31] = "minecraft:tallgrass";
|
||||
ID_MAP[32] = "minecraft:deadbush";
|
||||
ID_MAP[33] = "minecraft:piston";
|
||||
ID_MAP[35] = "minecraft:wool";
|
||||
ID_MAP[37] = "minecraft:yellow_flower";
|
||||
ID_MAP[38] = "minecraft:red_flower";
|
||||
ID_MAP[39] = "minecraft:brown_mushroom";
|
||||
ID_MAP[40] = "minecraft:red_mushroom";
|
||||
ID_MAP[41] = "minecraft:gold_block";
|
||||
ID_MAP[42] = "minecraft:iron_block";
|
||||
ID_MAP[43] = "minecraft:double_stone_slab";
|
||||
ID_MAP[44] = "minecraft:stone_slab";
|
||||
ID_MAP[45] = "minecraft:brick_block";
|
||||
ID_MAP[46] = "minecraft:tnt";
|
||||
ID_MAP[47] = "minecraft:bookshelf";
|
||||
ID_MAP[48] = "minecraft:mossy_cobblestone";
|
||||
ID_MAP[49] = "minecraft:obsidian";
|
||||
ID_MAP[50] = "minecraft:torch";
|
||||
ID_MAP[51] = "minecraft:fire";
|
||||
ID_MAP[52] = "minecraft:mob_spawner";
|
||||
ID_MAP[53] = "minecraft:oak_stairs";
|
||||
ID_MAP[54] = "minecraft:chest";
|
||||
ID_MAP[56] = "minecraft:diamond_ore";
|
||||
ID_MAP[57] = "minecraft:diamond_block";
|
||||
ID_MAP[58] = "minecraft:crafting_table";
|
||||
ID_MAP[60] = "minecraft:farmland";
|
||||
ID_MAP[61] = "minecraft:furnace";
|
||||
ID_MAP[62] = "minecraft:lit_furnace";
|
||||
ID_MAP[65] = "minecraft:ladder";
|
||||
ID_MAP[66] = "minecraft:rail";
|
||||
ID_MAP[67] = "minecraft:stone_stairs";
|
||||
ID_MAP[69] = "minecraft:lever";
|
||||
ID_MAP[70] = "minecraft:stone_pressure_plate";
|
||||
ID_MAP[72] = "minecraft:wooden_pressure_plate";
|
||||
ID_MAP[73] = "minecraft:redstone_ore";
|
||||
ID_MAP[76] = "minecraft:redstone_torch";
|
||||
ID_MAP[77] = "minecraft:stone_button";
|
||||
ID_MAP[78] = "minecraft:snow_layer";
|
||||
ID_MAP[79] = "minecraft:ice";
|
||||
ID_MAP[80] = "minecraft:snow";
|
||||
ID_MAP[81] = "minecraft:cactus";
|
||||
ID_MAP[82] = "minecraft:clay";
|
||||
ID_MAP[84] = "minecraft:jukebox";
|
||||
ID_MAP[85] = "minecraft:fence";
|
||||
ID_MAP[86] = "minecraft:pumpkin";
|
||||
ID_MAP[87] = "minecraft:netherrack";
|
||||
ID_MAP[88] = "minecraft:soul_sand";
|
||||
ID_MAP[89] = "minecraft:glowstone";
|
||||
ID_MAP[90] = "minecraft:portal";
|
||||
ID_MAP[91] = "minecraft:lit_pumpkin";
|
||||
ID_MAP[95] = "minecraft:stained_glass";
|
||||
ID_MAP[96] = "minecraft:trapdoor";
|
||||
ID_MAP[97] = "minecraft:monster_egg";
|
||||
ID_MAP[98] = "minecraft:stonebrick";
|
||||
ID_MAP[99] = "minecraft:brown_mushroom_block";
|
||||
ID_MAP[100] = "minecraft:red_mushroom_block";
|
||||
ID_MAP[101] = "minecraft:iron_bars";
|
||||
ID_MAP[102] = "minecraft:glass_pane";
|
||||
ID_MAP[103] = "minecraft:melon_block";
|
||||
ID_MAP[106] = "minecraft:vine";
|
||||
ID_MAP[107] = "minecraft:fence_gate";
|
||||
ID_MAP[108] = "minecraft:brick_stairs";
|
||||
ID_MAP[109] = "minecraft:stone_brick_stairs";
|
||||
ID_MAP[110] = "minecraft:mycelium";
|
||||
ID_MAP[111] = "minecraft:waterlily";
|
||||
ID_MAP[112] = "minecraft:nether_brick";
|
||||
ID_MAP[113] = "minecraft:nether_brick_fence";
|
||||
ID_MAP[114] = "minecraft:nether_brick_stairs";
|
||||
ID_MAP[116] = "minecraft:enchanting_table";
|
||||
ID_MAP[119] = "minecraft:end_portal";
|
||||
ID_MAP[120] = "minecraft:end_portal_frame";
|
||||
ID_MAP[121] = "minecraft:end_stone";
|
||||
ID_MAP[122] = "minecraft:dragon_egg";
|
||||
ID_MAP[123] = "minecraft:redstone_lamp";
|
||||
ID_MAP[125] = "minecraft:double_wooden_slab";
|
||||
ID_MAP[126] = "minecraft:wooden_slab";
|
||||
ID_MAP[127] = "minecraft:cocoa";
|
||||
ID_MAP[128] = "minecraft:sandstone_stairs";
|
||||
ID_MAP[129] = "minecraft:emerald_ore";
|
||||
ID_MAP[130] = "minecraft:ender_chest";
|
||||
ID_MAP[131] = "minecraft:tripwire_hook";
|
||||
ID_MAP[133] = "minecraft:emerald_block";
|
||||
ID_MAP[134] = "minecraft:spruce_stairs";
|
||||
ID_MAP[135] = "minecraft:birch_stairs";
|
||||
ID_MAP[136] = "minecraft:jungle_stairs";
|
||||
ID_MAP[137] = "minecraft:command_block";
|
||||
ID_MAP[138] = "minecraft:beacon";
|
||||
ID_MAP[139] = "minecraft:cobblestone_wall";
|
||||
ID_MAP[141] = "minecraft:carrots";
|
||||
ID_MAP[142] = "minecraft:potatoes";
|
||||
ID_MAP[143] = "minecraft:wooden_button";
|
||||
ID_MAP[145] = "minecraft:anvil";
|
||||
ID_MAP[146] = "minecraft:trapped_chest";
|
||||
ID_MAP[147] = "minecraft:light_weighted_pressure_plate";
|
||||
ID_MAP[148] = "minecraft:heavy_weighted_pressure_plate";
|
||||
ID_MAP[151] = "minecraft:daylight_detector";
|
||||
ID_MAP[152] = "minecraft:redstone_block";
|
||||
ID_MAP[153] = "minecraft:quartz_ore";
|
||||
ID_MAP[154] = "minecraft:hopper";
|
||||
ID_MAP[155] = "minecraft:quartz_block";
|
||||
ID_MAP[156] = "minecraft:quartz_stairs";
|
||||
ID_MAP[157] = "minecraft:activator_rail";
|
||||
ID_MAP[158] = "minecraft:dropper";
|
||||
ID_MAP[159] = "minecraft:stained_hardened_clay";
|
||||
ID_MAP[160] = "minecraft:stained_glass_pane";
|
||||
ID_MAP[161] = "minecraft:leaves2";
|
||||
ID_MAP[162] = "minecraft:log2";
|
||||
ID_MAP[163] = "minecraft:acacia_stairs";
|
||||
ID_MAP[164] = "minecraft:dark_oak_stairs";
|
||||
ID_MAP[170] = "minecraft:hay_block";
|
||||
ID_MAP[171] = "minecraft:carpet";
|
||||
ID_MAP[172] = "minecraft:hardened_clay";
|
||||
ID_MAP[173] = "minecraft:coal_block";
|
||||
ID_MAP[174] = "minecraft:packed_ice";
|
||||
ID_MAP[175] = "minecraft:double_plant";
|
||||
ID_MAP[256] = "minecraft:iron_shovel";
|
||||
ID_MAP[257] = "minecraft:iron_pickaxe";
|
||||
ID_MAP[258] = "minecraft:iron_axe";
|
||||
ID_MAP[259] = "minecraft:flint_and_steel";
|
||||
ID_MAP[260] = "minecraft:apple";
|
||||
ID_MAP[261] = "minecraft:bow";
|
||||
ID_MAP[262] = "minecraft:arrow";
|
||||
ID_MAP[263] = "minecraft:coal";
|
||||
ID_MAP[264] = "minecraft:diamond";
|
||||
ID_MAP[265] = "minecraft:iron_ingot";
|
||||
ID_MAP[266] = "minecraft:gold_ingot";
|
||||
ID_MAP[267] = "minecraft:iron_sword";
|
||||
ID_MAP[268] = "minecraft:wooden_sword";
|
||||
ID_MAP[269] = "minecraft:wooden_shovel";
|
||||
ID_MAP[270] = "minecraft:wooden_pickaxe";
|
||||
ID_MAP[271] = "minecraft:wooden_axe";
|
||||
ID_MAP[272] = "minecraft:stone_sword";
|
||||
ID_MAP[273] = "minecraft:stone_shovel";
|
||||
ID_MAP[274] = "minecraft:stone_pickaxe";
|
||||
ID_MAP[275] = "minecraft:stone_axe";
|
||||
ID_MAP[276] = "minecraft:diamond_sword";
|
||||
ID_MAP[277] = "minecraft:diamond_shovel";
|
||||
ID_MAP[278] = "minecraft:diamond_pickaxe";
|
||||
ID_MAP[279] = "minecraft:diamond_axe";
|
||||
ID_MAP[280] = "minecraft:stick";
|
||||
ID_MAP[281] = "minecraft:bowl";
|
||||
ID_MAP[282] = "minecraft:mushroom_stew";
|
||||
ID_MAP[283] = "minecraft:golden_sword";
|
||||
ID_MAP[284] = "minecraft:golden_shovel";
|
||||
ID_MAP[285] = "minecraft:golden_pickaxe";
|
||||
ID_MAP[286] = "minecraft:golden_axe";
|
||||
ID_MAP[287] = "minecraft:string";
|
||||
ID_MAP[288] = "minecraft:feather";
|
||||
ID_MAP[289] = "minecraft:gunpowder";
|
||||
ID_MAP[290] = "minecraft:wooden_hoe";
|
||||
ID_MAP[291] = "minecraft:stone_hoe";
|
||||
ID_MAP[292] = "minecraft:iron_hoe";
|
||||
ID_MAP[293] = "minecraft:diamond_hoe";
|
||||
ID_MAP[294] = "minecraft:golden_hoe";
|
||||
ID_MAP[295] = "minecraft:wheat_seeds";
|
||||
ID_MAP[296] = "minecraft:wheat";
|
||||
ID_MAP[297] = "minecraft:bread";
|
||||
ID_MAP[298] = "minecraft:leather_helmet";
|
||||
ID_MAP[299] = "minecraft:leather_chestplate";
|
||||
ID_MAP[300] = "minecraft:leather_leggings";
|
||||
ID_MAP[301] = "minecraft:leather_boots";
|
||||
ID_MAP[302] = "minecraft:chainmail_helmet";
|
||||
ID_MAP[303] = "minecraft:chainmail_chestplate";
|
||||
ID_MAP[304] = "minecraft:chainmail_leggings";
|
||||
ID_MAP[305] = "minecraft:chainmail_boots";
|
||||
ID_MAP[306] = "minecraft:iron_helmet";
|
||||
ID_MAP[307] = "minecraft:iron_chestplate";
|
||||
ID_MAP[308] = "minecraft:iron_leggings";
|
||||
ID_MAP[309] = "minecraft:iron_boots";
|
||||
ID_MAP[310] = "minecraft:diamond_helmet";
|
||||
ID_MAP[311] = "minecraft:diamond_chestplate";
|
||||
ID_MAP[312] = "minecraft:diamond_leggings";
|
||||
ID_MAP[313] = "minecraft:diamond_boots";
|
||||
ID_MAP[314] = "minecraft:golden_helmet";
|
||||
ID_MAP[315] = "minecraft:golden_chestplate";
|
||||
ID_MAP[316] = "minecraft:golden_leggings";
|
||||
ID_MAP[317] = "minecraft:golden_boots";
|
||||
ID_MAP[318] = "minecraft:flint";
|
||||
ID_MAP[319] = "minecraft:porkchop";
|
||||
ID_MAP[320] = "minecraft:cooked_porkchop";
|
||||
ID_MAP[321] = "minecraft:painting";
|
||||
ID_MAP[322] = "minecraft:golden_apple";
|
||||
ID_MAP[323] = "minecraft:sign";
|
||||
ID_MAP[324] = "minecraft:wooden_door";
|
||||
ID_MAP[325] = "minecraft:bucket";
|
||||
ID_MAP[326] = "minecraft:water_bucket";
|
||||
ID_MAP[327] = "minecraft:lava_bucket";
|
||||
ID_MAP[328] = "minecraft:minecart";
|
||||
ID_MAP[329] = "minecraft:saddle";
|
||||
ID_MAP[330] = "minecraft:iron_door";
|
||||
ID_MAP[331] = "minecraft:redstone";
|
||||
ID_MAP[332] = "minecraft:snowball";
|
||||
ID_MAP[333] = "minecraft:boat";
|
||||
ID_MAP[334] = "minecraft:leather";
|
||||
ID_MAP[335] = "minecraft:milk_bucket";
|
||||
ID_MAP[336] = "minecraft:brick";
|
||||
ID_MAP[337] = "minecraft:clay_ball";
|
||||
ID_MAP[338] = "minecraft:reeds";
|
||||
ID_MAP[339] = "minecraft:paper";
|
||||
ID_MAP[340] = "minecraft:book";
|
||||
ID_MAP[341] = "minecraft:slime_ball";
|
||||
ID_MAP[342] = "minecraft:chest_minecart";
|
||||
ID_MAP[343] = "minecraft:furnace_minecart";
|
||||
ID_MAP[344] = "minecraft:egg";
|
||||
ID_MAP[345] = "minecraft:compass";
|
||||
ID_MAP[346] = "minecraft:fishing_rod";
|
||||
ID_MAP[347] = "minecraft:clock";
|
||||
ID_MAP[348] = "minecraft:glowstone_dust";
|
||||
ID_MAP[349] = "minecraft:fish";
|
||||
ID_MAP[350] = "minecraft:cooked_fished";
|
||||
ID_MAP[351] = "minecraft:dye";
|
||||
ID_MAP[352] = "minecraft:bone";
|
||||
ID_MAP[353] = "minecraft:sugar";
|
||||
ID_MAP[354] = "minecraft:cake";
|
||||
ID_MAP[355] = "minecraft:bed";
|
||||
ID_MAP[356] = "minecraft:repeater";
|
||||
ID_MAP[357] = "minecraft:cookie";
|
||||
ID_MAP[358] = "minecraft:filled_map";
|
||||
ID_MAP[359] = "minecraft:shears";
|
||||
ID_MAP[360] = "minecraft:melon";
|
||||
ID_MAP[361] = "minecraft:pumpkin_seeds";
|
||||
ID_MAP[362] = "minecraft:melon_seeds";
|
||||
ID_MAP[363] = "minecraft:beef";
|
||||
ID_MAP[364] = "minecraft:cooked_beef";
|
||||
ID_MAP[365] = "minecraft:chicken";
|
||||
ID_MAP[366] = "minecraft:cooked_chicken";
|
||||
ID_MAP[367] = "minecraft:rotten_flesh";
|
||||
ID_MAP[368] = "minecraft:ender_pearl";
|
||||
ID_MAP[369] = "minecraft:blaze_rod";
|
||||
ID_MAP[370] = "minecraft:ghast_tear";
|
||||
ID_MAP[371] = "minecraft:gold_nugget";
|
||||
ID_MAP[372] = "minecraft:nether_wart";
|
||||
ID_MAP[373] = "minecraft:potion";
|
||||
ID_MAP[374] = "minecraft:glass_bottle";
|
||||
ID_MAP[375] = "minecraft:spider_eye";
|
||||
ID_MAP[376] = "minecraft:fermented_spider_eye";
|
||||
ID_MAP[377] = "minecraft:blaze_powder";
|
||||
ID_MAP[378] = "minecraft:magma_cream";
|
||||
ID_MAP[379] = "minecraft:brewing_stand";
|
||||
ID_MAP[380] = "minecraft:cauldron";
|
||||
ID_MAP[381] = "minecraft:ender_eye";
|
||||
ID_MAP[382] = "minecraft:speckled_melon";
|
||||
ID_MAP[383] = "minecraft:spawn_egg";
|
||||
ID_MAP[384] = "minecraft:experience_bottle";
|
||||
ID_MAP[385] = "minecraft:fire_charge";
|
||||
ID_MAP[386] = "minecraft:writable_book";
|
||||
ID_MAP[387] = "minecraft:written_book";
|
||||
ID_MAP[388] = "minecraft:emerald";
|
||||
ID_MAP[389] = "minecraft:item_frame";
|
||||
ID_MAP[390] = "minecraft:flower_pot";
|
||||
ID_MAP[391] = "minecraft:carrot";
|
||||
ID_MAP[392] = "minecraft:potato";
|
||||
ID_MAP[393] = "minecraft:baked_potato";
|
||||
ID_MAP[394] = "minecraft:poisonous_potato";
|
||||
ID_MAP[395] = "minecraft:map";
|
||||
ID_MAP[396] = "minecraft:golden_carrot";
|
||||
ID_MAP[397] = "minecraft:skull";
|
||||
ID_MAP[398] = "minecraft:carrot_on_a_stick";
|
||||
ID_MAP[399] = "minecraft:nether_star";
|
||||
ID_MAP[400] = "minecraft:pumpkin_pie";
|
||||
ID_MAP[401] = "minecraft:fireworks";
|
||||
ID_MAP[402] = "minecraft:firework_charge";
|
||||
ID_MAP[403] = "minecraft:enchanted_book";
|
||||
ID_MAP[404] = "minecraft:comparator";
|
||||
ID_MAP[405] = "minecraft:netherbrick";
|
||||
ID_MAP[406] = "minecraft:quartz";
|
||||
ID_MAP[407] = "minecraft:tnt_minecart";
|
||||
ID_MAP[408] = "minecraft:hopper_minecart";
|
||||
ID_MAP[417] = "minecraft:iron_horse_armor";
|
||||
ID_MAP[418] = "minecraft:golden_horse_armor";
|
||||
ID_MAP[419] = "minecraft:diamond_horse_armor";
|
||||
ID_MAP[420] = "minecraft:lead";
|
||||
ID_MAP[421] = "minecraft:name_tag";
|
||||
ID_MAP[422] = "minecraft:command_block_minecart";
|
||||
ID_MAP[2256] = "minecraft:record_13";
|
||||
ID_MAP[2257] = "minecraft:record_cat";
|
||||
ID_MAP[2258] = "minecraft:record_blocks";
|
||||
ID_MAP[2259] = "minecraft:record_chirp";
|
||||
ID_MAP[2260] = "minecraft:record_far";
|
||||
ID_MAP[2261] = "minecraft:record_mall";
|
||||
ID_MAP[2262] = "minecraft:record_mellohi";
|
||||
ID_MAP[2263] = "minecraft:record_stal";
|
||||
ID_MAP[2264] = "minecraft:record_strad";
|
||||
ID_MAP[2265] = "minecraft:record_ward";
|
||||
ID_MAP[2266] = "minecraft:record_11";
|
||||
ID_MAP[2267] = "minecraft:record_wait";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.List;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class MinecartEntityTypes implements IFixableData
|
||||
{
|
||||
private static final List<String> MINECART_TYPE_LIST = Lists.newArrayList("MinecartRideable", "MinecartChest", "MinecartFurnace", "MinecartTNT", "MinecartSpawner", "MinecartHopper", "MinecartCommandBlock");
|
||||
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 106;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
if ("Minecart".equals(compound.getString("id")))
|
||||
{
|
||||
String s = "MinecartRideable";
|
||||
int i = compound.getInteger("Type");
|
||||
|
||||
if (i > 0 && i < MINECART_TYPE_LIST.size())
|
||||
{
|
||||
s = MINECART_TYPE_LIST.get(i);
|
||||
}
|
||||
|
||||
compound.setString("id", s);
|
||||
compound.removeTag("Type");
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import java.util.Locale;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class OptionsLowerCaseLanguage implements IFixableData
|
||||
{
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 816;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
if (compound.hasKey("lang", 8))
|
||||
{
|
||||
compound.setString("lang", compound.getString("lang").toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class PaintingDirection implements IFixableData
|
||||
{
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 111;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
String s = compound.getString("id");
|
||||
boolean flag = "Painting".equals(s);
|
||||
boolean flag1 = "ItemFrame".equals(s);
|
||||
|
||||
if ((flag || flag1) && !compound.hasKey("Facing", 99))
|
||||
{
|
||||
EnumFacing enumfacing;
|
||||
|
||||
if (compound.hasKey("Direction", 99))
|
||||
{
|
||||
enumfacing = EnumFacing.getHorizontal(compound.getByte("Direction"));
|
||||
compound.setInteger("TileX", compound.getInteger("TileX") + enumfacing.getFrontOffsetX());
|
||||
compound.setInteger("TileY", compound.getInteger("TileY") + enumfacing.getFrontOffsetY());
|
||||
compound.setInteger("TileZ", compound.getInteger("TileZ") + enumfacing.getFrontOffsetZ());
|
||||
compound.removeTag("Direction");
|
||||
|
||||
if (flag1 && compound.hasKey("ItemRotation", 99))
|
||||
{
|
||||
compound.setByte("ItemRotation", (byte)(compound.getByte("ItemRotation") * 2));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
enumfacing = EnumFacing.getHorizontal(compound.getByte("Dir"));
|
||||
compound.removeTag("Dir");
|
||||
}
|
||||
|
||||
compound.setByte("Facing", (byte)enumfacing.getHorizontalIndex());
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class PotionItems implements IFixableData
|
||||
{
|
||||
private static final String[] POTION_IDS = new String[128];
|
||||
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 102;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
if ("minecraft:potion".equals(compound.getString("id")))
|
||||
{
|
||||
NBTTagCompound nbttagcompound = compound.getCompoundTag("tag");
|
||||
short short1 = compound.getShort("Damage");
|
||||
|
||||
if (!nbttagcompound.hasKey("Potion", 8))
|
||||
{
|
||||
String s = POTION_IDS[short1 & 127];
|
||||
nbttagcompound.setString("Potion", s == null ? "minecraft:water" : s);
|
||||
compound.setTag("tag", nbttagcompound);
|
||||
|
||||
if ((short1 & 16384) == 16384)
|
||||
{
|
||||
compound.setString("id", "minecraft:splash_potion");
|
||||
}
|
||||
}
|
||||
|
||||
if (short1 != 0)
|
||||
{
|
||||
compound.setShort("Damage", (short)0);
|
||||
}
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
POTION_IDS[0] = "minecraft:water";
|
||||
POTION_IDS[1] = "minecraft:regeneration";
|
||||
POTION_IDS[2] = "minecraft:swiftness";
|
||||
POTION_IDS[3] = "minecraft:fire_resistance";
|
||||
POTION_IDS[4] = "minecraft:poison";
|
||||
POTION_IDS[5] = "minecraft:healing";
|
||||
POTION_IDS[6] = "minecraft:night_vision";
|
||||
POTION_IDS[7] = null;
|
||||
POTION_IDS[8] = "minecraft:weakness";
|
||||
POTION_IDS[9] = "minecraft:strength";
|
||||
POTION_IDS[10] = "minecraft:slowness";
|
||||
POTION_IDS[11] = "minecraft:leaping";
|
||||
POTION_IDS[12] = "minecraft:harming";
|
||||
POTION_IDS[13] = "minecraft:water_breathing";
|
||||
POTION_IDS[14] = "minecraft:invisibility";
|
||||
POTION_IDS[15] = null;
|
||||
POTION_IDS[16] = "minecraft:awkward";
|
||||
POTION_IDS[17] = "minecraft:regeneration";
|
||||
POTION_IDS[18] = "minecraft:swiftness";
|
||||
POTION_IDS[19] = "minecraft:fire_resistance";
|
||||
POTION_IDS[20] = "minecraft:poison";
|
||||
POTION_IDS[21] = "minecraft:healing";
|
||||
POTION_IDS[22] = "minecraft:night_vision";
|
||||
POTION_IDS[23] = null;
|
||||
POTION_IDS[24] = "minecraft:weakness";
|
||||
POTION_IDS[25] = "minecraft:strength";
|
||||
POTION_IDS[26] = "minecraft:slowness";
|
||||
POTION_IDS[27] = "minecraft:leaping";
|
||||
POTION_IDS[28] = "minecraft:harming";
|
||||
POTION_IDS[29] = "minecraft:water_breathing";
|
||||
POTION_IDS[30] = "minecraft:invisibility";
|
||||
POTION_IDS[31] = null;
|
||||
POTION_IDS[32] = "minecraft:thick";
|
||||
POTION_IDS[33] = "minecraft:strong_regeneration";
|
||||
POTION_IDS[34] = "minecraft:strong_swiftness";
|
||||
POTION_IDS[35] = "minecraft:fire_resistance";
|
||||
POTION_IDS[36] = "minecraft:strong_poison";
|
||||
POTION_IDS[37] = "minecraft:strong_healing";
|
||||
POTION_IDS[38] = "minecraft:night_vision";
|
||||
POTION_IDS[39] = null;
|
||||
POTION_IDS[40] = "minecraft:weakness";
|
||||
POTION_IDS[41] = "minecraft:strong_strength";
|
||||
POTION_IDS[42] = "minecraft:slowness";
|
||||
POTION_IDS[43] = "minecraft:strong_leaping";
|
||||
POTION_IDS[44] = "minecraft:strong_harming";
|
||||
POTION_IDS[45] = "minecraft:water_breathing";
|
||||
POTION_IDS[46] = "minecraft:invisibility";
|
||||
POTION_IDS[47] = null;
|
||||
POTION_IDS[48] = null;
|
||||
POTION_IDS[49] = "minecraft:strong_regeneration";
|
||||
POTION_IDS[50] = "minecraft:strong_swiftness";
|
||||
POTION_IDS[51] = "minecraft:fire_resistance";
|
||||
POTION_IDS[52] = "minecraft:strong_poison";
|
||||
POTION_IDS[53] = "minecraft:strong_healing";
|
||||
POTION_IDS[54] = "minecraft:night_vision";
|
||||
POTION_IDS[55] = null;
|
||||
POTION_IDS[56] = "minecraft:weakness";
|
||||
POTION_IDS[57] = "minecraft:strong_strength";
|
||||
POTION_IDS[58] = "minecraft:slowness";
|
||||
POTION_IDS[59] = "minecraft:strong_leaping";
|
||||
POTION_IDS[60] = "minecraft:strong_harming";
|
||||
POTION_IDS[61] = "minecraft:water_breathing";
|
||||
POTION_IDS[62] = "minecraft:invisibility";
|
||||
POTION_IDS[63] = null;
|
||||
POTION_IDS[64] = "minecraft:mundane";
|
||||
POTION_IDS[65] = "minecraft:long_regeneration";
|
||||
POTION_IDS[66] = "minecraft:long_swiftness";
|
||||
POTION_IDS[67] = "minecraft:long_fire_resistance";
|
||||
POTION_IDS[68] = "minecraft:long_poison";
|
||||
POTION_IDS[69] = "minecraft:healing";
|
||||
POTION_IDS[70] = "minecraft:long_night_vision";
|
||||
POTION_IDS[71] = null;
|
||||
POTION_IDS[72] = "minecraft:long_weakness";
|
||||
POTION_IDS[73] = "minecraft:long_strength";
|
||||
POTION_IDS[74] = "minecraft:long_slowness";
|
||||
POTION_IDS[75] = "minecraft:long_leaping";
|
||||
POTION_IDS[76] = "minecraft:harming";
|
||||
POTION_IDS[77] = "minecraft:long_water_breathing";
|
||||
POTION_IDS[78] = "minecraft:long_invisibility";
|
||||
POTION_IDS[79] = null;
|
||||
POTION_IDS[80] = "minecraft:awkward";
|
||||
POTION_IDS[81] = "minecraft:long_regeneration";
|
||||
POTION_IDS[82] = "minecraft:long_swiftness";
|
||||
POTION_IDS[83] = "minecraft:long_fire_resistance";
|
||||
POTION_IDS[84] = "minecraft:long_poison";
|
||||
POTION_IDS[85] = "minecraft:healing";
|
||||
POTION_IDS[86] = "minecraft:long_night_vision";
|
||||
POTION_IDS[87] = null;
|
||||
POTION_IDS[88] = "minecraft:long_weakness";
|
||||
POTION_IDS[89] = "minecraft:long_strength";
|
||||
POTION_IDS[90] = "minecraft:long_slowness";
|
||||
POTION_IDS[91] = "minecraft:long_leaping";
|
||||
POTION_IDS[92] = "minecraft:harming";
|
||||
POTION_IDS[93] = "minecraft:long_water_breathing";
|
||||
POTION_IDS[94] = "minecraft:long_invisibility";
|
||||
POTION_IDS[95] = null;
|
||||
POTION_IDS[96] = "minecraft:thick";
|
||||
POTION_IDS[97] = "minecraft:regeneration";
|
||||
POTION_IDS[98] = "minecraft:swiftness";
|
||||
POTION_IDS[99] = "minecraft:long_fire_resistance";
|
||||
POTION_IDS[100] = "minecraft:poison";
|
||||
POTION_IDS[101] = "minecraft:strong_healing";
|
||||
POTION_IDS[102] = "minecraft:long_night_vision";
|
||||
POTION_IDS[103] = null;
|
||||
POTION_IDS[104] = "minecraft:long_weakness";
|
||||
POTION_IDS[105] = "minecraft:strength";
|
||||
POTION_IDS[106] = "minecraft:long_slowness";
|
||||
POTION_IDS[107] = "minecraft:leaping";
|
||||
POTION_IDS[108] = "minecraft:strong_harming";
|
||||
POTION_IDS[109] = "minecraft:long_water_breathing";
|
||||
POTION_IDS[110] = "minecraft:long_invisibility";
|
||||
POTION_IDS[111] = null;
|
||||
POTION_IDS[112] = null;
|
||||
POTION_IDS[113] = "minecraft:regeneration";
|
||||
POTION_IDS[114] = "minecraft:swiftness";
|
||||
POTION_IDS[115] = "minecraft:long_fire_resistance";
|
||||
POTION_IDS[116] = "minecraft:poison";
|
||||
POTION_IDS[117] = "minecraft:strong_healing";
|
||||
POTION_IDS[118] = "minecraft:long_night_vision";
|
||||
POTION_IDS[119] = null;
|
||||
POTION_IDS[120] = "minecraft:long_weakness";
|
||||
POTION_IDS[121] = "minecraft:strength";
|
||||
POTION_IDS[122] = "minecraft:long_slowness";
|
||||
POTION_IDS[123] = "minecraft:leaping";
|
||||
POTION_IDS[124] = "minecraft:strong_harming";
|
||||
POTION_IDS[125] = "minecraft:long_water_breathing";
|
||||
POTION_IDS[126] = "minecraft:long_invisibility";
|
||||
POTION_IDS[127] = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class PotionWater implements IFixableData
|
||||
{
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 806;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
String s = compound.getString("id");
|
||||
|
||||
if ("minecraft:potion".equals(s) || "minecraft:splash_potion".equals(s) || "minecraft:lingering_potion".equals(s) || "minecraft:tipped_arrow".equals(s))
|
||||
{
|
||||
NBTTagCompound nbttagcompound = compound.getCompoundTag("tag");
|
||||
|
||||
if (!nbttagcompound.hasKey("Potion", 8))
|
||||
{
|
||||
nbttagcompound.setString("Potion", "minecraft:water");
|
||||
}
|
||||
|
||||
if (!compound.hasKey("tag", 10))
|
||||
{
|
||||
compound.setTag("tag", nbttagcompound);
|
||||
}
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class RedundantChanceTags implements IFixableData
|
||||
{
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 113;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
if (compound.hasKey("HandDropChances", 9))
|
||||
{
|
||||
NBTTagList nbttaglist = compound.getTagList("HandDropChances", 5);
|
||||
|
||||
if (nbttaglist.tagCount() == 2 && nbttaglist.getFloatAt(0) == 0.0F && nbttaglist.getFloatAt(1) == 0.0F)
|
||||
{
|
||||
compound.removeTag("HandDropChances");
|
||||
}
|
||||
}
|
||||
|
||||
if (compound.hasKey("ArmorDropChances", 9))
|
||||
{
|
||||
NBTTagList nbttaglist1 = compound.getTagList("ArmorDropChances", 5);
|
||||
|
||||
if (nbttaglist1.tagCount() == 4 && nbttaglist1.getFloatAt(0) == 0.0F && nbttaglist1.getFloatAt(1) == 0.0F && nbttaglist1.getFloatAt(2) == 0.0F && nbttaglist1.getFloatAt(3) == 0.0F)
|
||||
{
|
||||
compound.removeTag("ArmorDropChances");
|
||||
}
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class RidingToPassengers implements IFixableData
|
||||
{
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 135;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
while (compound.hasKey("Riding", 10))
|
||||
{
|
||||
NBTTagCompound nbttagcompound = this.extractVehicle(compound);
|
||||
this.addPassengerToVehicle(compound, nbttagcompound);
|
||||
compound = nbttagcompound;
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
protected void addPassengerToVehicle(NBTTagCompound p_188219_1_, NBTTagCompound p_188219_2_)
|
||||
{
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
nbttaglist.appendTag(p_188219_1_);
|
||||
p_188219_2_.setTag("Passengers", nbttaglist);
|
||||
}
|
||||
|
||||
protected NBTTagCompound extractVehicle(NBTTagCompound p_188220_1_)
|
||||
{
|
||||
NBTTagCompound nbttagcompound = p_188220_1_.getCompoundTag("Riding");
|
||||
p_188220_1_.removeTag("Riding");
|
||||
return nbttagcompound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class ShulkerBoxEntityColor implements IFixableData
|
||||
{
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 808;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
if ("minecraft:shulker".equals(compound.getString("id")) && !compound.hasKey("Color", 99))
|
||||
{
|
||||
compound.setByte("Color", (byte)10);
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class ShulkerBoxItemColor implements IFixableData
|
||||
{
|
||||
public static final String[] NAMES_BY_COLOR = new String[] {"minecraft:white_shulker_box", "minecraft:orange_shulker_box", "minecraft:magenta_shulker_box", "minecraft:light_blue_shulker_box", "minecraft:yellow_shulker_box", "minecraft:lime_shulker_box", "minecraft:pink_shulker_box", "minecraft:gray_shulker_box", "minecraft:silver_shulker_box", "minecraft:cyan_shulker_box", "minecraft:purple_shulker_box", "minecraft:blue_shulker_box", "minecraft:brown_shulker_box", "minecraft:green_shulker_box", "minecraft:red_shulker_box", "minecraft:black_shulker_box"};
|
||||
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 813;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
if ("minecraft:shulker_box".equals(compound.getString("id")) && compound.hasKey("tag", 10))
|
||||
{
|
||||
NBTTagCompound nbttagcompound = compound.getCompoundTag("tag");
|
||||
|
||||
if (nbttagcompound.hasKey("BlockEntityTag", 10))
|
||||
{
|
||||
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("BlockEntityTag");
|
||||
|
||||
if (nbttagcompound1.getTagList("Items", 10).hasNoTags())
|
||||
{
|
||||
nbttagcompound1.removeTag("Items");
|
||||
}
|
||||
|
||||
int i = nbttagcompound1.getInteger("Color");
|
||||
nbttagcompound1.removeTag("Color");
|
||||
|
||||
if (nbttagcompound1.hasNoTags())
|
||||
{
|
||||
nbttagcompound.removeTag("BlockEntityTag");
|
||||
}
|
||||
|
||||
if (nbttagcompound.hasNoTags())
|
||||
{
|
||||
compound.removeTag("tag");
|
||||
}
|
||||
|
||||
compound.setString("id", NAMES_BY_COLOR[i % 16]);
|
||||
}
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class ShulkerBoxTileColor implements IFixableData
|
||||
{
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 813;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
if ("minecraft:shulker".equals(compound.getString("id")))
|
||||
{
|
||||
compound.removeTag("Color");
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import java.lang.reflect.Type;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraft.util.StringUtils;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
|
||||
public class SignStrictJSON implements IFixableData
|
||||
{
|
||||
public static final Gson GSON_INSTANCE = (new GsonBuilder()).registerTypeAdapter(ITextComponent.class, new JsonDeserializer<ITextComponent>()
|
||||
{
|
||||
public ITextComponent deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
|
||||
{
|
||||
if (p_deserialize_1_.isJsonPrimitive())
|
||||
{
|
||||
return new TextComponentString(p_deserialize_1_.getAsString());
|
||||
}
|
||||
else if (p_deserialize_1_.isJsonArray())
|
||||
{
|
||||
JsonArray jsonarray = p_deserialize_1_.getAsJsonArray();
|
||||
ITextComponent itextcomponent = null;
|
||||
|
||||
for (JsonElement jsonelement : jsonarray)
|
||||
{
|
||||
ITextComponent itextcomponent1 = this.deserialize(jsonelement, jsonelement.getClass(), p_deserialize_3_);
|
||||
|
||||
if (itextcomponent == null)
|
||||
{
|
||||
itextcomponent = itextcomponent1;
|
||||
}
|
||||
else
|
||||
{
|
||||
itextcomponent.appendSibling(itextcomponent1);
|
||||
}
|
||||
}
|
||||
|
||||
return itextcomponent;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new JsonParseException("Don't know how to turn " + p_deserialize_1_ + " into a Component");
|
||||
}
|
||||
}
|
||||
}).create();
|
||||
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 101;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
if ("Sign".equals(compound.getString("id")))
|
||||
{
|
||||
this.updateLine(compound, "Text1");
|
||||
this.updateLine(compound, "Text2");
|
||||
this.updateLine(compound, "Text3");
|
||||
this.updateLine(compound, "Text4");
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
private void updateLine(NBTTagCompound compound, String key)
|
||||
{
|
||||
String s = compound.getString(key);
|
||||
ITextComponent itextcomponent = null;
|
||||
|
||||
if (!"null".equals(s) && !StringUtils.isNullOrEmpty(s))
|
||||
{
|
||||
if (s.charAt(0) == '"' && s.charAt(s.length() - 1) == '"' || s.charAt(0) == '{' && s.charAt(s.length() - 1) == '}')
|
||||
{
|
||||
try
|
||||
{
|
||||
itextcomponent = (ITextComponent)JsonUtils.gsonDeserialize(GSON_INSTANCE, s, ITextComponent.class, true);
|
||||
|
||||
if (itextcomponent == null)
|
||||
{
|
||||
itextcomponent = new TextComponentString("");
|
||||
}
|
||||
}
|
||||
catch (JsonParseException var8)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
if (itextcomponent == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
itextcomponent = ITextComponent.Serializer.jsonToComponent(s);
|
||||
}
|
||||
catch (JsonParseException var7)
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if (itextcomponent == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
itextcomponent = ITextComponent.Serializer.fromJsonLenient(s);
|
||||
}
|
||||
catch (JsonParseException var6)
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if (itextcomponent == null)
|
||||
{
|
||||
itextcomponent = new TextComponentString(s);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
itextcomponent = new TextComponentString(s);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
itextcomponent = new TextComponentString("");
|
||||
}
|
||||
|
||||
compound.setString(key, ITextComponent.Serializer.componentToJson(itextcomponent));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class SkeletonSplit implements IFixableData
|
||||
{
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 701;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
String s = compound.getString("id");
|
||||
|
||||
if ("Skeleton".equals(s))
|
||||
{
|
||||
int i = compound.getInteger("SkeletonType");
|
||||
|
||||
if (i == 1)
|
||||
{
|
||||
compound.setString("id", "WitherSkeleton");
|
||||
}
|
||||
else if (i == 2)
|
||||
{
|
||||
compound.setString("id", "Stray");
|
||||
}
|
||||
|
||||
compound.removeTag("SkeletonType");
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class SpawnEggNames implements IFixableData
|
||||
{
|
||||
private static final String[] ENTITY_IDS = new String[256];
|
||||
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 105;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
if ("minecraft:spawn_egg".equals(compound.getString("id")))
|
||||
{
|
||||
NBTTagCompound nbttagcompound = compound.getCompoundTag("tag");
|
||||
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("EntityTag");
|
||||
short short1 = compound.getShort("Damage");
|
||||
|
||||
if (!nbttagcompound1.hasKey("id", 8))
|
||||
{
|
||||
String s = ENTITY_IDS[short1 & 255];
|
||||
|
||||
if (s != null)
|
||||
{
|
||||
nbttagcompound1.setString("id", s);
|
||||
nbttagcompound.setTag("EntityTag", nbttagcompound1);
|
||||
compound.setTag("tag", nbttagcompound);
|
||||
}
|
||||
}
|
||||
|
||||
if (short1 != 0)
|
||||
{
|
||||
compound.setShort("Damage", (short)0);
|
||||
}
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
String[] astring = ENTITY_IDS;
|
||||
astring[1] = "Item";
|
||||
astring[2] = "XPOrb";
|
||||
astring[7] = "ThrownEgg";
|
||||
astring[8] = "LeashKnot";
|
||||
astring[9] = "Painting";
|
||||
astring[10] = "Arrow";
|
||||
astring[11] = "Snowball";
|
||||
astring[12] = "Fireball";
|
||||
astring[13] = "SmallFireball";
|
||||
astring[14] = "ThrownEnderpearl";
|
||||
astring[15] = "EyeOfEnderSignal";
|
||||
astring[16] = "ThrownPotion";
|
||||
astring[17] = "ThrownExpBottle";
|
||||
astring[18] = "ItemFrame";
|
||||
astring[19] = "WitherSkull";
|
||||
astring[20] = "PrimedTnt";
|
||||
astring[21] = "FallingSand";
|
||||
astring[22] = "FireworksRocketEntity";
|
||||
astring[23] = "TippedArrow";
|
||||
astring[24] = "SpectralArrow";
|
||||
astring[25] = "ShulkerBullet";
|
||||
astring[26] = "DragonFireball";
|
||||
astring[30] = "ArmorStand";
|
||||
astring[41] = "Boat";
|
||||
astring[42] = "MinecartRideable";
|
||||
astring[43] = "MinecartChest";
|
||||
astring[44] = "MinecartFurnace";
|
||||
astring[45] = "MinecartTNT";
|
||||
astring[46] = "MinecartHopper";
|
||||
astring[47] = "MinecartSpawner";
|
||||
astring[40] = "MinecartCommandBlock";
|
||||
astring[48] = "Mob";
|
||||
astring[49] = "Monster";
|
||||
astring[50] = "Creeper";
|
||||
astring[51] = "Skeleton";
|
||||
astring[52] = "Spider";
|
||||
astring[53] = "Giant";
|
||||
astring[54] = "Zombie";
|
||||
astring[55] = "Slime";
|
||||
astring[56] = "Ghast";
|
||||
astring[57] = "PigZombie";
|
||||
astring[58] = "Enderman";
|
||||
astring[59] = "CaveSpider";
|
||||
astring[60] = "Silverfish";
|
||||
astring[61] = "Blaze";
|
||||
astring[62] = "LavaSlime";
|
||||
astring[63] = "EnderDragon";
|
||||
astring[64] = "WitherBoss";
|
||||
astring[65] = "Bat";
|
||||
astring[66] = "Witch";
|
||||
astring[67] = "Endermite";
|
||||
astring[68] = "Guardian";
|
||||
astring[69] = "Shulker";
|
||||
astring[90] = "Pig";
|
||||
astring[91] = "Sheep";
|
||||
astring[92] = "Cow";
|
||||
astring[93] = "Chicken";
|
||||
astring[94] = "Squid";
|
||||
astring[95] = "Wolf";
|
||||
astring[96] = "MushroomCow";
|
||||
astring[97] = "SnowMan";
|
||||
astring[98] = "Ozelot";
|
||||
astring[99] = "VillagerGolem";
|
||||
astring[100] = "EntityHorse";
|
||||
astring[101] = "Rabbit";
|
||||
astring[120] = "Villager";
|
||||
astring[200] = "EnderCrystal";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package net.minecraft.util.datafix.fixes;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
|
||||
public class SpawnerEntityTypes implements IFixableData
|
||||
{
|
||||
public int getFixVersion()
|
||||
{
|
||||
return 107;
|
||||
}
|
||||
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
|
||||
{
|
||||
if (!"MobSpawner".equals(compound.getString("id")))
|
||||
{
|
||||
return compound;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (compound.hasKey("EntityId", 8))
|
||||
{
|
||||
String s = compound.getString("EntityId");
|
||||
NBTTagCompound nbttagcompound = compound.getCompoundTag("SpawnData");
|
||||
nbttagcompound.setString("id", s.isEmpty() ? "Pig" : s);
|
||||
compound.setTag("SpawnData", nbttagcompound);
|
||||
compound.removeTag("EntityId");
|
||||
}
|
||||
|
||||
if (compound.hasKey("SpawnPotentials", 9))
|
||||
{
|
||||
NBTTagList nbttaglist = compound.getTagList("SpawnPotentials", 10);
|
||||
|
||||
for (int i = 0; i < nbttaglist.tagCount(); ++i)
|
||||
{
|
||||
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
|
||||
|
||||
if (nbttagcompound1.hasKey("Type", 8))
|
||||
{
|
||||
NBTTagCompound nbttagcompound2 = nbttagcompound1.getCompoundTag("Properties");
|
||||
nbttagcompound2.setString("id", nbttagcompound1.getString("Type"));
|
||||
nbttagcompound1.setTag("Entity", nbttagcompound2);
|
||||
nbttagcompound1.removeTag("Type");
|
||||
nbttagcompound1.removeTag("Properties");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user