Jump to content

MultiCoder

Members
  • Posts

    8
  • Joined

  • Last visited

MultiCoder's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I have found my issue, I had forgotten to put the register inside the enqueueWork Runnable
  2. My mod is not loading on a dedicated server that I'm using for beta testing features the crash report is below. Crash Report I followed a tutorial to create the classes to run the networking. My current code is below. One thing to note is that the mod runs on client side without an issue. package org.multicoder.mcpaintball.network; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraftforge.network.NetworkDirection; import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.network.PacketDistributor; import net.minecraftforge.network.simple.SimpleChannel; import org.multicoder.mcpaintball.MCPaintball; import org.multicoder.mcpaintball.network.packets.*; public class Networking { private static SimpleChannel INSTANCE; private static int id = 0; private static int ID(){ return id++; } public static void Register() { SimpleChannel net = NetworkRegistry.ChannelBuilder.named(new ResourceLocation(MCPaintball.MODID,"messsage")).networkProtocolVersion(() -> "1.0.0").clientAcceptedVersions(s -> true) .serverAcceptedVersions(s -> true).simpleChannel(); INSTANCE = net; net.messageBuilder(TeamPointS2CPacket.class,ID(),NetworkDirection.PLAY_TO_CLIENT).decoder(TeamPointS2CPacket::new).encoder(TeamPointS2CPacket::toBytes).consumerMainThread(TeamPointS2CPacket::Handle).add(); net.messageBuilder(TeamUpdateS2CPacket.class,ID(),NetworkDirection.PLAY_TO_CLIENT).decoder(TeamUpdateS2CPacket::new).encoder(TeamUpdateS2CPacket::toBytes).consumerMainThread(TeamUpdateS2CPacket::Handle).add(); net.messageBuilder(PlayLowClassSoundS2CPacket.class,ID(),NetworkDirection.PLAY_TO_CLIENT).decoder(PlayLowClassSoundS2CPacket::new).encoder(PlayLowClassSoundS2CPacket::toBytes).consumerMainThread(PlayLowClassSoundS2CPacket::Handle).add(); net.messageBuilder(PlayHighClassSoundS2CPacket.class,ID(),NetworkDirection.PLAY_TO_CLIENT).decoder(PlayHighClassSoundS2CPacket::new).encoder(PlayHighClassSoundS2CPacket::toBytes).consumerMainThread(PlayHighClassSoundS2CPacket::Handle).add(); net.messageBuilder(TeamUpdateC2SPacket.class,ID(),NetworkDirection.PLAY_TO_SERVER).decoder(TeamUpdateC2SPacket::new).encoder(TeamUpdateC2SPacket::toBytes).consumerMainThread(TeamUpdateC2SPacket::Handle).add(); } public static <MSG> void SendToServer(MSG message) { INSTANCE.sendToServer(message); } public static <MSG> void sendToPlayer(MSG message, ServerPlayer player) {INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), message);} public static <MSG> void sendToClients(MSG message) {INSTANCE.send(PacketDistributor.ALL.noArg(), message);} } @Mod(MCPaintball.MODID) public class MCPaintball { public static final String MODID = "mcpaintball"; public static final Logger LOG = LogManager.getLogger(MODID); public MCPaintball() { ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, MCPaintballConfig.SPEC,"mcpaintball-common.toml"); IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); bus.register(this); bus.addListener(this::OnCommon); } private void OnCommon(FMLCommonSetupEvent event) { event.enqueueWork(() -> { BlockHolder.AppendList(); }); Networking.Register(); } // Removed Unnessacery things from file to shrink its size }
  3. Thank you for that. It has fixed the problem.
  4. import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.animal.Cow; import net.minecraft.world.entity.projectile.AbstractArrow; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.phys.EntityHitResult; import org.multicoder.mcpaintball.init.entityinit; import org.multicoder.mcpaintball.init.soundinit; public class BluePaintballArrowEntity extends AbstractArrow { public BluePaintballArrowEntity(EntityType<? extends Entity> p_36858_, Level p_36859_) {super((EntityType<? extends AbstractArrow>) p_36858_, p_36859_);} public BluePaintballArrowEntity(Level p_36861_, double p_36862_, double p_36863_, double p_36864_) {super((EntityType<? extends AbstractArrow>) entityinit.BLUE_PAINTBALL.get(), p_36862_, p_36863_, p_36864_,p_36861_);} public BluePaintballArrowEntity(Level p_36866_, LivingEntity p_36867_) {super((EntityType<? extends AbstractArrow>) entityinit.BLUE_PAINTBALL.get(), p_36867_,p_36866_);} @Override protected SoundEvent getDefaultHitGroundSoundEvent() {return null;} @Override protected ItemStack getPickupItem() {return ItemStack.EMPTY;} @Override protected void onHitEntity(EntityHitResult p_36757_) { if (p_36757_.getEntity() instanceof Cow) {getOwner().playSound(soundinit.DING.get(),1.0f,1.0f);} } } This is the entity file. The debug and log GIST I'm unsure why this error occurs, can anyone explain what is causing the issue. I have narrowed down the error to the additional save data method, it seems to be a resource location but what is it looking for
  5. Right I was not aware of the abstract arrow was what had both constructors. I thought that both abstract arrow and arrow has both constructors
  6. I am trying to add a few custom arrows for a project i'm currently working on. I have the classes all there and setup however there are some errors on a couple of constructors (see below) import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.projectile.AbstractArrow; import net.minecraft.world.entity.projectile.Arrow; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.phys.EntityHitResult; import org.multicoder.mcpaintball.init.entityinit; public class RedPaintballArrowEntity extends Arrow { public RedPaintballArrowEntity(EntityType<? extends RedPaintballArrowEntity> p_36858_, Level p_36859_) { super(p_36858_, p_36859_); } public RedPaintballArrowEntity(Level p_36861_, double p_36862_, double p_36863_, double p_36864_) { super(entityinit.RED_PAINTBALL.get(),p_36861_, p_36862_, p_36863_, p_36864_); } public RedPaintballArrowEntity(Level p_36866_, LivingEntity p_36867_) { super(entityinit.RED_PAINTBALL.get(), p_36866_, p_36867_); } @Override protected ItemStack getPickupItem() { return ItemStack.EMPTY; } @Override protected void onHitEntity(EntityHitResult p_36757_) { } } The error is with the bottom 2 constructors and it is saying cannot resolve method 'super', I am completely stuck on what to do or why this is happening to begin with. Am I missing something. import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MobCategory; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; import org.multicoder.mcpaintball.MCPaintball; import org.multicoder.mcpaintball.entity.RedPaintballArrowEntity; public class entityinit { public static final DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITIES, MCPaintball.MODID); public static final RegistryObject<EntityType<RedPaintballArrowEntity>> RED_PAINTBALL = ENTITY_TYPES.register("red_paintball",() -> EntityType.Builder.of(RedPaintballArrowEntity::new, MobCategory.MISC).sized(0.5f,0.5f).build("red_paintball")); } This is my entitytype register.
  7. Could you explain what you mean by that, just to clarify I am trying to create a recipe type that handles potions and I'm pretty sure the standard recipe type cannot handle nbt data within the recipe. Do you mean use minecraft:crafting_shapeless as the type in the json file or am I misinterpreting
  8. I have a custom recipe type that has successfully registered into minecraft, however I am trying to get it to work on the standard crafting table as it doesn't need a custom table for it. { "type": "randomfhings:potion_edible", "ingredients": [ { "item" : "minecraft:glass", "data": "" }, { "item" : "minecraft:diamond" } ], "output": { "item": "randomfhings:ruby", "count": 3 } } This is a test recipe so far . package org.multicoder.randomfhings.recipe; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import net.minecraft.core.NonNullList; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.GsonHelper; import net.minecraft.world.inventory.CraftingContainer; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.*; import net.minecraft.world.level.Level; import org.multicoder.randomfhings.RandomFhings; import javax.annotation.Nullable; public class PotionRecipe implements Recipe<CraftingContainer> { private final ResourceLocation id; private final ItemStack output; private final NonNullList<Ingredient> input; public PotionRecipe(ResourceLocation id, ItemStack output, NonNullList<Ingredient> input) { this.id = id; this.output = output; this.input = input; } @Override public NonNullList<Ingredient> getIngredients() { return input; } @Override public boolean matches(CraftingContainer p_44002_, Level p_44003_) { return input.get(0).test(p_44002_.getItem(0)); } @Override public ItemStack assemble(CraftingContainer p_44001_) { return output.copy(); } @Override public boolean canCraftInDimensions(int p_43999_, int p_44000_) { return true; } @Override public ItemStack getResultItem() { return output; } @Override public ResourceLocation getId() { return id; } @Override public RecipeSerializer<?> getSerializer() { return Serializer.INSTANCE; } @Override public RecipeType<?> getType() { return Type.INSTANCE; } public static class Type implements RecipeType<PotionRecipe> { private Type() { } public static final Type INSTANCE = new Type(); public static final String ID = "potion_edible"; } public static class Serializer implements RecipeSerializer<PotionRecipe> { public static final Serializer INSTANCE = new Serializer(); public static final ResourceLocation ID = new ResourceLocation(RandomFhings.MOD_ID,"potion_edible"); @Override public PotionRecipe fromJson(ResourceLocation id, JsonObject json) { ItemStack output = ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(json, "output")); JsonArray ingredients = GsonHelper.getAsJsonArray(json, "ingredients"); NonNullList<Ingredient> inputs = NonNullList.withSize(2, Ingredient.EMPTY); for (int i = 0; i < inputs.size(); i++) { inputs.set(i, Ingredient.fromJson(ingredients.get(i))); } return new PotionRecipe(id, output, inputs); } @Override public PotionRecipe fromNetwork(ResourceLocation id, FriendlyByteBuf buf) { NonNullList<Ingredient> inputs = NonNullList.withSize(buf.readInt(), Ingredient.EMPTY); for (int i = 0; i < inputs.size(); i++) { inputs.set(i, Ingredient.fromNetwork(buf)); } ItemStack output = buf.readItem(); return new PotionRecipe(id, output, inputs); } @Override public void toNetwork(FriendlyByteBuf buf, PotionRecipe recipe) { buf.writeInt(recipe.getIngredients().size()); for (Ingredient ing : recipe.getIngredients()) { ing.toNetwork(buf); } buf.writeItemStack(recipe.getResultItem(), false); } @Override public RecipeSerializer<?> setRegistryName(ResourceLocation name) { return INSTANCE; } @Nullable @Override public ResourceLocation getRegistryName() { return ID; } @Override public Class<RecipeSerializer<?>> getRegistryType() { return Serializer.castClass(RecipeSerializer.class); } @SuppressWarnings("unchecked") // Need this wrapper, because generics private static <G> Class<G> castClass(Class<?> cls) { return (Class<G>)cls; } } } This is my recipe type class and it is registered via a deferred register.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.