Networking fix
This commit is contained in:
parent
0f82dbc35f
commit
adc7849c10
5 changed files with 21 additions and 21 deletions
|
@ -37,4 +37,8 @@ public class BetterEnd implements ModInitializer {
|
||||||
public static Identifier getResId(String path) {
|
public static Identifier getResId(String path) {
|
||||||
return new Identifier(MOD_ID, path);
|
return new Identifier(MOD_ID, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getStringId(String id) {
|
||||||
|
return String.format("%s:%s", MOD_ID, id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraft.util.thread.ThreadExecutor;
|
||||||
import ru.betterend.blocks.entities.ESignBlockEntity;
|
import ru.betterend.blocks.entities.ESignBlockEntity;
|
||||||
import ru.betterend.client.gui.BlockSignEditScreen;
|
import ru.betterend.client.gui.BlockSignEditScreen;
|
||||||
|
|
||||||
@Mixin(value = ClientPlayNetworkHandler.class, priority = 1000)
|
@Mixin(ClientPlayNetworkHandler.class)
|
||||||
public class ClientPlayNetworkHandlerMixin
|
public class ClientPlayNetworkHandlerMixin
|
||||||
{
|
{
|
||||||
@Shadow
|
@Shadow
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class AlloyingRecipe implements Recipe<Inventory> {
|
||||||
|
|
||||||
public static Builder create(String id) {
|
public static Builder create(String id) {
|
||||||
INSTANCE.id = BetterEnd.getResId(id);
|
INSTANCE.id = BetterEnd.getResId(id);
|
||||||
INSTANCE.group = String.format("%s:%s", GROUP, id);
|
INSTANCE.group = String.format("%s_%s", GROUP, id);
|
||||||
INSTANCE.primaryInput = null;
|
INSTANCE.primaryInput = null;
|
||||||
INSTANCE.secondaryInput = null;
|
INSTANCE.secondaryInput = null;
|
||||||
INSTANCE.output = null;
|
INSTANCE.output = null;
|
||||||
|
|
|
@ -32,24 +32,12 @@ public class AlloyingRecipeSerializer implements RecipeSerializer<AlloyingRecipe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlloyingRecipe read(Identifier id, PacketByteBuf packetBuffer) {
|
public AlloyingRecipe read(Identifier id, PacketByteBuf packetBuffer) {
|
||||||
String group = packetBuffer.readString();
|
Identifier recipeId = packetBuffer.readIdentifier();
|
||||||
Ingredient primaryInput = Ingredient.fromPacket(packetBuffer);
|
return (AlloyingRecipe) EndRecipeManager.getRecipe(AlloyingRecipe.TYPE, recipeId);
|
||||||
Ingredient secondaryInput = Ingredient.fromPacket(packetBuffer);
|
|
||||||
ItemStack output = packetBuffer.readItemStack();
|
|
||||||
float experience = packetBuffer.readFloat();
|
|
||||||
int smeltTime = packetBuffer.readVarInt();
|
|
||||||
|
|
||||||
return new AlloyingRecipe(id, group, primaryInput, secondaryInput, output, experience, smeltTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(PacketByteBuf packetBuffer, AlloyingRecipe recipe) {
|
public void write(PacketByteBuf packetBuffer, AlloyingRecipe recipe) {
|
||||||
packetBuffer.writeString(recipe.group);
|
packetBuffer.writeIdentifier(recipe.id);
|
||||||
recipe.primaryInput.write(packetBuffer);
|
|
||||||
recipe.secondaryInput.write(packetBuffer);
|
|
||||||
packetBuffer.writeItemStack(recipe.output);
|
|
||||||
packetBuffer.writeFloat(recipe.experience);
|
|
||||||
packetBuffer.writeInt(recipe.smeltTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,13 @@ public class EndRecipeManager {
|
||||||
list.put(recipe.getId(), recipe);
|
list.put(recipe.getId(), recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Recipe<?> getRecipe(RecipeType<?> type, Identifier id) {
|
||||||
|
if (RECIPES.containsKey(type)) {
|
||||||
|
return RECIPES.get(type).get(id);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static Map<RecipeType<?>, Map<Identifier, Recipe<?>>> getMap(Map<RecipeType<?>, Map<Identifier, Recipe<?>>> recipes) {
|
public static Map<RecipeType<?>, Map<Identifier, Recipe<?>>> getMap(Map<RecipeType<?>, Map<Identifier, Recipe<?>>> recipes) {
|
||||||
Map<RecipeType<?>, Map<Identifier, Recipe<?>>> result = Maps.newHashMap();
|
Map<RecipeType<?>, Map<Identifier, Recipe<?>>> result = Maps.newHashMap();
|
||||||
|
|
||||||
|
@ -53,13 +60,14 @@ public class EndRecipeManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
static <S extends RecipeSerializer<T>, T extends Recipe<?>> S registerSerializer(String id, S serializer) {
|
static <S extends RecipeSerializer<T>, T extends Recipe<?>> S registerSerializer(String id, S serializer) {
|
||||||
return Registry.register(Registry.RECIPE_SERIALIZER, BetterEnd.getResId(id), serializer);
|
return Registry.register(Registry.RECIPE_SERIALIZER, BetterEnd.getStringId(id), serializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static <T extends Recipe<?>> RecipeType<T> registerType(String name) {
|
static <T extends Recipe<?>> RecipeType<T> registerType(String type) {
|
||||||
return Registry.register(Registry.RECIPE_TYPE, BetterEnd.getResId(name), new RecipeType<T>() {
|
Identifier recipeTypeId = BetterEnd.getResId(type);
|
||||||
|
return Registry.register(Registry.RECIPE_TYPE, recipeTypeId, new RecipeType<T>() {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
return type;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue