Jump to content

Packets being sent but not recieved!


AskHow1248

Recommended Posts

I have a IPlayerTracker that is supposed to send a packet to the server when a player logs in.  It sends the packets, but they are never recieved!

 

Here is my code:

 

Player Tracker:

 

 

package Technomage3.both.Common;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import cpw.mods.fml.common.IPlayerTracker;
import cpw.mods.fml.common.network.PacketDispatcher;
import Technomage3.both.ModInfo;
import Technomage3.both.Blocks.tileentities.TileEntityMagicPathway;
import Technomage3.both.Network.TMPacketHandeler;
import Technomage3.both.Network.TMPackets;
import am2.PlayerTracker;

public class TMPlayerTracker implements IPlayerTracker {

@Override
public void onPlayerLogin(EntityPlayer player) {

	System.out.println("TechMagic Player login");
	NBTTagCompound toSend = new NBTTagCompound();
	PacketDispatcher.sendPacketToServer(TMPacketHandeler.getNBTPacket(toSend, ModInfo.channel, TMPackets.magicPathwayRead));



}

@Override
public void onPlayerLogout(EntityPlayer player) {

}

@Override
public void onPlayerChangedDimension(EntityPlayer player) {

}

@Override
public void onPlayerRespawn(EntityPlayer player) {

}

}

 

 

 

Packet Handeler:

 

 

package Technomage3.both.Network;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteStreams;

import Technomage3.Core.Utils.TN3DataReader;
import Technomage3.Core.Utils.TN3DataWriter;
import Technomage3.both.ModInfo;
import Technomage3.both.Blocks.tileentities.TileEntityMageForge;
import Technomage3.both.Blocks.tileentities.TileEntityMagicPathway;
import Technomage3.both.Interfaces.containers.ContainerMageForge;
import Technomage3.both.Items.ItemKeystone;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;

public class TMPacketHandeler implements IPacketHandler {



@Override
public void onPacketData(INetworkManager manager,
		Packet250CustomPayload packet, Player player) {

	NBTTagCompound tag = TN3DataReader.readNBTPacket(packet);

	System.out.println("Caught packet with id " + tag.getInteger("PacketID"));
	World world = Minecraft.getMinecraft().theWorld;
	switch(tag.getInteger("PacketID")){

	case TMPackets.magicPathwayRead:


		int[] cords = tag.getIntArray("Cords");
		System.out.println("Caught Magic pathway packet with cords (" + cords[0] + ", " + cords[1] + ", " + cords[2] + ")");
		TileEntityMagicPathway t = (TileEntityMagicPathway) world.getBlockTileEntity(cords[0], cords[1], cords[2]);
		t.recieveUpdatePacket(tag);

	case TMPackets.playerLogin:
		System.out.println("TechMagic Player login packet recieved");
		for(Object o : world.loadedTileEntityList)
			if(o instanceof TileEntityMagicPathway)
				((TileEntityMagicPathway) o).sendUpdatePacket();

	}



}

public static Packet250CustomPayload getNBTPacket(NBTTagCompound nbt, String channel, int id){
	return TN3DataWriter.getNBTPacket(id, channel, nbt);
}


}

 

 

 

Main mod class:

 

 

package Technomage3.both;

import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import Technomage3.both.AncientSpells.AncientSpellStaff;
import Technomage3.both.AncientSpells.AncientSpells;
import Technomage3.both.Blocks.TMBlocks;
import Technomage3.both.Blocks.tileentities.TileEntityMageForge;
import Technomage3.both.Blocks.tileentities.TileEntityMagicPathway;
import Technomage3.both.Blocks.tileentities.recipies.MageForgeRecipie;
import Technomage3.both.Common.ChatHandeler;
import Technomage3.both.Common.TMEventHandeler;
import Technomage3.both.Common.TMPlayerTracker;
import Technomage3.both.Config.TMConfigHandeler;
import Technomage3.both.Entities.TMEntities;
import Technomage3.both.Interfaces.TMGUIHandeler;
import Technomage3.both.Items.TMItems;
import Technomage3.both.Network.TMPacketHandeler;
import Technomage3.both.Proxies.TMCommonProxy;
import Technomage3.both.Spell.SpellComponents;
import Technomage3.both.Spell.SpellIconRegisterer;
import Technomage3.both.World.TMGenerationHandeler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;


@Mod(modid = ModInfo.id, name = ModInfo.name, version = ModInfo.version)
@NetworkMod(channels = {ModInfo.channel}, clientSideRequired = true, serverSideRequired = true, packetHandler = TMPacketHandeler.class)
public class TechnologicalMagic {

@SidedProxy(clientSide = "Technomage3.both.Proxies.TMClientProxy", serverSide = "Technomage3.both.Proxies.TMCommonProxy")
public static TMCommonProxy proxy;

public boolean hasPerformedSucesfulLoad = false;

@Instance(ModInfo.id)
public static TechnologicalMagic instance;


@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
	TMConfigHandeler.init(event.getSuggestedConfigurationFile());

	if(event.getSide() == Side.CLIENT)
		MinecraftForge.EVENT_BUS.register(new SpellIconRegisterer());

	proxy.initRenderers();
	proxy.initSounds();

	NetworkRegistry.instance().registerChannel(new TMPacketHandeler(), ModInfo.channel);

	TMItems.init();
	TMBlocks.blockInit();
	TMEntities.init();
	AncientSpells.init();
	//SpellComponents.register();


}

@EventHandler
public void load(FMLInitializationEvent event)
{

	addCraftingRecipies();

	GameRegistry.registerPlayerTracker(new TMPlayerTracker());
	GameRegistry.registerWorldGenerator(new TMGenerationHandeler());

	MinecraftForge.EVENT_BUS.register(new ChatHandeler());
	MinecraftForge.EVENT_BUS.register(new TMEventHandeler());

	new TMGUIHandeler();

}

@EventHandler
public void postInit(FMLPostInitializationEvent event)
{

}


private static void addCraftingRecipies() {

	addMageForgeRecipies();

	GameRegistry.addRecipe(AncientSpellStaff.getStaff(AncientSpells.teleport), 

			" A ",
			" B ",
			" B ",
					'A', Item.diamond, 'B', Item.blazeRod



			);






}

private static void addMageForgeRecipies() {
	TileEntityMageForge.addRecipie(
			new MageForgeRecipie(
					new ItemStack(TMItems.metoroticIron), 

					new ItemStack(Item.diamond), 
					new ItemStack(TMItems.clestialCrystal), 
					new ItemStack(Item.blazeRod), 
					new ItemStack(Item.enderPearl), 

					100, 0, 
					new ItemStack(TMItems.brightSteel))
			);

}


}

 

 

 

Tile Entity:

 

 

package Technomage3.both.Blocks.tileentities;

import java.util.ArrayList;

import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.world.World;
import net.minecraftforge.event.Event;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.world.ChunkEvent;
import net.minecraftforge.event.world.WorldEvent;
import Technomage3.Core.Utils.TN3DataWriter;
import Technomage3.both.ModInfo;
import Technomage3.both.Items.ItemKeystone;
import Technomage3.both.Items.ItemKeystone.KeyCode;
import Technomage3.both.Items.TMItems;
import Technomage3.both.Network.TMPacketHandeler;
import Technomage3.both.Network.TMPackets;
import Technomage3.both.Power.TileEntityMagicMachine;

public class TileEntityMagicPathway extends TileEntityMagicMachine implements IInventory {

private String name = "none";

public ItemStack[] keystone = new ItemStack[1];

public void onUpdate(){

}

@Override
public void writeToNBT(NBTTagCompound nbt) {
	super.writeToNBT(nbt);

	System.out.println(worldObj.isRemote ? "Client writeToNBT" : "Server writeToNBT");
    
    nbt.setString("Name", name);

	NBTTagList items = new NBTTagList();

	for (int i = 0; i < getSizeInventory(); i++) {
		ItemStack stack = getStackInSlot(i);

		if (stack != null) {
			NBTTagCompound item = new NBTTagCompound();
			item.setByte("Slot", (byte)i);
			stack.writeToNBT(item);
			items.appendTag(item);
		}
	}

	nbt.setTag("Items", items);
}

@Override
public void readFromNBT(NBTTagCompound compound) {
	super.readFromNBT(compound);
	name = compound.getString("Name");
	NBTTagList items = compound.getTagList("Items");

	for (int i = 0; i < items.tagCount(); i++) {
		NBTTagCompound item = (NBTTagCompound)items.tagAt(i);
		int slot = item.getByte("Slot");

		if (slot >= 0 && slot < getSizeInventory()) {
			setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(item));
		}
	}
	onInventoryChanged();


}

public ArrayList<TileEntityMagicPathway> getOtherPoints(KeyCode code){

	ArrayList<TileEntityMagicPathway> list = new ArrayList<TileEntityMagicPathway>();

	for(Object o : worldObj.loadedTileEntityList){
		if(o instanceof TileEntityMagicPathway){
			TileEntityMagicPathway t = (TileEntityMagicPathway) o;
			if(t.getCode().isMatch(code) && !list.contains(t) && !t.equals(this))
				list.add(t);
		}
	}


	return list;

}



public KeyCode getCode() {
	return keystone[0] == null ? KeyCode.blank : KeyCode.getCode(keystone[0]);
}

@Override
public int getSizeInventory() {
	return 1;
}

@Override
public ItemStack getStackInSlot(int i) {
	return keystone[i];
}

@Override
public ItemStack decrStackSize(int i, int j) {

	ItemStack itemstack = getStackInSlot(i);

	if (itemstack != null) {
		if (itemstack.stackSize <= j) {
			setInventorySlotContents(i, null);
			onInventoryChanged();
		}else{
			itemstack = itemstack.splitStack(j);
			onInventoryChanged();
		}
	}

	return itemstack;

}

@Override
public ItemStack getStackInSlotOnClosing(int i) {

	ItemStack s = getStackInSlot(i);

	setInventorySlotContents(i, null);
	onInventoryChanged();

	return s;
}

@Override
public void setInventorySlotContents(int i, ItemStack itemstack) {

	if(itemstack != null && itemstack.stackSize > getInventoryStackLimit())
		itemstack.stackSize = getInventoryStackLimit();

	if(this.isItemValidForSlot(0, itemstack))
		keystone[i] = itemstack;

	onInventoryChanged();

}

@Override
public String getInvName() {
	return name;
}

@Override
public boolean isInvNameLocalized() {
	return false;
}

@Override
public int getInventoryStackLimit() {
	return 1;
}

@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
	return entityplayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) <= 64;
}

@Override
public void openChest() {

}

@Override
public void closeChest() {

}

@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
	return itemstack == null || itemstack.itemID == TMItems.keyStone.itemID;
}

public String getName() {
	return name;
}

@Override
public boolean equals(Object o){

	if(!(o instanceof TileEntityMagicPathway))
		return false;

	TileEntityMagicPathway t = (TileEntityMagicPathway) o;

	return t.xCoord == xCoord && t.yCoord == yCoord && t.zCoord == zCoord;

}

public static boolean shouldPlayerSeeKeystone(EntityPlayer player, TileEntityMagicPathway tile){
	return KeyCode.getHeldCode(player).equals(tile.getCode());
}

public void setCode(KeyCode keyCode) {

	if(!keyCode.equals(KeyCode.blank)){
		if(keyCode.equals(getCode()))
			return;

		ItemStack i = new ItemStack(TMItems.keyStone);

		KeyCode.setCode(i, keyCode);

		this.setInventorySlotContents(0, i);
	} else
		this.setInventorySlotContents(0, null);
	onInventoryChanged();

}

public void setCodeN(KeyCode keyCode) {

	if(!keyCode.equals(KeyCode.blank)){
		if(keyCode.equals(getCode()))
			return;

		ItemStack i = new ItemStack(TMItems.keyStone);

		KeyCode.setCode(i, keyCode);

		keystone[0] = i;
	} else
		keystone[0] = null;

}


public void recieveUpdatePacket(NBTTagCompound tag) {
	System.out.println("Recived Update packet!");
	if(FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT){
		name = tag.getString("Name");
		keystone[0] = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("KeyStack"));
	}

}


public void sendUpdatePacket() {
	if(FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
		System.out.println("Sent Update packet!");
		NBTTagCompound toSend = new NBTTagCompound();
		NBTTagCompound stack = new NBTTagCompound();
		if(keystone[0] != null)
			keystone[0].writeToNBT(stack);
		toSend.setCompoundTag("KeyStack", stack);
		toSend.setString("Name", name);
		toSend.setIntArray("Cords", new int[] {xCoord, yCoord, zCoord});
		PacketDispatcher.sendPacketToAllPlayers(TMPacketHandeler.getNBTPacket(toSend, ModInfo.channel, TMPackets.magicPathwayRead));
	}
}

public void onInventoryChanged()
{
    super.onInventoryChanged();
    
    if(FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
    	sendUpdatePacket();
    
    /*
    if(!worldObj.isRemote)
    	for(int i = 0 ; i < 3 ; i++)
    		worldObj.addBlockEvent(xCoord, yCoord, zCoord, worldObj.getBlockId(xCoord, yCoord, zCoord), 10 + i, getCode().getCode(i));
	*/
}
/*
@SideOnly(Side.CLIENT)
public boolean receiveClientEvent(int id, int val)
{
	if(worldObj.isRemote){
		if(id - 10 < 3 && id - 10 >= 0){
			setCodeN(getCode().setCode(val, id - 10));
			return true;
		} else
			return false;
	}
	return false;
}
*/
    /*
private static ArrayList<TileEntityMagicPathway> tileList = new ArrayList<TileEntityMagicPathway>();
private static boolean hasList = false;

public static void writeToTileList(TileEntityMagicPathway tile, KeyCode path){

	tileList = tile.getOtherPoints(path);
	hasList = true;

}

public static void clearTileList(){
	tileList.clear();
	hasList = false;
}

public static ArrayList<TileEntityMagicPathway> getTileList(){
	if(hasList){
		return tileList;
	} else
		throw new IllegalStateException("You must write a TileList first!");
}
*/
}

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello. Basically I made a custom standalone util library (https://github.com/lolhol/Pathfinder3D) and want to use it with my mod. Although I have done the normal jit pack stuff (basically the tutorial on their website) the Minecraft crashes the second it starts saying that it cannot find the name of a class inside of my library. (When I remove the implement(<my library link thingy>) mc launches normally and does not crash (if I comment out the code that uses the custom lib)). Now then, is there a quick fix for this because all of the other questions that I found on this topic were trying to load another mod (again, not what I’m trying to do). Am I doing something wrong? 
    • Fast Leaf Decay (by olafskiii) Rubidium (by Asek3) Artifacts (by ochotonida) Framework (by MrCrayfish) Max Health Fix (by DarkhaxDev) Embeddium/Rubidium Extras (by Txni) Essential Mod (by SparkUniverse_) Immersive Aircraft [Fabric/Forge] (by Conczin) Cherished Worlds (Fabric/Forge/NeoForge/Quilt) (by TheIllusiveC4) ExpandAbility (by florensie) Sophisticated Core (by P3pp3rF1y) Tinkers' Levelling Addon (by Pyre540) Better Advancements (by way2muchnoise) Immersive Melodies [Fabric/Forge] (by Conczin) Citadel (by sbom_xela) Vampirism - Become a vampire! (by maxanier) FerriteCore ((Neo)Forge) (by malte0811) CoroUtil (by Corosus) Create Big Cannons (by rbasamoyai) Controlling (by Jaredlll08) Cloth Config API (Fabric/Forge/NeoForge) (by shedaniel) Mekanism (by bradyaidanc) BetterF3 (by cominixo) Supplementaries (by MehVahdJukaar) Chest Cavity - Forge Port (by booneldanforever) ConnectedTexturesMod (by tterrag1098) NetherPortalFix (by BlayTheNinth) Spartan Weaponry (by ObliviousSpartan) Charm of Undying (Fabric/Forge/Quilt) (by TheIllusiveC4) Plushie Mod (by Link4real) JourneyMap (by techbrew) Farmer's Delight (by vectorwing) Connectivity[Forge/Fabric] (by someaddon) Create : Misc & Things (by To0pa) Create: Steam 'n' Rails (by IThundxr) Shutup Experimental Settings! (by Corgi_Taco) Alex's Mobs (by sbom_xela) Quark (by Vazkii) Tool Belt (by gigaherz) Just Enough Items (JEI) (by mezz) Bookshelf (by DarkhaxDev) FastWorkbench (by Shadows_of_Fire) Tinkers Construct (by mDiyo) Collective (by Serilum) Inventory HUD+ (by dmitrylovin) Explorer's Compass (by Chaosyr) playerAnimator (by KosmX) Size Devices (by DaFlame_rl) Jade 🔍 (by Snownee) Create Slice & Dice (by possible_triangle) Create Jetpack (by possible_triangle) Carry On (by Tschipp) Moonlight Lib (by MehVahdJukaar) Kotlin for Forge (by thedarkcolour) CraftTweaker (by Jaredlll08) Just Enough Resources (JER) (by way2muchnoise) AI Improvements (by QueenOfMissiles) Patchouli (by Vazkii) Catalogue (by MrCrayfish) Tool Stats (by DarkhaxDev) It Takes a Pillage (by izofar) JEITweaker (by Jaredlll08) Waystones (by BlayTheNinth) Vampires Need Umbrellas (by focamacho) Oculus (by Asek3) Mantle (by mDiyo) Mob Grinding Utils (by vadis365) Chiseled (by freepeopleworking) AutoRegLib (by Vazkii) Mystical Agriculture (by BlakeBr0) Embeddium/Rubidium Dynamic Lights (by Txni) Flywheel (Legacy) (by jozufozu) Builder's Delight (Forge) (by Tynoxs) Apotheosis (by Shadows_of_Fire) What Are They Up To (Watut) (by Corosus) Create: Interiors (by sudolev) FastFurnace (by Shadows_of_Fire) Balm (Forge Edition) (by BlayTheNinth) Clumps (by Jaredlll08) Iris & Oculus Flywheel Compat (by leon_mout) Configured (by MrCrayfish) Tinkers' Expansion (by Insane96) Crafting on a stick (by OfekN_) MrCrayfish's Gun Mod (by MrCrayfish) Create: Crystal Clear (by singularity_cyvack) FTB Library (Forge) (by FTB) AppleSkin (by squeek502) Curios API (Forge/NeoForge) (by TheIllusiveC4) Better Third Person (by Socolio) Caelus API (Forge/NeoForge) (by TheIllusiveC4) Sons Of Sins (by Furti_Two) SwingThroughGrass (by exidex) AttributeFix (by DarkhaxDev) Quests Additions (Forge) (by NaturaSpell) Building Gadgets (by Direwolf20) Enchantment Descriptions (by DarkhaxDev) Skin Layers 3D (Fabric/Forge) (by tr7zw) Bad Wither No Cookie - Reloaded (by Kreezxil) Placebo (by Shadows_of_Fire) FTB Teams (Forge) (by FTB) Mod Name Tooltip (by mezz) Enigmatic Graves (by Quarris) Sophisticated Backpacks (by P3pp3rF1y) GeckoLib (by Gecko) Builders Crafts & Additions (by MRHminer) Immersive Portals (for Forge) (by qouteall) Architectury API (Fabric/Forge/NeoForge) (by shedaniel) Lazy DataFixerUpper(LazyDFU) [FORGE] (by Corgi_Taco) Create Ore Excavation (by tom54541) Tinkers' Rapier (by sz0999312) Mowzie's Mobs (by bobmowzie) Better Combat [Fabric & Forge] (by daedelus_dev) Create Stuff & Additions (by Furti_Two) Cucumber Library (by BlakeBr0) FPS Reducer (by bre2el) Item Filters (by LatvianModder) FTB Quests (Forge) (by FTB) L_Ender 's Cataclysm (by mcl_ender) Starter Kit (by Serilum) Feature NBT Deadlock Be Gone (by telepathicgrunt) Materialis (by RCXcrafter) KleeSlabs (by BlayTheNinth) Pehkui (by Virtuoel) Grappling Hook Mod (by yyonne) Security Craft (by Geforce132) Ars Nouveau (by baileyholl2) Mouse Tweaks (by YaLTeR) Werewolves - Become a Beast! (by Cheaterpaul) Elytra Slot (Fabric/Forge/Quilt) (by TheIllusiveC4) Create (by simibubi) Budschie's Morph Mod (by budschie_) Ore Excavation (by Funwayguy) Create Confectionery (by Furti_Two)
    • Hello, im kind of a newbie on creating mods, and i been trying to make simples mods so far, Right now, i'm creating a mod which detect an specific type of mob and kill it if reach a certain number, by far the mod is detecting the mob and counting them but at the time it reach the limit number, it don't do anything. The Game don't tweak, don't crash, just i't don't run the method i call, which is kill().   public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pUsedHand) { final var TotalCows = pLevel.getNearbyEntities(Cow.class, TargetingConditions.forNonCombat(), pPlayer, pPlayer.getBoundingBox().inflate(5)); if(pLevel.isClientSide){ if(pPlayer.getItemInHand(InteractionHand.MAIN_HAND).getItem() == this.asItem()){ if(!TotalCows.isEmpty()){ if(TotalCows.get(0).isAlive()){ TotalCows.get(0).kill(); } }else{ pPlayer.sendSystemMessage(Component.literal("No hay vacas")); } } } The sendSystemMessage is get triggered, and when i change the method .kill() by any other like send a message it got called, can i get some tips, and a clue of what i'm missing
    • UPD: I DID IT   @Override public void applyEffectTick(LivingEntity livingEntity, int pAmplifier) { Level level = livingEntity.level(); if (!level.isClientSide()) { Holder<DamageType> entropyHolder = level .registryAccess() .registryOrThrow(Registries.DAMAGE_TYPE) .getHolderOrThrow(GTDamageTypes.ENTROPY_KEY); livingEntity.hurt(new DamageSource(entropyHolder), 1); } super.applyEffectTick(livingEntity, pAmplifier); }  
    • So I came to this public class ModDamageTypes{ public static void bootstrap(BootstapContext<DamageType> context) { context.register(GTDamageTypes.ENTROPY_KEY, new DamageType(GrimTales.MOD_ID + "_entropy", 0.1f)); } } public class GTDamageTypes implements DamageTypes { public static final ResourceKey<DamageType> ENTROPY_KEY = register("entropy"); private static ResourceKey<DamageType> register(String name) { return ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(GrimTales.MOD_ID, name)); } } public class ModWorldGenProvider extends DatapackBuiltinEntriesProvider { public static final RegistrySetBuilder BUILDER = new RegistrySetBuilder() .add(Registries.DAMAGE_TYPE, ModDamageTypes::bootstrap); public ModWorldGenProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> registries) { super(output, registries, BUILDER, Set.of(GrimTales.MOD_ID)); } But! I still have an issue that, I cannot just use Holder.direct, due to it will create error that "Required type:  Holder<DamageType>  Provided : Holder<ResourceKey<DamageType>>" And I still have no clue how to fix it
  • Topics

×
×
  • Create New...

Important Information

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