util, tileentity, stats, realms. Potions got an overhaul and out registry will need to be adapted.

This commit is contained in:
LexManos committed 2016-03-01 04:07:00 -08:00
1 parent f654157adb
commit 1f80eb17df
29 files changed
+303 -407

No files matched your search

@@ -8,3 +8,12 @@
inetaddress = InetAddress.getByName(p_connect_1_);
if (RealmsConnect.this.aborted)
@@ -59,7 +60,7 @@
return;
}
- RealmsConnect.this.connection.sendPacket(new C00Handshake(107, p_connect_1_, p_connect_2_, EnumConnectionState.LOGIN));
+ RealmsConnect.this.connection.sendPacket(new C00Handshake(107, p_connect_1_, p_connect_2_, EnumConnectionState.LOGIN, true));
if (RealmsConnect.this.aborted)
{
@@ -1,5 +1,23 @@
--- ../src-base/minecraft/net/minecraft/stats/StatList.java
+++ ../src-work/minecraft/net/minecraft/stats/StatList.java
@@ -155,7 +155,7 @@
}
}
- replaceAllSimilarBlocks(field_188066_af);
+ replaceAllSimilarBlocks(field_188066_af, true);
}
private static void initMiningStats()
@@ -177,7 +177,7 @@
}
}
- replaceAllSimilarBlocks(field_188065_ae);
+ replaceAllSimilarBlocks(field_188065_ae, false);
}
private static void initStats()
@@ -201,7 +201,7 @@
}
}
@@ -9,6 +27,15 @@
}
private static void initItemDepleteStats()
@@ -220,7 +220,7 @@
}
}
- replaceAllSimilarBlocks(objectBreakStats);
+ replaceAllSimilarBlocks(objectBreakStats, true);
}
private static void func_188054_f()
@@ -240,7 +240,7 @@
}
}
@@ -27,7 +27,40 @@
}
}
@@ -144,7 +148,6 @@
@@ -83,10 +87,11 @@
{
TileEntity tileentity = null;
String s = p_184246_1_.getString("id");
+ Class <? extends TileEntity > oclass = null;
try
{
- Class <? extends TileEntity > oclass = (Class)nameToClassMap.get(s);
+ oclass = (Class)nameToClassMap.get(s);
if (oclass != null)
{
@@ -96,6 +101,9 @@
catch (Throwable throwable1)
{
logger.error("Failed to create block entity " + s, throwable1);
+ net.minecraftforge.fml.common.FMLLog.log(org.apache.logging.log4j.Level.ERROR, throwable1,
+ "A TileEntity %s(%s) has thrown an exception during loading, its state cannot be restored. Report this to the mod author",
+ s, oclass.getName());
}
if (tileentity != null)
@@ -107,6 +115,9 @@
catch (Throwable throwable)
{
logger.error("Failed to load data for block entity " + s, throwable);
+ net.minecraftforge.fml.common.FMLLog.log(org.apache.logging.log4j.Level.ERROR, throwable,
+ "A TileEntity %s(%s) has thrown an exception during loading, its state cannot be restored. Report this to the mod author",
+ s, oclass.getName());
tileentity = null;
}
}
@@ -144,7 +155,6 @@
}
}
@@ -35,7 +68,7 @@
public double getDistanceSq(double x, double y, double z)
{
double d0 = (double)this.pos.getX() + 0.5D - x;
@@ -271,6 +274,185 @@
@@ -271,6 +281,185 @@
return false;
}
@@ -49,7 +82,7 @@
+ * @param net The NetworkManager the packet originated from
+ * @param pkt The data packet
+ */
+ public void onDataPacket(net.minecraft.network.NetworkManager net, net.minecraft.network.play.server.S35PacketUpdateTileEntity pkt)
+ public void onDataPacket(net.minecraft.network.NetworkManager net, net.minecraft.network.play.server.SPacketUpdateTileEntity pkt)
+ {
+ }
+
@@ -84,7 +117,7 @@
+ /**
+ * Sometimes default render bounding box: infinite in scope. Used to control rendering on {@link TileEntitySpecialRenderer}.
+ */
+ public static final net.minecraft.util.AxisAlignedBB INFINITE_EXTENT_AABB = new net.minecraft.util.AxisAlignedBB(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
+ public static final net.minecraft.util.math.AxisAlignedBB INFINITE_EXTENT_AABB = new net.minecraft.util.math.AxisAlignedBB(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
+ /**
+ * Return an {@link AxisAlignedBB} that controls the visible scope of a {@link TileEntitySpecialRenderer} associated with this {@link TileEntity}
+ * Defaults to the collision bounding box {@link Block#getCollisionBoundingBoxFromPool(World, int, int, int)} associated with the block
@@ -93,24 +126,24 @@
+ * @return an appropriately size {@link AxisAlignedBB} for the {@link TileEntity}
+ */
+ @SideOnly(Side.CLIENT)
+ public net.minecraft.util.AxisAlignedBB getRenderBoundingBox()
+ public net.minecraft.util.math.AxisAlignedBB getRenderBoundingBox()
+ {
+ net.minecraft.util.AxisAlignedBB bb = INFINITE_EXTENT_AABB;
+ net.minecraft.util.math.AxisAlignedBB bb = INFINITE_EXTENT_AABB;
+ Block type = getBlockType();
+ if (type == Blocks.enchanting_table)
+ {
+ bb = new net.minecraft.util.AxisAlignedBB(getPos(), getPos().add(1, 1, 1));
+ bb = new net.minecraft.util.math.AxisAlignedBB(getPos(), getPos().add(1, 1, 1));
+ }
+ else if (type == Blocks.chest || type == Blocks.trapped_chest)
+ {
+ bb = new net.minecraft.util.AxisAlignedBB(getPos().add(-1, 0, -1), getPos().add(2, 2, 2));
+ bb = new net.minecraft.util.math.AxisAlignedBB(getPos().add(-1, 0, -1), getPos().add(2, 2, 2));
+ }
+ else if (type != null && type != Blocks.beacon)
+ {
+ net.minecraft.util.AxisAlignedBB cbb = null;
+ net.minecraft.util.math.AxisAlignedBB cbb = null;
+ try
+ {
+ cbb = type.getCollisionBoundingBox(worldObj, getPos(), worldObj.getBlockState(getPos()));
+ cbb = worldObj.getBlockState(getPos()).func_185890_d(worldObj, getPos());
+ }
+ catch (Exception e)
+ {
@@ -120,7 +153,7 @@
+ // So, once again in the long line of US having to accommodate BUKKIT breaking things,
+ // here it is, assume that the TE is only 1 cubic block. Problem with this is that it may
+ // cause the TileEntity renderer to error further down the line! But alas, nothing we can do.
+ cbb = new net.minecraft.util.AxisAlignedBB(getPos().add(-1, 0, -1), getPos().add(1, 1, 1));
+ cbb = new net.minecraft.util.math.AxisAlignedBB(getPos().add(-1, 0, -1), getPos().add(1, 1, 1));
+ }
+ if (cbb != null) bb = cbb;
+ }
@@ -9,15 +9,61 @@
{
ItemStack itemstack = this.brewingItemStacks[3];
@@ -193,6 +193,7 @@
{
InventoryHelper.spawnItemStack(this.worldObj, (double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ(), itemstack1);
}
+ net.minecraftforge.event.ForgeEventFactory.onPotionBrewed(brewingItemStacks);
@@ -165,25 +165,23 @@
}
else
{
- return false;
+ return net.minecraftforge.common.brewing.BrewingRecipeRegistry.canBrew(brewingItemStacks, brewingItemStacks[3], outputSlots);
}
}
if (itemstack.stackSize <= 0)
@@ -362,6 +363,20 @@
private void brewPotions()
{
+ if (net.minecraftforge.event.ForgeEventFactory.onPotionAttemptBreaw(brewingItemStacks)) return;
ItemStack itemstack = this.brewingItemStacks[3];
- for (int i = 0; i < 3; ++i)
- {
- this.brewingItemStacks[i] = PotionHelper.func_185212_d(itemstack, this.brewingItemStacks[i]);
- }
+ net.minecraftforge.common.brewing.BrewingRecipeRegistry.brewPotions(brewingItemStacks, brewingItemStacks[3], outputSlots);
--itemstack.stackSize;
BlockPos blockpos = this.getPos();
- if (itemstack.getItem().hasContainerItem())
+ if (itemstack.getItem().hasContainerItem(itemstack))
{
- ItemStack itemstack1 = new ItemStack(itemstack.getItem().getContainerItem());
+ ItemStack itemstack1 = new ItemStack(itemstack.getItem().getContainerItem(itemstack));
if (itemstack.stackSize <= 0)
{
@@ -202,6 +200,7 @@
this.brewingItemStacks[3] = itemstack;
this.worldObj.playAuxSFX(1035, blockpos, 0);
+ net.minecraftforge.event.ForgeEventFactory.onPotionBrewed(brewingItemStacks);
}
public void readFromNBT(NBTTagCompound compound)
@@ -303,12 +302,12 @@
{
if (index == 3)
{
- return PotionHelper.func_185205_a(stack);
+ return net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidIngredient(stack);
}
else
{
Item item = stack.getItem();
- return index == 4 ? item == Items.blaze_powder : item == Items.potionitem || item == Items.field_185155_bH || item == Items.field_185156_bI || item == Items.glass_bottle;
+ return index == 4 ? item == Items.blaze_powder : net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidInput(stack);
}
}
@@ -362,6 +361,20 @@
}
}
@@ -1,11 +1,12 @@
++++ REJECTED PATCH 1
--- ../src-base/minecraft/net/minecraft/util/BlockRenderLayer.java
+++ ../src-work/minecraft/net/minecraft/util/BlockRenderLayer.java
@@ -1,9 +1,5 @@
package net.minecraft.util;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-@SideOnly(Side.CLIENT)
public enum EnumWorldBlockLayer
public enum BlockRenderLayer
{
SOLID("Solid"),
++++ END PATCH
@@ -1,6 +1,15 @@
--- ../src-base/minecraft/net/minecraft/util/EnumFacing.java
+++ ../src-work/minecraft/net/minecraft/util/EnumFacing.java
@@ -62,7 +62,6 @@
@@ -8,8 +8,6 @@
import java.util.Random;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3i;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
public enum EnumFacing implements IStringSerializable
{
@@ -62,7 +60,6 @@
return getFront(this.opposite);
}
@@ -8,7 +17,7 @@
public EnumFacing rotateAround(EnumFacing.Axis axis)
{
switch (axis)
@@ -113,7 +112,6 @@
@@ -113,7 +110,6 @@
}
}
@@ -16,7 +25,7 @@
private EnumFacing rotateX()
{
switch (this)
@@ -133,7 +131,6 @@
@@ -133,7 +129,6 @@
}
}
@@ -24,7 +33,7 @@
private EnumFacing rotateZ()
{
switch (this)
@@ -194,7 +191,6 @@
@@ -194,7 +189,6 @@
return this.axis;
}
@@ -32,7 +41,7 @@
public static EnumFacing byName(String name)
{
return name == null ? null : (EnumFacing)NAME_LOOKUP.get(name.toLowerCase());
@@ -225,7 +221,6 @@
@@ -225,7 +219,6 @@
return values()[rand.nextInt(values().length)];
}
@@ -40,7 +49,7 @@
public static EnumFacing getFacingFromVector(float p_176737_0_, float p_176737_1_, float p_176737_2_)
{
EnumFacing enumfacing = NORTH;
@@ -268,7 +263,6 @@
@@ -268,7 +261,6 @@
throw new IllegalArgumentException("No such direction: " + p_181076_0_ + " " + p_181076_1_);
}
@@ -48,7 +57,7 @@
public Vec3i getDirectionVec()
{
return this.directionVec;
@@ -304,7 +298,6 @@
@@ -304,7 +296,6 @@
this.plane = plane;
}
@@ -34,7 +34,7 @@
this.username = usernameIn;
this.playerID = playerIDIn;
this.token = tokenIn;
@@ -49,11 +66,13 @@
@@ -49,14 +66,29 @@
try
{
UUID uuid = UUIDTypeAdapter.fromString(this.getPlayerID());
@@ -50,3 +50,19 @@
}
}
+ /* ======================================== 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
{
@@ -0,0 +1,32 @@
--- ../src-base/minecraft/net/minecraft/util/WeightedRandomChestContent.java
+++ ../src-work/minecraft/net/minecraft/util/WeightedRandomChestContent.java
@@ -20,11 +20,29 @@
this.maxStackSize = maximumChance;
}
+ // -- Forge hooks
+ /**
+ * Allow a mod to submit a custom implementation that can delegate item stack generation beyond simple stack lookup
+ *
+ * @param random The current random for generation
+ * @param newInventory The inventory being generated (do not populate it, but you can refer to it)
+ * @return An array of {@link ItemStack} to put into the chest
+ */
+ @Deprecated // New loottable system shouldn't need this. Need to research more.
+ protected ItemStack[] generateChestContent(Random random, net.minecraft.inventory.IInventory newInventory)
+ {
+ return net.minecraftforge.common.ChestGenHooks.generateStacks(random, theItemId, minStackSize, maxStackSize);
+ }
+
public static void generateDispenserContents(Random random, List<WeightedRandomChestContent> listIn, TileEntityDispenser dispenser, int max)
{
for (int i = 0; i < max; ++i)
{
WeightedRandomChestContent weightedrandomchestcontent = (WeightedRandomChestContent)WeightedRandom.getRandomItem(random, listIn);
+ ItemStack[] stacks = weightedrandomchestcontent.generateChestContent(random, dispenser);
+ for (ItemStack stack : stacks)
+ dispenser.setInventorySlotContents(random.nextInt(dispenser.getSizeInventory()), stack);
+ if (true) continue; // Forge: Skip the rest we replace it.
int j = weightedrandomchestcontent.minStackSize + random.nextInt(weightedrandomchestcontent.maxStackSize - weightedrandomchestcontent.minStackSize + 1);
if (weightedrandomchestcontent.theItemId.getMaxStackSize() >= j)
@@ -1,4 +1,6 @@
++++ REJECTED PATCH 1
--- ../src-base/minecraft/net/minecraft/util/math/BlockPos.java
+++ ../src-work/minecraft/net/minecraft/util/math/BlockPos.java
@@ -270,6 +270,21 @@
};
}
@@ -20,13 +22,20 @@
public static final class MutableBlockPos extends BlockPos
{
private int x;
++++ END PATCH
++++ REJECTED PATCH 2
this.z = zIn;
return this;
@@ -333,6 +348,8 @@
{
return new BlockPos(this);
}
+
+ @Override public BlockPos getImmutable() { return new BlockPos(this); }
}
public static final class PooledMutableBlockPos extends BlockPos
@@ -443,5 +460,7 @@
{
return this.func_185343_d(this.field_185347_c + p_185341_1_.getFrontOffsetX(), this.field_185348_d + p_185341_1_.getFrontOffsetY(), this.field_185349_e + p_185341_1_.getFrontOffsetZ());
}
+
+ @Override public BlockPos getImmutable() { return new BlockPos(this); }
}
}
++++ END PATCH
@@ -0,0 +1,15 @@
--- ../src-base/minecraft/net/minecraft/util/math/RayTraceResult.java
+++ ../src-work/minecraft/net/minecraft/util/math/RayTraceResult.java
@@ -5,6 +5,12 @@
public class RayTraceResult
{
+ /** Used to determine what sub-segment is hit */
+ public int subHit = -1;
+
+ /** Used to add extra hit info */
+ public Object hitInfo = null;
+
private BlockPos blockPos;
public RayTraceResult.Type typeOfHit;
public EnumFacing sideHit;
@@ -0,0 +1,19 @@
--- ../src-base/minecraft/net/minecraft/util/math/Vec3d.java
+++ ../src-work/minecraft/net/minecraft/util/math/Vec3d.java
@@ -1,8 +1,5 @@
package net.minecraft.util.math;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
public class Vec3d
{
public static final Vec3d field_186680_a = new Vec3d(0.0D, 0.0D, 0.0D);
@@ -53,7 +50,6 @@
return this.xCoord * vec.xCoord + this.yCoord * vec.yCoord + this.zCoord * vec.zCoord;
}
- @SideOnly(Side.CLIENT)
public Vec3d crossProduct(Vec3d vec)
{
return new Vec3d(this.yCoord * vec.zCoord - this.zCoord * vec.yCoord, this.zCoord * vec.xCoord - this.xCoord * vec.zCoord, this.xCoord * vec.yCoord - this.yCoord * vec.xCoord);
@@ -0,0 +1,10 @@
--- ../src-base/minecraft/net/minecraft/util/text/ITextComponent.java
+++ ../src-work/minecraft/net/minecraft/util/text/ITextComponent.java
@@ -33,7 +33,6 @@
String getUnformattedText();
- @SideOnly(Side.CLIENT)
String getFormattedText();
List<ITextComponent> getSiblings();
@@ -0,0 +1,10 @@
--- ../src-base/minecraft/net/minecraft/util/text/Style.java
+++ ../src-work/minecraft/net/minecraft/util/text/Style.java
@@ -229,7 +229,6 @@
return this;
}
- @SideOnly(Side.CLIENT)
public String getFormattingCode()
{
if (this.isEmpty())
@@ -1,4 +1,6 @@
++++ REJECTED PATCH 1
--- ../src-base/minecraft/net/minecraft/util/text/TextComponentBase.java
+++ ../src-work/minecraft/net/minecraft/util/text/TextComponentBase.java
@@ -74,7 +74,6 @@
return stringbuilder.toString();
}
@@ -6,4 +8,3 @@
public final String getFormattedText()
{
StringBuilder stringbuilder = new StringBuilder();
++++ END PATCH
@@ -1,8 +1,10 @@
++++ REJECTED PATCH 1
--- ../src-base/minecraft/net/minecraft/util/text/translation/LanguageMap.java
+++ ../src-work/minecraft/net/minecraft/util/text/translation/LanguageMap.java
@@ -23,9 +23,29 @@
public StringTranslate()
public LanguageMap()
{
+ InputStream inputstream = StringTranslate.class.getResourceAsStream("/assets/minecraft/lang/en_US.lang");
+ InputStream inputstream = LanguageMap.class.getResourceAsStream("/assets/minecraft/lang/en_US.lang");
+ inject(this, inputstream);
+ }
+
@@ -11,26 +13,25 @@
+ inject(instance, inputstream);
+ }
+
+ private static void inject(StringTranslate inst, InputStream inputstream)
+ private static void inject(LanguageMap inst, InputStream inputstream)
+ {
+ java.util.HashMap<String, String> map = parseLangFile(inputstream);
+ Map<String, String> map = parseLangFile(inputstream);
+ inst.languageList.putAll(map);
+ inst.lastUpdateTimeInMilliseconds = System.currentTimeMillis();
+ }
+
+ public static java.util.HashMap<String,String> parseLangFile(InputStream inputstream)
+ public static Map<String, String> parseLangFile(InputStream inputstream)
+ {
+ java.util.HashMap<String,String> table = Maps.newHashMap();
+ Map<String, String> table = Maps.newHashMap();
try
{
- InputStream inputstream = StringTranslate.class.getResourceAsStream("/assets/minecraft/lang/en_US.lang");
- InputStream inputstream = LanguageMap.class.getResourceAsStream("/assets/minecraft/lang/en_US.lang");
+ inputstream = net.minecraftforge.fml.common.FMLCommonHandler.instance().loadLanguage(table, inputstream);
+ if (inputstream == null) return table;
for (String s : IOUtils.readLines(inputstream, Charsets.UTF_8))
{
++++ END PATCH
++++ REJECTED PATCH 2
@@ -37,17 +57,18 @@
{
String s1 = astring[0];
String s2 = numericVariablePattern.matcher(astring[1]).replaceAll("%$1s");
@@ -42,13 +43,12 @@
- this.lastUpdateTimeInMilliseconds = System.currentTimeMillis();
}
- catch (IOException var7)
+ catch (Exception var7)
catch (IOException var7)
{
;
}
+ catch (Exception ex) {}
+ return table;
}
static StringTranslate getInstance()
++++ END PATCH
static LanguageMap getInstance()
@@ -1,10 +0,0 @@
++++ REJECTED PATCH 2
return;
}
- RealmsConnect.this.connection.sendPacket(new C00Handshake(47, p_connect_1_, p_connect_2_, EnumConnectionState.LOGIN));
+ RealmsConnect.this.connection.sendPacket(new C00Handshake(47, p_connect_1_, p_connect_2_, EnumConnectionState.LOGIN, true));
if (RealmsConnect.this.aborted)
{
++++ END PATCH
@@ -1,20 +0,0 @@
++++ REJECTED PATCH 1
}
}
- replaceAllSimilarBlocks(objectCraftStats);
+ replaceAllSimilarBlocks(objectCraftStats, true);
}
private static void initMiningStats()
++++ END PATCH
++++ REJECTED PATCH 2
}
}
- replaceAllSimilarBlocks(mineBlockStatArray);
+ replaceAllSimilarBlocks(mineBlockStatArray, false);
}
private static void initStats()
++++ END PATCH
@@ -1,32 +0,0 @@
++++ REJECTED PATCH 4
{
TileEntity tileentity = null;
+ Class <? extends TileEntity > oclass = null;
try
{
- Class <? extends TileEntity > oclass = (Class)nameToClassMap.get(nbt.getString("id"));
+ oclass = (Class)nameToClassMap.get(nbt.getString("id"));
if (oclass != null)
{
++++ END PATCH
++++ REJECTED PATCH 5
}
else
{
+ try
+ {
logger.warn("Skipping BlockEntity with id " + nbt.getString("id"));
+ }
+ catch (Exception ex)
+ {
+ net.minecraftforge.fml.common.FMLLog.log(org.apache.logging.log4j.Level.ERROR, ex,
+ "A TileEntity %s(%s) has thrown an exception during loading, its state cannot be restored. Report this to the mod author",
+ nbt.getString("id"), oclass.getName());
+ tileentity = null;
+ }
}
return tileentity;
++++ END PATCH
@@ -1,63 +0,0 @@
++++ REJECTED PATCH 2
for (int i = 0; i < 3; ++i)
{
- if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].getItem() == Items.potionitem)
+ if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].getItem() instanceof ItemPotion)
{
int j = this.brewingItemStacks[i].getMetadata();
int k = this.getPotionResult(j, itemstack);
++++ END PATCH
++++ REJECTED PATCH 3
}
else
{
- return false;
+ return net.minecraftforge.common.brewing.BrewingRecipeRegistry.canBrew(brewingItemStacks, brewingItemStacks[3], outputSlots);
}
}
private void brewPotions()
{
+ if (net.minecraftforge.event.ForgeEventFactory.onPotionAttemptBreaw(brewingItemStacks)) return;
if (this.canBrew())
{
+ net.minecraftforge.common.brewing.BrewingRecipeRegistry.brewPotions(brewingItemStacks, brewingItemStacks[3], outputSlots);
ItemStack itemstack = this.brewingItemStacks[3];
+ if (false) { // Code moved to net.minecraftforge.common.brewing.VanillaBrewingRecipe
for (int i = 0; i < 3; ++i)
{
- if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].getItem() == Items.potionitem)
+ if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].getItem() instanceof ItemPotion)
{
int j = this.brewingItemStacks[i].getMetadata();
int k = this.getPotionResult(j, itemstack);
++++ END PATCH
++++ REJECTED PATCH 4
}
}
}
+ }
- if (itemstack.getItem().hasContainerItem())
+ if (itemstack.getItem().hasContainerItem(itemstack))
{
- this.brewingItemStacks[3] = new ItemStack(itemstack.getItem().getContainerItem());
+ this.brewingItemStacks[3] = itemstack.getItem().getContainerItem(itemstack);
}
else
{
++++ END PATCH
++++ REJECTED PATCH 6
public boolean isItemValidForSlot(int index, ItemStack stack)
{
- return index == 3 ? stack.getItem().isPotionIngredient(stack) : stack.getItem() == Items.potionitem || stack.getItem() == Items.glass_bottle;
+ if (index == 3 && net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidIngredient(stack)) return true;
+ else if (index != 3 && net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidInput(stack)) return true;
+ return false;
}
public boolean[] func_174902_m()
++++ END PATCH
@@ -1,9 +0,0 @@
++++ REJECTED PATCH 1
return this;
}
- @SideOnly(Side.CLIENT)
public String getFormattingCode()
{
if (this.isEmpty())
++++ END PATCH
@@ -1,10 +0,0 @@
++++ REJECTED PATCH 1
import java.util.Iterator;
import java.util.Map;
import java.util.Random;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
public enum EnumFacing implements IStringSerializable
{
++++ END PATCH
@@ -1,9 +0,0 @@
++++ REJECTED PATCH 1
String getUnformattedText();
- @SideOnly(Side.CLIENT)
String getFormattedText();
List<IChatComponent> getSiblings();
++++ END PATCH
@@ -1,14 +0,0 @@
++++ REJECTED PATCH 1
public Vec3 hitVec;
public Entity entityHit;
+ /** Used to determine what sub-segment is hit */
+ public int subHit = -1;
+
+ /** Used to add extra hit info */
+ public Object hitInfo = null;
+
public MovingObjectPosition(Vec3 hitVecIn, EnumFacing facing, BlockPos blockPosIn)
{
this(MovingObjectPosition.MovingObjectType.BLOCK, hitVecIn, facing, blockPosIn);
++++ END PATCH
@@ -1,27 +0,0 @@
++++ REJECTED PATCH 1
package net.minecraft.util;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.Validate;
public class ResourceLocation
++++ END PATCH
++++ REJECTED PATCH 2
this(0, splitObjectName(resourceName));
}
- @SideOnly(Side.CLIENT)
public ResourceLocation(String resourceDomainIn, String resourcePathIn)
{
this(0, new String[] {resourceDomainIn, resourcePathIn});
++++ END PATCH
++++ REJECTED PATCH 3
return this.resourcePath;
}
- @SideOnly(Side.CLIENT)
public String getResourceDomain()
{
return this.resourceDomain;
++++ END PATCH
@@ -1,21 +0,0 @@
++++ REJECTED PATCH 4
return this.sessionType;
}
+ /* ======================================== 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
{
++++ END PATCH
@@ -1,37 +0,0 @@
++++ REJECTED PATCH 1
package net.minecraft.util;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
public class Vec3
{
public final double xCoord;
++++ END PATCH
++++ REJECTED PATCH 2
this((double)p_i46377_1_.getX(), (double)p_i46377_1_.getY(), (double)p_i46377_1_.getZ());
}
- @SideOnly(Side.CLIENT)
public Vec3 subtractReverse(Vec3 vec)
{
return new Vec3(vec.xCoord - this.xCoord, vec.yCoord - this.yCoord, vec.zCoord - this.zCoord);
++++ END PATCH
++++ REJECTED PATCH 3
return this.xCoord * vec.xCoord + this.yCoord * vec.yCoord + this.zCoord * vec.zCoord;
}
- @SideOnly(Side.CLIENT)
public Vec3 crossProduct(Vec3 vec)
{
return new Vec3(this.yCoord * vec.zCoord - this.zCoord * vec.yCoord, this.zCoord * vec.xCoord - this.xCoord * vec.zCoord, this.xCoord * vec.yCoord - this.yCoord * vec.xCoord);
++++ END PATCH
++++ REJECTED PATCH 4
return new Vec3(this.xCoord + x, this.yCoord + y, this.zCoord + z);
}
- @SideOnly(Side.CLIENT)
public double distanceTo(Vec3 vec)
{
double d0 = vec.xCoord - this.xCoord;
++++ END PATCH
@@ -1,67 +0,0 @@
++++ REJECTED PATCH 1
for (int i = 0; i < max; ++i)
{
WeightedRandomChestContent weightedrandomchestcontent = (WeightedRandomChestContent)WeightedRandom.getRandomItem(random, listIn);
- int j = weightedrandomchestcontent.minStackSize + random.nextInt(weightedrandomchestcontent.maxStackSize - weightedrandomchestcontent.minStackSize + 1);
+ ItemStack[] stacks = weightedrandomchestcontent.generateChestContent(random, inv);
- if (weightedrandomchestcontent.theItemId.getMaxStackSize() >= j)
+ for (ItemStack itemstack1 : stacks)
{
- ItemStack itemstack1 = weightedrandomchestcontent.theItemId.copy();
- itemstack1.stackSize = j;
inv.setInventorySlotContents(random.nextInt(inv.getSizeInventory()), itemstack1);
}
- else
- {
- for (int k = 0; k < j; ++k)
- {
- ItemStack itemstack = weightedrandomchestcontent.theItemId.copy();
- itemstack.stackSize = 1;
- inv.setInventorySlotContents(random.nextInt(inv.getSizeInventory()), itemstack);
- }
- }
}
}
+ // -- Forge hooks
+ /**
+ * Allow a mod to submit a custom implementation that can delegate item stack generation beyond simple stack lookup
+ *
+ * @param random The current random for generation
+ * @param newInventory The inventory being generated (do not populate it, but you can refer to it)
+ * @return An array of {@link ItemStack} to put into the chest
+ */
+ protected ItemStack[] generateChestContent(Random random, IInventory newInventory)
+ {
+ return net.minecraftforge.common.ChestGenHooks.generateStacks(random, theItemId, minStackSize, maxStackSize);
+ }
+
public static void generateDispenserContents(Random random, List<WeightedRandomChestContent> listIn, TileEntityDispenser dispenser, int max)
{
for (int i = 0; i < max; ++i)
{
WeightedRandomChestContent weightedrandomchestcontent = (WeightedRandomChestContent)WeightedRandom.getRandomItem(random, listIn);
- int j = weightedrandomchestcontent.minStackSize + random.nextInt(weightedrandomchestcontent.maxStackSize - weightedrandomchestcontent.minStackSize + 1);
+ ItemStack[] stacks = weightedrandomchestcontent.generateChestContent(random, dispenser);
- if (weightedrandomchestcontent.theItemId.getMaxStackSize() >= j)
+ for (ItemStack itemstack1 : stacks)
{
- ItemStack itemstack1 = weightedrandomchestcontent.theItemId.copy();
- itemstack1.stackSize = j;
dispenser.setInventorySlotContents(random.nextInt(dispenser.getSizeInventory()), itemstack1);
}
- else
- {
- for (int k = 0; k < j; ++k)
- {
- ItemStack itemstack = weightedrandomchestcontent.theItemId.copy();
- itemstack.stackSize = 1;
- dispenser.setInventorySlotContents(random.nextInt(dispenser.getSizeInventory()), itemstack);
- }
- }
}
}
++++ END PATCH
@@ -1,11 +1,8 @@
package net.minecraftforge.common.brewing;
import java.util.List;
import net.minecraft.init.Items;
import net.minecraft.item.ItemPotion;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.potion.PotionHelper;
/**
@@ -21,7 +18,8 @@ public class VanillaBrewingRecipe implements IBrewingRecipe {
@Override
public boolean isInput(ItemStack stack)
{
return stack.getItem() instanceof ItemPotion || stack.getItem() == Items.glass_bottle;
Item item = stack.getItem();
return item == Items.potionitem || item == Items.field_185155_bH || item == Items.field_185156_bI || item == Items.glass_bottle;
}
/**
@@ -30,7 +28,7 @@ public class VanillaBrewingRecipe implements IBrewingRecipe {
@Override
public boolean isIngredient(ItemStack stack)
{
return stack.getItem().isPotionIngredient(stack);
return PotionHelper.func_185205_a(stack);
}
/**
@@ -41,34 +39,14 @@ public class VanillaBrewingRecipe implements IBrewingRecipe {
@Override
public ItemStack getOutput(ItemStack input, ItemStack ingredient)
{
if (ingredient != null && input != null && input.getItem() instanceof ItemPotion && isIngredient(ingredient))
if (ingredient != null && input != null && isIngredient(ingredient))
{
int inputMeta = input.getMetadata();
int outputMeta = PotionHelper.applyIngredient(inputMeta, ingredient.getItem().getPotionEffect(ingredient));
if (inputMeta == outputMeta)
ItemStack result = PotionHelper.func_185212_d(ingredient, input);
if (result != input)
{
return null;
}
List<PotionEffect> oldEffects = Items.potionitem.getEffects(inputMeta);
List<PotionEffect> newEffects = Items.potionitem.getEffects(outputMeta);
boolean hasResult = false;
if ((inputMeta <= 0 || oldEffects != newEffects) && (oldEffects == null || !oldEffects.equals(newEffects) && newEffects != null))
{
hasResult = true;
}
else if (!ItemPotion.isSplash(inputMeta) && ItemPotion.isSplash(outputMeta))
{
hasResult = true;
}
if (hasResult)
{
ItemStack output = input.copy();
output.setItemDamage(outputMeta);
return output;
return result;
}
return null;
}
return null;
@@ -34,7 +34,7 @@ import org.apache.logging.log4j.Level;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StringTranslate;
import net.minecraft.util.text.translation.LanguageMap;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.Loader;
@@ -241,7 +241,7 @@ public class LanguageRegistry
}
}
public void injectLanguage(String language, HashMap<String, String> parsedLangFile)
public void injectLanguage(String language, Map<String, String> parsedLangFile)
{
Properties p = modLanguageData.get(language);
@@ -285,11 +285,11 @@ public class LanguageRegistry
String lang = matcher.group(2);
//FMLLog.fine("Injecting found translation data for lang %s in zip file %s at %s into language system", lang, source.getName(), ze.getName());
added.add(lang);
LanguageRegistry.instance().injectLanguage(lang, StringTranslate.parseLangFile(zf.getInputStream(ze)));
LanguageRegistry.instance().injectLanguage(lang, LanguageMap.parseLangFile(zf.getInputStream(ze)));
// Ensure en_US is available to StringTranslate on the server
if ("en_US".equals(lang) && side == Side.SERVER)
{
StringTranslate.inject(zf.getInputStream(ze));
LanguageMap.inject(zf.getInputStream(ze));
}
}
}
@@ -312,11 +312,11 @@ public class LanguageRegistry
{
String lang = matcher.group(2);
FMLLog.fine("Injecting found translation assets for lang %s at %s into language system", lang, currPath);
LanguageRegistry.instance().injectLanguage(lang, StringTranslate.parseLangFile(new FileInputStream(file)));
LanguageRegistry.instance().injectLanguage(lang, LanguageMap.parseLangFile(new FileInputStream(file)));
// Ensure en_US is available to StringTranslate on the server
if ("en_US".equals(lang) && side == Side.SERVER)
{
StringTranslate.inject(new FileInputStream(file));
LanguageMap.inject(new FileInputStream(file));
}
}
}