forked from MinecraftForge/MinecraftForge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow custom DataSerializers to be registered safely (MinecraftForge#…
- Loading branch information
1 parent
1f12642
commit 208ed99
Showing
5 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
patches/minecraft/net/minecraft/network/datasync/DataSerializers.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- ../src-base/minecraft/net/minecraft/network/datasync/DataSerializers.java | ||
+++ ../src-work/minecraft/net/minecraft/network/datasync/DataSerializers.java | ||
@@ -305,20 +305,21 @@ | ||
} | ||
}; | ||
|
||
+ @Deprecated // Forge: ONLY FOR VANILLA - mods should use the Forge registry | ||
public static void func_187189_a(DataSerializer<?> p_187189_0_) | ||
{ | ||
- field_187204_n.func_186808_c(p_187189_0_); | ||
+ if (field_187204_n.func_186808_c(p_187189_0_) >= 256) throw new RuntimeException("Vanilla DataSerializer ID limit exceeded"); | ||
} | ||
|
||
@Nullable | ||
public static DataSerializer<?> func_187190_a(int p_187190_0_) | ||
{ | ||
- return (DataSerializer)field_187204_n.func_186813_a(p_187190_0_); | ||
+ return net.minecraftforge.common.ForgeHooks.getSerializer(p_187190_0_, field_187204_n); | ||
} | ||
|
||
public static int func_187188_b(DataSerializer<?> p_187188_0_) | ||
{ | ||
- return field_187204_n.func_186815_a(p_187188_0_); | ||
+ return net.minecraftforge.common.ForgeHooks.getSerializerId(p_187188_0_, field_187204_n); | ||
} | ||
|
||
static |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/net/minecraftforge/registries/DataSerializerEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Minecraft Forge | ||
* Copyright (c) 2016-2018. | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation version 2.1 | ||
* of the License. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
package net.minecraftforge.registries; | ||
|
||
import net.minecraft.network.datasync.DataSerializer; | ||
|
||
public final class DataSerializerEntry extends IForgeRegistryEntry.Impl<DataSerializerEntry> | ||
{ | ||
private final DataSerializer<?> serializer; | ||
|
||
public DataSerializerEntry(DataSerializer<?> serializer) | ||
{ | ||
this.serializer = serializer; | ||
} | ||
|
||
public DataSerializer<?> getSerializer() | ||
{ | ||
return serializer; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters