mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-23 21:49:46 +00:00
Restore binary compatibility issues in FluidRegistry caused by recent changes.
This commit is contained in:
1 parent
1fd39578b0
commit
02ebc9ca21
2 files changed
+27
-5
No files matched your search
@@ -14,14 +14,14 @@ public abstract class ForgeMessage {
|
|||||||
int dimensionId;
|
int dimensionId;
|
||||||
/** The provider ID to register with dimension on client */
|
/** The provider ID to register with dimension on client */
|
||||||
int providerId;
|
int providerId;
|
||||||
|
|
||||||
public DimensionRegisterMessage(){}
|
public DimensionRegisterMessage(){}
|
||||||
public DimensionRegisterMessage(int dimensionId, int providerId)
|
public DimensionRegisterMessage(int dimensionId, int providerId)
|
||||||
{
|
{
|
||||||
this.dimensionId = dimensionId;
|
this.dimensionId = dimensionId;
|
||||||
this.providerId = providerId;
|
this.providerId = providerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void toBytes(ByteBuf bytes)
|
void toBytes(ByteBuf bytes)
|
||||||
{
|
{
|
||||||
@@ -42,7 +42,7 @@ public abstract class ForgeMessage {
|
|||||||
@Override
|
@Override
|
||||||
void toBytes(ByteBuf bytes)
|
void toBytes(ByteBuf bytes)
|
||||||
{
|
{
|
||||||
Map<Fluid, Integer> ids = FluidRegistry.getRegisteredFluidIDs();
|
Map<Fluid, Integer> ids = FluidRegistry.getRegisteredFluidIDsByFluid();
|
||||||
bytes.writeInt(ids.size());
|
bytes.writeInt(ids.size());
|
||||||
for (Map.Entry<Fluid, Integer> entry : ids.entrySet())
|
for (Map.Entry<Fluid, Integer> entry : ids.entrySet())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package net.minecraftforge.fluids;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
@@ -28,6 +29,7 @@ public abstract class FluidRegistry
|
|||||||
|
|
||||||
static BiMap<String, Fluid> fluids = HashBiMap.create();
|
static BiMap<String, Fluid> fluids = HashBiMap.create();
|
||||||
static BiMap<Fluid, Integer> fluidIDs = HashBiMap.create();
|
static BiMap<Fluid, Integer> fluidIDs = HashBiMap.create();
|
||||||
|
static BiMap<Integer, String> fluidNames = HashBiMap.create(); //Caching this just makes some other calls faster
|
||||||
static BiMap<Block, Fluid> fluidBlocks;
|
static BiMap<Block, Fluid> fluidBlocks;
|
||||||
|
|
||||||
public static final Fluid WATER = new Fluid("water") {
|
public static final Fluid WATER = new Fluid("water") {
|
||||||
@@ -63,6 +65,9 @@ public abstract class FluidRegistry
|
|||||||
maxID = newfluidIDs.size();
|
maxID = newfluidIDs.size();
|
||||||
fluidIDs.clear();
|
fluidIDs.clear();
|
||||||
fluidIDs.putAll(newfluidIDs);
|
fluidIDs.putAll(newfluidIDs);
|
||||||
|
fluidNames.clear();
|
||||||
|
for (Entry<Fluid, Integer> e : fluidIDs.entrySet())
|
||||||
|
fluidNames.put(e.getValue(), e.getKey().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,6 +86,7 @@ public abstract class FluidRegistry
|
|||||||
}
|
}
|
||||||
fluids.put(fluid.getName(), fluid);
|
fluids.put(fluid.getName(), fluid);
|
||||||
fluidIDs.put(fluid, ++maxID);
|
fluidIDs.put(fluid, ++maxID);
|
||||||
|
fluidNames.put(maxID, fluid.getName());
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.post(new FluidRegisterEvent(fluid.getName(), maxID));
|
MinecraftForge.EVENT_BUS.post(new FluidRegisterEvent(fluid.getName(), maxID));
|
||||||
return true;
|
return true;
|
||||||
@@ -116,6 +122,12 @@ public abstract class FluidRegistry
|
|||||||
return fluidIDs.get(getFluid(fluidName));
|
return fluidIDs.get(getFluid(fluidName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated //Remove in 1.8.3
|
||||||
|
public static String getFluidName(int fluidID)
|
||||||
|
{
|
||||||
|
return fluidNames.get(fluidID);
|
||||||
|
}
|
||||||
|
|
||||||
public static String getFluidName(Fluid fluid)
|
public static String getFluidName(Fluid fluid)
|
||||||
{
|
{
|
||||||
return fluids.inverse().get(fluid);
|
return fluids.inverse().get(fluid);
|
||||||
@@ -144,9 +156,19 @@ public abstract class FluidRegistry
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a read-only map containing Fluid IDs and their associated Fluids.
|
* Returns a read-only map containing Fluid Names and their associated IDs.
|
||||||
*/
|
*/
|
||||||
public static Map<Fluid, Integer> getRegisteredFluidIDs()
|
@Deprecated //Change return type to <Fluid, Integer> in 1.8.3
|
||||||
|
public static Map<String, Integer> getRegisteredFluidIDs()
|
||||||
|
{
|
||||||
|
return ImmutableMap.copyOf(fluidNames.inverse());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a read-only map containing Fluid IDs and their associated Fluids.
|
||||||
|
* In 1.8.3, this will change to just 'getRegisteredFluidIDs'
|
||||||
|
*/
|
||||||
|
public static Map<Fluid, Integer> getRegisteredFluidIDsByFluid()
|
||||||
{
|
{
|
||||||
return ImmutableMap.copyOf(fluidIDs);
|
return ImmutableMap.copyOf(fluidIDs);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user