Jump to content

[1.8] Need help modding Professions mod


Foxy

Recommended Posts

Hi i'm new to modding and i require a bit of help, everything is explained in Professions topic in mods section. Link to GitHub

 

[sOLVED] Herbalism:

 

 

 

}else if (event.state.getBlock() == Blocks.wheat || event.state.getBlock() == Blocks.potatoes || event.state.getBlock() == Blocks.carrots){

int age = (Integer)event.state.getValue(BlockCrops.AGE);

if (age != 7){

Professions.herbalism.setExp(Professions.herbalism.getExp() - (2 * Professions.herbalism.getLevel()));

Professions.herbalism.update();

}else{

Professions.herbalism.setExp(Professions.herbalism.getExp() + (3 * Professions.herbalism.getLevel()));

Professions.herbalism.update();

}

 

 

Link to comment
Share on other sites

I tried checking if metadata is 7 but it still adds exp event if it isn't

 

 

 

if (event.state.getBlock() == Blocks.wheat){

    if (Blocks.wheat.getMetaFromState() == 7){

        Professions.herbalism.setExp(Professions.herbalism.getExp() + (3 * Professions.herbalism.getLevel()));

      Professions.herbalism.update();

    }else{

        Professions.herbalism.setExp(Professions.herbalism.getExp() - (2 * Professions.herbalism.getLevel()));

      Professions.herbalism.update();

}

 

 

 

This isn't only way i checked but still doesn't work.

 

Link to comment
Share on other sites

@Failender

I fixed that alredy but diesieben07 said i shouldn't use getMetaFromState so i am experimenting again.

 

Never ever call getMetaFromState yourself. Interact with the IBlockState, it's there so that you don't have to work with stupid magic numbers (7) anymore.

The age is stored in the property BlockCrops.AGE.

 

@diesieben70

Can you explain why i shouldn't use getMetaFromState ? I also modified if statement, but not sure if it's correct way to do it. Don't really understand how Block States work.

 

 

 

}else if (event.state.getBlock() == Blocks.wheat || event.state.getBlock() == Blocks.potatoes || event.state.getBlock() == Blocks.carrots){

if (event.state.getBlock() == event.state.withProperty(BlockCrops.AGE, 7)){

Professions.herbalism.setExp(Professions.herbalism.getExp() - (2 * Professions.herbalism.getLevel()));

Professions.herbalism.update();

}else{

Professions.herbalism.setExp(Professions.herbalism.getExp() + (3 * Professions.herbalism.getLevel()));

Professions.herbalism.update();

}

 

 

Link to comment
Share on other sites

I am beginner programmer so i don't know much but i'm learning.

 

Here is another try:

 

 

}else if (event.state.getBlock() == Blocks.wheat || event.state.getBlock() == Blocks.potatoes || event.state.getBlock() == Blocks.carrots){

int age = (Integer)event.state.getValue(BlockCrops.AGE);

if (age != 7){

Professions.herbalism.setExp(Professions.herbalism.getExp() - (2 * Professions.herbalism.getLevel()));

Professions.herbalism.update();

}else{

Professions.herbalism.setExp(Professions.herbalism.getExp() + (3 * Professions.herbalism.getLevel()));

Professions.herbalism.update();

}

 

 

 

This way it works as intended but idk if it's considered right or wrong programming.

Link to comment
Share on other sites

Well, the "Professions.herbalism" makes me suspicious whether you actually handle the fact that there is more than one player.

 

I don't ... which classes should i check to see how it's done ?

Btw i added github link

 

also do i need to initiate save of players current exp and level on server  or world exit or is it automatic, i guess it's not ?

Link to comment
Share on other sites

Okay i finished implementing IExtendedEntityProperties, is this alright:

 

Profession.java

 

 

package com.foxy.profs.common.profession;

 

import com.foxy.profs.common.library.ProfLib;

 

import net.minecraft.entity.Entity;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.world.World;

import net.minecraftforge.common.IExtendedEntityProperties;

 

public class Profession implements IExtendedEntityProperties {

 

protected String name;

protected static String IDENTIFICATION = "Professions";

protected int exp, maxExp, level, maxLevel;

 

public Profession(String name, int maxExp, int maxLevel){

this.name = name;

this.maxExp = maxExp;

this.level = 1;

this.maxLevel = maxLevel;

 

}

 

public static final Profession register(EntityPlayer player){

return (Profession)player.getExtendedProperties(IDENTIFICATION);

}

 

public static final Profession get(EntityPlayer player){

return (Profession)player.getExtendedProperties(IDENTIFICATION);

}

 

@Override

public void saveNBTData(NBTTagCompound compound) {

NBTTagCompound profession = new NBTTagCompound();

 

profession.setInteger("Exp", this.exp);

profession.setInteger("Max Exp", this.maxExp);

profession.setInteger("Level", level);

profession.setInteger("Max Level", this.maxLevel);

 

compound.setTag(name, profession);

}

 

@Override

public void loadNBTData(NBTTagCompound compound) {

NBTTagCompound profession = (NBTTagCompound) compound.getTag(name);

 

profession.getInteger("Exp");

profession.getInteger("Max Exp");

profession.getInteger("Level");

profession.getInteger("Max Level");

 

System.out.println("[" + ProfLib.MODID + "]Has loaded " + name + " from NBT: [Exp" + this.exp + "/" + this.maxExp + "][Level" + this.level + "/" + this.maxLevel + "]");

 

}

 

@Override

public void init(Entity entity, World world) {

 

}

 

 

public String getName(){

return name;

}

 

public int getExp(){

return exp;

}

 

public int getMaxExp(){

return maxExp;

}

 

public int getLevel(){

return level;

}

 

public int getMaxLevel(){

return maxLevel;

}

 

public Profession setName(String name){

this.name = name;

return this;

}

 

public Profession setExp(int exp){

this.exp = exp;

return this;

}

 

public Profession setMaxExp(int maxExp){

this.maxExp = maxExp;

return this;

}

 

public Profession setLevel(int level){

this.level = level;

return this;

}

 

public Profession setMaxLevel(int maxLevel){

this.maxLevel = maxLevel;

return this;

}

 

 

public Profession addExp(int exp){

this.exp += exp;

return this;

}

 

public Profession removeExp(int exp){

this.exp -= exp;

return this;

}

 

public Profession addExp(int exp, int modifier){

this.exp += (exp * modifier);

return this;

}

 

public Profession removeExp(int exp, int modifier){

this.exp -= (exp * modifier);

return this;

}

 

public boolean isLeveledUp(){

if (level == maxLevel){

return true;

}else{

return false;

}

}

 

public boolean isMaxed(){

if (exp == maxExp && isLeveledUp()){

return true;

}else{

return false;

}

}

 

public boolean canLevelUp(){

if (exp >= maxExp && !isLeveledUp()){

return true;

}else{

return false;

}

}

 

public boolean canLevelDown(){

if (exp < 0){

if (level != 1){

return true;

}else{

return false;

}

}

return false;

}

 

public boolean canEarnExp(){

if (exp > 0 || exp <= maxExp){

return true;

}else{

return false;

}

}

 

public boolean canLoseExp(){

if (exp > 0){

return true;

}else{

return false;

}

}

 

public void levelUp(){

level++;

exp = (exp - maxExp);

maxExp = (maxExp + (15 * level));

}

 

public void levelDown(){

level--;

exp = (maxExp - (exp * -1));

maxExp = (maxExp + (15 * level));

}

 

public void update(){

while (exp >= maxExp || exp < 0){

if (canLevelUp()){

levelUp();

}else if (canLevelDown()){

levelDown();

}

}

}

 

}

 

 

ProfEvents.java

 

 

package com.foxy.profs.common.event;

 

import com.foxy.profs.common.init.Professions;

import com.foxy.profs.common.profession.Profession;

 

import net.minecraft.block.BlockCrops;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.init.Blocks;

import net.minecraft.init.Items;

import net.minecraft.item.ItemStack;

import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;

import net.minecraftforge.event.entity.player.PlayerUseItemEvent;

import net.minecraftforge.event.world.BlockEvent;

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

 

public class ProfEvents {

 

@SubscribeEvent

public void onBlockBroken(BlockEvent.BreakEvent event){

if (!event.getPlayer().capabilities.isCreativeMode){

if (event.state.getBlock() == Blocks.coal_ore || event.state.getBlock() == Blocks.redstone_ore || event.state.getBlock() == Blocks.lit_redstone_ore){

Professions.mining.setExp(Professions.mining.getExp() + (2 + (2 * Professions.mining.getLevel())));

Professions.mining.update();

}else if (event.state.getBlock() == Blocks.iron_ore || event.state.getBlock() == Blocks.lapis_ore || event.state.getBlock() == Blocks.quartz_ore){

Professions.mining.setExp(Professions.mining.getExp() + (4 + (2 * Professions.mining.getLevel())));

Professions.mining.update();

}else if (event.state.getBlock() == Blocks.gold_ore || event.state.getBlock() == Blocks.diamond_ore || event.state.getBlock() == Blocks.emerald_ore){

Professions.mining.setExp(Professions.mining.getExp() + (8 + (2 * Professions.mining.getLevel())));

Professions.mining.update();

}else if (event.state.getBlock() == Blocks.leaves || event.state.getBlock() == Blocks.leaves2){

Professions.woodcutting.setExp(Professions.woodcutting.getExp() + (1 + Professions.woodcutting.getLevel()));

Professions.woodcutting.update();

}else if (event.state.getBlock() == Blocks.log || event.state.getBlock() == Blocks.log2){

Professions.woodcutting.setExp(Professions.woodcutting.getExp() + (3 + Professions.woodcutting.getLevel()));

Professions.woodcutting.update();

}else if (event.state.getBlock() == Blocks.wheat || event.state.getBlock() == Blocks.potatoes || event.state.getBlock() == Blocks.carrots){

int age = (Integer)event.state.getValue(BlockCrops.AGE);

 

if (age != 7){

Professions.herbalism.setExp(Professions.herbalism.getExp() - (2 * Professions.herbalism.getLevel()));

Professions.herbalism.update();

}else{

Professions.herbalism.setExp(Professions.herbalism.getExp() + (3 * Professions.herbalism.getLevel()));

Professions.herbalism.update();

}

}else if (event.state.getBlock() == Blocks.reeds){

Professions.herbalism.setExp(Professions.herbalism.getExp() + (1 * Professions.herbalism.getLevel()));

}

}

}

 

@SubscribeEvent

public void onFishedUp(PlayerUseItemEvent event){

if (!event.entityPlayer.capabilities.isCreativeMode){

if (event.entityPlayer.getHeldItem() != null){

if (event.entityPlayer.getHeldItem().equals(Items.fishing_rod)){

 

}

}

}

}

 

 

@SubscribeEvent

public void onEntityConstructing(EntityConstructing event){

if (event.entity instanceof EntityPlayer && Profession.get((EntityPlayer) event.entity) == null){

Profession.register((EntityPlayer) event.entity);

}

}

 

}

 

 

 

Professions is init class for all professions...

 

Professions

 

 

package com.foxy.profs.common.init;

 

import com.foxy.profs.common.profession.Fishing;

import com.foxy.profs.common.profession.Herbalism;

import com.foxy.profs.common.profession.Hunting;

import com.foxy.profs.common.profession.Mining;

import com.foxy.profs.common.profession.Profession;

import com.foxy.profs.common.profession.Woodcutting;

 

public class Professions {

 

public static Profession hunting;

public static Profession woodcutting;

public static Profession mining;

public static Profession herbalism;

public static Profession fishing;

 

public static void init(){

hunting = new Hunting("Hunting", 100, 725);

woodcutting = new Woodcutting("Woodcutting", 100, 725);

mining = new Mining("Mining", 100, 725);

herbalism = new Herbalism("Herbalism", 100, 725);

fishing = new Fishing("Fishing", 100, 725);

}

 

}

 

 

Link to comment
Share on other sites

Is this what you mean ?

 

 

package com.foxy.profs.common.profession;

 

import com.foxy.profs.common.library.ProfLib;

 

import net.minecraft.entity.Entity;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.world.World;

import net.minecraftforge.common.IExtendedEntityProperties;

 

public class Profession implements IExtendedEntityProperties {

 

protected String name;

protected static String IDENTIFICATION = "Professions";

protected int exp, maxExp, level, maxLevel;

 

public Profession hunting = new Profession("Hunting", 100, 725);

public Profession woodcutting = new Profession("Woodcutting", 100, 725);

public Profession mining = new Profession("Mining", 100, 725);

public Profession herbalism = new Profession("Herbalism", 100, 725);

public Profession fishing = new Profession("Fishing", 100, 725);

 

public Profession(String name, int maxExp, int maxLevel){

this.name = name;

this.exp = 0;

this.level = 1;

this.maxExp = maxExp;

this.maxLevel = maxLevel;

}

 

public static final Profession register(EntityPlayer player){

return (Profession)player.getExtendedProperties(IDENTIFICATION);

}

 

public static final Profession get(EntityPlayer player){

return (Profession)player.getExtendedProperties(IDENTIFICATION);

}

 

@Override

public void saveNBTData(NBTTagCompound compound) {

NBTTagCompound profession = new NBTTagCompound();

 

profession.setInteger("Exp", this.exp);

profession.setInteger("Max Exp", this.maxExp);

profession.setInteger("Level", level);

profession.setInteger("Max Level", this.maxLevel);

 

compound.setTag(name, profession);

}

 

@Override

public void loadNBTData(NBTTagCompound compound) {

NBTTagCompound profession = (NBTTagCompound) compound.getTag(name);

 

this.exp = profession.getInteger("Exp");

this.level = profession.getInteger("Level");

this.maxExp = profession.getInteger("Max Exp");

this.maxLevel = profession.getInteger("Max Level");

 

System.out.println("[" + ProfLib.MODID + "]Has loaded " + name + " from NBT: [Exp" + this.exp + "/" + this.maxExp + "][Level" + this.level + "/" + this.maxLevel + "]");

 

}

 

@Override

public void init(Entity entity, World world) {

 

}

 

 

public String getName(){

return name;

}

 

public int getExp(){

return exp;

}

 

public int getMaxExp(){

return maxExp;

}

 

public int getLevel(){

return level;

}

 

public int getMaxLevel(){

return maxLevel;

}

 

public Profession setName(String name){

this.name = name;

return this;

}

 

public Profession setExp(int exp){

this.exp = exp;

return this;

}

 

public Profession setMaxExp(int maxExp){

this.maxExp = maxExp;

return this;

}

 

public Profession setLevel(int level){

this.level = level;

return this;

}

 

public Profession setMaxLevel(int maxLevel){

this.maxLevel = maxLevel;

return this;

}

 

 

public Profession addExp(int exp){

this.exp += exp;

return this;

}

 

public Profession removeExp(int exp){

this.exp -= exp;

return this;

}

 

public Profession addExp(int exp, int modifier){

this.exp += (exp + (modifier * level));

return this;

}

 

public Profession removeExp(int exp, int modifier){

this.exp -= (exp * modifier);

return this;

}

 

public boolean isLeveledUp(){

if (level == maxLevel){

return true;

}else{

return false;

}

}

 

public boolean isMaxed(){

if (exp == maxExp && isLeveledUp()){

return true;

}else{

return false;

}

}

 

public boolean canLevelUp(){

if (exp >= maxExp && !isLeveledUp()){

return true;

}else{

return false;

}

}

 

public boolean canLevelDown(){

if (exp < 0){

if (level != 1){

return true;

}else{

return false;

}

}

return false;

}

 

public boolean canEarnExp(){

if (exp > 0 || exp <= maxExp){

return true;

}else{

return false;

}

}

 

public boolean canLoseExp(){

if (exp > 0){

return true;

}else{

return false;

}

}

 

public void levelUp(){

level++;

exp = (exp - maxExp);

maxExp = (maxExp + (15 * level));

}

 

public void levelDown(){

level--;

exp = (maxExp - (exp * -1));

maxExp = (maxExp + (15 * level));

}

 

public void update(){

while (exp >= maxExp || exp < 0){

if (canLevelUp()){

levelUp();

}else if (canLevelDown()){

levelDown();

}

}

}

 

}

 

 

 

Also should i use datawatchers for exp and level or no ?

 

EDIT: no need for datawatchers cause players wont need to know about other player exp or level.

 

EDIT:

ProfEvent class

 

 

package com.foxy.profs.common.event;

 

import com.foxy.profs.common.profession.Profession;

 

import net.minecraft.block.BlockCrops;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.init.Blocks;

import net.minecraft.init.Items;

import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;

import net.minecraftforge.event.entity.player.PlayerUseItemEvent;

import net.minecraftforge.event.world.BlockEvent;

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

 

public class ProfEvents {

 

@SubscribeEvent

public void onEntityConstructing(EntityConstructing event){

if (event.entity instanceof EntityPlayer && Profession.get((EntityPlayer) event.entity) == null){

Profession.register((EntityPlayer) event.entity);

}

}

 

@SubscribeEvent

public void onBlockBroken(BlockEvent.BreakEvent event){

Profession profession = Profession.get((EntityPlayer) event.getPlayer());

 

if (!event.getPlayer().capabilities.isCreativeMode){

if (event.state.getBlock() == Blocks.coal_ore || event.state.getBlock() == Blocks.redstone_ore || event.state.getBlock() == Blocks.lit_redstone_ore){

profession.mining.addExp(2, 2);

profession.mining.update();

}else if (event.state.getBlock() == Blocks.iron_ore || event.state.getBlock() == Blocks.lapis_ore || event.state.getBlock() == Blocks.quartz_ore){

profession.mining.addExp(4, 2);

profession.mining.update();

}else if (event.state.getBlock() == Blocks.gold_ore || event.state.getBlock() == Blocks.diamond_ore || event.state.getBlock() == Blocks.emerald_ore){

profession.mining.addExp(8, 2);

profession.mining.update();

}else if (event.state.getBlock() == Blocks.leaves || event.state.getBlock() == Blocks.leaves2){

profession.woodcutting.addExp(1, 1);

profession.woodcutting.update();

}else if (event.state.getBlock() == Blocks.log || event.state.getBlock() == Blocks.log2){

profession.woodcutting.addExp(3, 1);

profession.woodcutting.update();

}else if (event.state.getBlock() == Blocks.wheat || event.state.getBlock() == Blocks.potatoes || event.state.getBlock() == Blocks.carrots){

int age = (Integer)event.state.getValue(BlockCrops.AGE);

 

if (age != 7){

profession.herbalism.removeExp(2, 1);

profession.herbalism.update();

}else{

profession.herbalism.removeExp(3, 1);

profession.herbalism.update();

}

}else if (event.state.getBlock() == Blocks.reeds){

profession.herbalism.addExp(1, 1);

}

}

}

 

@SubscribeEvent

public void onBlockPlaced(BlockEvent.PlaceEvent event){

Profession profession = Profession.get((EntityPlayer) event.player);

 

if (!event.player.capabilities.isCreativeMode){

if (event.placedBlock.getBlock() == Blocks.reeds){

profession.mining.removeExp(3, 1);

}

}

}

 

}

 

 

 

do i need to cast event.player and event.getPlayer() to (EntityPlayer), seeing as they are already players i think they shouldn't.

Link to comment
Share on other sites

No, that's not right.

 

Lemme explain. There is some EntityPlayer. Each living entity has a map looking +/- like this Map<KeyToProps, IEEP>.

You can assign class you create that inplements IEEP to given entity (by putting it into that map) - that happens in construction event - you literally assign "additional" "storage" (called IEEP) to given player.

 

Now - in that storage you can hold ANY kind of data. it doesn't need to be even saved to disk. It can be really anything - object, variable, object iwth other objects. Then if you decide - you can save it to given entity's NBT.

 

That's whole logic behind it.

 

Now - profession is something that is assigned to PLAYER, not all players. That's what you need to do - you need to make fields in your IEEP class that will hold profession data about given player.

 

Design you can do: (nice and readable)

 

EntityPlayer

--> ProfessionsMap implements IEEP

-----> Herbalism extends Profession

-----> Mining extends Profession

-----> Combat extends Profession.

 

Where "Profession" would be an object that holds data about specific profession for given player.

Then you can load/save that data using  load/saveNBTData(...).

 

P.S

I wonder how your code (one you posted in last post) is not givng OutOfMemeory. Unless it does (you are literally making infinite number of "Profession" there).

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

Thanks for help, but before i can finish this project i should read more tutorials on java so i have base knowledge of java. I understand what you are saying but don't know how to fully implement it, so i will start with simpler things.

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

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

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