Jump to content

How to make a custom Workbench with "holes"


IlTosaerba

Recommended Posts

Hi modders,

I want to put a particular custom workbench in my mod, a workbench with "holes" in the GUI.

 

GUI:

Spoiler

crystalInfuser.png.63bca2b345963e45601512b6e9e8c610.png

 

 

Now, in the container I successfully added the slots in the right way, but when I try to interact with it the ShapedRecipe give me problems.

 

The InventoryCrafting is a 5x5, so I created a custom class to set the  SizeInventory to 17 (instead of 25).
 

Custom InventoryCraft:

Spoiler

package com.WLLC.mysticWeapons.crafting.crystalInfuser;

import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;

public class WLLC_myWE_CrystalInfuserInventoryCrafting extends InventoryCrafting {

	public WLLC_myWE_CrystalInfuserInventoryCrafting(Container p_i1807_1_) {
		
		super(p_i1807_1_, 5, 5);
		
	}
    
	@Override
	public int getSizeInventory() {
		
		return 17;
		
	}
	
	@Override
	public String getInventoryName() {
		
		return "container.crystalInfuser";
		
	}
	
	@Override
	public boolean hasCustomInventoryName() {
		
		return true;
		
	}
	
	
	@Override
	public ItemStack getStackInRowAndColumn(int row, int column) {
		
		if (row == 0 || row == 4) {
			
			return vanillaGetStackInRowAndColumnOperation(row, column);
			
		} else if (row == 1 || row == 3){
			
			if (column == 0 || column == 4) {
				
				return vanillaGetStackInRowAndColumnOperation(row, column);
				
			} else {
				
				return null;
				
			}
			
		} else if (row == 2) {
			
			if (column != 1 && column != 3) {
				
				return vanillaGetStackInRowAndColumnOperation(row, column);
				
			} else {
				
				return null;
				
			}
			
		} else {
			
			return null;
			
		}
		
	}
	
	public ItemStack vanillaGetStackInRowAndColumnOperation(int row, int column) {
		
		return super.getStackInSlot(row + column * 5);
		
	}
    
}

 

 

The problem is in the checkMatch() method of the ShapedRecipe class, where the class do some strange operation (lines form 98 to 106). This kind of satanic farmulas work fine if I have a 25 elements array, but I have a 17 one :( and I don't know how to arrange them to correctly scan the array from 0 to 16.

Custom ShapedRecipe:

Spoiler

package com.WLLC.mysticWeapons.crafting.crystalInfuser;

import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;

public class WLLC_myWE_CrystalInfuserShapedRecipes implements IRecipe {

    public final int recipeWidth;
    public final int recipeHeight;
    public final ItemStack[] recipeItems;
    private ItemStack recipeOutput;
    private boolean field_92101_f;
    private static final String __OBFID = "CL_00000093";

    public WLLC_myWE_CrystalInfuserShapedRecipes(int p_i1917_1_, int p_i1917_2_, ItemStack[] ingredients, ItemStack result) {
    	
        this.recipeWidth = p_i1917_1_;
        this.recipeHeight = p_i1917_2_;
        this.recipeItems = ingredients;
        this.recipeOutput = result;
        
    }

    public ItemStack getRecipeOutput() {
    	
        return this.recipeOutput;
        
    }

    public boolean customMatches(WLLC_myWE_CrystalInfuserInventoryCrafting invCrafting, World world) {
    	
        for (int row = 0; row <= 5 - this.recipeWidth; ++row) {
        	
            for (int column = 0; column <= 5 - this.recipeHeight; ++column) {
            	
            	if (row == 0 || row == 4) {
            	
            		return vanillaMatchesProcess(invCrafting, world, row, column);
                
            	} else if (row == 1 || row == 3){
            		
            		if (column == 0 || column == 4) {
            			
            			return vanillaMatchesProcess(invCrafting, world, row, column);
            			
            		}
            		
            	} else if (row == 2) {
            		
            		if (column != 1 && column != 3) {
            			
            			return vanillaMatchesProcess(invCrafting, world, row, column);
            			
            		}
            		
            	}
                
            }
            
        }

        return false;
    }
    
    public boolean vanillaMatchesProcess(WLLC_myWE_CrystalInfuserInventoryCrafting invCrafting, World world, int row, int column) {
    	
    	if (this.checkMatch(invCrafting, row, column, true)) {
        	
			return true;
        
		}

		if (this.checkMatch(invCrafting, row, column, false)) {
    	
			return true;
        
		}
		
		return false;
    	
    }

    private boolean checkMatch(WLLC_myWE_CrystalInfuserInventoryCrafting invCrafting, int row0, int column0, boolean p_77573_4_) {
    	
        for (int row = 0; row < 5; ++row) {
        	
            for (int column = 0; column < 5; ++column) {
            	
                int row1 = row - row0;
                int column1 = column - column0;
                ItemStack itemstack = null;

                if (row1 >= 0 && column1 >= 0 && row1 < this.recipeWidth && column1 < this.recipeHeight) {
                	
                    if (p_77573_4_) {
                    	
                        itemstack = this.recipeItems[this.recipeWidth - row1 - 1 + column1 * this.recipeWidth];
                        
                    } else {
                    	
                        itemstack = this.recipeItems[row1 + column1 * this.recipeWidth];
                        
                    }
                    
                }

                ItemStack itemstack1 = invCrafting.getStackInRowAndColumn(row, column);

                if (itemstack1 != null || itemstack != null) {
                	
                    if (itemstack1 == null && itemstack != null || itemstack1 != null && itemstack == null) {
                    	
                        return false;
                        
                    }

                    if (itemstack.getItem() != itemstack1.getItem()) {
                    	
                        return false;
                        
                    }

                    if (itemstack.getItemDamage() != 32767 && itemstack.getItemDamage() != itemstack1.getItemDamage()) {
                    	
                        return false;
                        
                    }
                    
                }
                
            }
            
        }

        return true;
    }

    public ItemStack customGetCraftingResult(WLLC_myWE_CrystalInfuserInventoryCrafting invCrafting) {
    	
        ItemStack itemstack = this.getRecipeOutput().copy();

        if (this.field_92101_f) {
        	
            for (int i = 0; i < invCrafting.getSizeInventory(); ++i) {
            	
                ItemStack itemstack1 = invCrafting.getStackInSlot(i);

                if (itemstack1 != null && itemstack1.hasTagCompound()) {
                	
                    itemstack.setTagCompound((NBTTagCompound)itemstack1.stackTagCompound.copy());
                    
                }
                
            }
            
        }

        return itemstack;
    }

   public int getRecipeSize() {
	   
        return this.recipeWidth * this.recipeHeight;
        
    }

    public WLLC_myWE_CrystalInfuserShapedRecipes func_92100_c() {
    	
        this.field_92101_f = true;
        return this;
        
    }

	@Override
	public boolean matches(InventoryCrafting invCrafting, World world) {
		
		return this.customMatches((WLLC_myWE_CrystalInfuserInventoryCrafting) invCrafting, world);
		
	}

	@Override
	public ItemStack getCraftingResult(InventoryCrafting invCrafting) {
		
		return this.customGetCraftingResult((WLLC_myWE_CrystalInfuserInventoryCrafting) invCrafting);
		
	}
    
}

 

 

How can I resolve this? Or I'm doing this terribly wrong?

Thanks in advice

Link to comment
Share on other sites

3 hours ago, IlTosaerba said:

Hi modders,

I want to put a particular custom workbench in my mod, a workbench with "holes" in the GUI.

 

GUI:

  Hide contents

crystalInfuser.png.63bca2b345963e45601512b6e9e8c610.png

 

 

Now, in the container I successfully added the slots in the right way, but when I try to interact with it the ShapedRecipe give me problems.

 

The InventoryCrafting is a 5x5, so I created a custom class to set the  SizeInventory to 17 (instead of 25).
 

Custom InventoryCraft:

  Hide contents


package com.WLLC.mysticWeapons.crafting.crystalInfuser;

import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;

public class WLLC_myWE_CrystalInfuserInventoryCrafting extends InventoryCrafting {

	public WLLC_myWE_CrystalInfuserInventoryCrafting(Container p_i1807_1_) {
		
		super(p_i1807_1_, 5, 5);
		
	}
    
	@Override
	public int getSizeInventory() {
		
		return 17;
		
	}
	
	@Override
	public String getInventoryName() {
		
		return "container.crystalInfuser";
		
	}
	
	@Override
	public boolean hasCustomInventoryName() {
		
		return true;
		
	}
	
	
	@Override
	public ItemStack getStackInRowAndColumn(int row, int column) {
		
		if (row == 0 || row == 4) {
			
			return vanillaGetStackInRowAndColumnOperation(row, column);
			
		} else if (row == 1 || row == 3){
			
			if (column == 0 || column == 4) {
				
				return vanillaGetStackInRowAndColumnOperation(row, column);
				
			} else {
				
				return null;
				
			}
			
		} else if (row == 2) {
			
			if (column != 1 && column != 3) {
				
				return vanillaGetStackInRowAndColumnOperation(row, column);
				
			} else {
				
				return null;
				
			}
			
		} else {
			
			return null;
			
		}
		
	}
	
	public ItemStack vanillaGetStackInRowAndColumnOperation(int row, int column) {
		
		return super.getStackInSlot(row + column * 5);
		
	}
    
}

 

 

The problem is in the checkMatch() method of the ShapedRecipe class, where the class do some strange operation (lines form 98 to 106). This kind of satanic farmulas work fine if I have a 25 elements array, but I have a 17 one :( and I don't know how to arrange them to correctly scan the array from 0 to 16.

Custom ShapedRecipe:

  Reveal hidden contents


package com.WLLC.mysticWeapons.crafting.crystalInfuser;

import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;

public class WLLC_myWE_CrystalInfuserShapedRecipes implements IRecipe {

    public final int recipeWidth;
    public final int recipeHeight;
    public final ItemStack[] recipeItems;
    private ItemStack recipeOutput;
    private boolean field_92101_f;
    private static final String __OBFID = "CL_00000093";

    public WLLC_myWE_CrystalInfuserShapedRecipes(int p_i1917_1_, int p_i1917_2_, ItemStack[] ingredients, ItemStack result) {
    	
        this.recipeWidth = p_i1917_1_;
        this.recipeHeight = p_i1917_2_;
        this.recipeItems = ingredients;
        this.recipeOutput = result;
        
    }

    public ItemStack getRecipeOutput() {
    	
        return this.recipeOutput;
        
    }

    public boolean customMatches(WLLC_myWE_CrystalInfuserInventoryCrafting invCrafting, World world) {
    	
        for (int row = 0; row <= 5 - this.recipeWidth; ++row) {
        	
            for (int column = 0; column <= 5 - this.recipeHeight; ++column) {
            	
            	if (row == 0 || row == 4) {
            	
            		return vanillaMatchesProcess(invCrafting, world, row, column);
                
            	} else if (row == 1 || row == 3){
            		
            		if (column == 0 || column == 4) {
            			
            			return vanillaMatchesProcess(invCrafting, world, row, column);
            			
            		}
            		
            	} else if (row == 2) {
            		
            		if (column != 1 && column != 3) {
            			
            			return vanillaMatchesProcess(invCrafting, world, row, column);
            			
            		}
            		
            	}
                
            }
            
        }

        return false;
    }
    
    public boolean vanillaMatchesProcess(WLLC_myWE_CrystalInfuserInventoryCrafting invCrafting, World world, int row, int column) {
    	
    	if (this.checkMatch(invCrafting, row, column, true)) {
        	
			return true;
        
		}

		if (this.checkMatch(invCrafting, row, column, false)) {
    	
			return true;
        
		}
		
		return false;
    	
    }

    private boolean checkMatch(WLLC_myWE_CrystalInfuserInventoryCrafting invCrafting, int row0, int column0, boolean p_77573_4_) {
    	
        for (int row = 0; row < 5; ++row) {
        	
            for (int column = 0; column < 5; ++column) {
            	
                int row1 = row - row0;
                int column1 = column - column0;
                ItemStack itemstack = null;

                if (row1 >= 0 && column1 >= 0 && row1 < this.recipeWidth && column1 < this.recipeHeight) {
                	
                    if (p_77573_4_) {
                    	
                        itemstack = this.recipeItems[this.recipeWidth - row1 - 1 + column1 * this.recipeWidth];
                        
                    } else {
                    	
                        itemstack = this.recipeItems[row1 + column1 * this.recipeWidth];
                        
                    }
                    
                }

                ItemStack itemstack1 = invCrafting.getStackInRowAndColumn(row, column);

                if (itemstack1 != null || itemstack != null) {
                	
                    if (itemstack1 == null && itemstack != null || itemstack1 != null && itemstack == null) {
                    	
                        return false;
                        
                    }

                    if (itemstack.getItem() != itemstack1.getItem()) {
                    	
                        return false;
                        
                    }

                    if (itemstack.getItemDamage() != 32767 && itemstack.getItemDamage() != itemstack1.getItemDamage()) {
                    	
                        return false;
                        
                    }
                    
                }
                
            }
            
        }

        return true;
    }

    public ItemStack customGetCraftingResult(WLLC_myWE_CrystalInfuserInventoryCrafting invCrafting) {
    	
        ItemStack itemstack = this.getRecipeOutput().copy();

        if (this.field_92101_f) {
        	
            for (int i = 0; i < invCrafting.getSizeInventory(); ++i) {
            	
                ItemStack itemstack1 = invCrafting.getStackInSlot(i);

                if (itemstack1 != null && itemstack1.hasTagCompound()) {
                	
                    itemstack.setTagCompound((NBTTagCompound)itemstack1.stackTagCompound.copy());
                    
                }
                
            }
            
        }

        return itemstack;
    }

   public int getRecipeSize() {
	   
        return this.recipeWidth * this.recipeHeight;
        
    }

    public WLLC_myWE_CrystalInfuserShapedRecipes func_92100_c() {
    	
        this.field_92101_f = true;
        return this;
        
    }

	@Override
	public boolean matches(InventoryCrafting invCrafting, World world) {
		
		return this.customMatches((WLLC_myWE_CrystalInfuserInventoryCrafting) invCrafting, world);
		
	}

	@Override
	public ItemStack getCraftingResult(InventoryCrafting invCrafting) {
		
		return this.customGetCraftingResult((WLLC_myWE_CrystalInfuserInventoryCrafting) invCrafting);
		
	}
    
}

 

 

How can I resolve this? Or I'm doing this terribly wrong?

Thanks in advice

Can we see your container code please?

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Container code: 

Spoiler

package com.WLLC.mysticWeapons.containers;

import com.WLLC.mysticWeapons.blocks.WLLC_myWE_Blocks;
import com.WLLC.mysticWeapons.crafting.crystalInfuser.WLLC_myWE_CrystalInfuserCraftingManager;
import com.WLLC.mysticWeapons.crafting.crystalInfuser.WLLC_myWE_CrystalInfuserInventoryCrafting;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCraftResult;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.SlotCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class WLLC_myWE_CrystalInfuserContainer extends Container {

	public WLLC_myWE_CrystalInfuserInventoryCrafting craftMatrix;
	public IInventory craftResult;
	private World worldObj;
	private int posX, posY, posZ;
	
	public WLLC_myWE_CrystalInfuserContainer(InventoryPlayer invPlayer, World world, int x, int y, int z) {
		
		craftMatrix = new WLLC_myWE_CrystalInfuserInventoryCrafting(this);
		craftResult = new InventoryCraftResult();
		worldObj = world;
		posX = x;
		posY = y;
		posZ = z;
		
		this.addSlotToContainer(new SlotCrafting(invPlayer.player, craftMatrix, craftResult, 0, 141, 43));
		
		for (int i = 0; i < 5; i++) {
			
			for (int k = 0; k < 5; k++) {
				
				if (i != 1 && i != 2 && i != 3) {
				
					this.addSlotToContainer(new Slot(craftMatrix, k + i * 5, 8 + k * 18, 7 + i * 18));
				
				} else if (i == 1 || i == 3) {
					
					if (k == 0 || k == 4) {
						
						this.addSlotToContainer(new Slot(craftMatrix, k + i * 5, 8 + k * 18, 7 + i * 18));
						
					}
					
				} else if (i == 2) {
					
					if (k != 1 && k != 3) {
						
						this.addSlotToContainer(new Slot(craftMatrix, k + i * 5, 8 + k * 18, 7 + i * 18));
						
					}
					
				}
				
			}
			
		}
		
		for (int i = 0; i < 3; i++) {
			
			for (int k = 0; k < 9; k++) {
				
				this.addSlotToContainer(new Slot(invPlayer, k + i * 9 + 9, 8 + k * 18, 106 + i * 18));
				
			}
			
		}
		
		for (int i = 0; i < 9; i++) {
			
			this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 164));
			
		}
		
		onCraftMatrixChanged(craftMatrix);
		
	}
	
	public void onCraftMatrixChanged(IInventory iinventory) {
		
		craftResult.setInventorySlotContents(0, WLLC_myWE_CrystalInfuserCraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj));
		
	}
	
	@Override
	public boolean canInteractWith(EntityPlayer player) {
		
		if (worldObj.getBlock(posX, posY, posZ) != WLLC_myWE_Blocks.crystalInfuser) {
			
			return false;
			
		} else {
			
			return player.getDistanceSq((double) posX + 0.5D, (double) posY + 0.5D, (double) posZ + 0.5D) <= 64.0D;
			
		}
	
	}
	
	public void onContainerClosed(EntityPlayer player) {
		
        super.onContainerClosed(player);

        if (!this.worldObj.isRemote) {
        	
            for (int i = 0; i < 25; ++i) {
            	
                ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i);

                if (itemstack != null) {
                	
                    player.dropPlayerItemWithRandomChoice(itemstack, false);
                    
                }
                
            }
            
        }
        
    }
	
	 public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int invSlot) {
		 
	        ItemStack itemstack = null;
	        Slot slot = (Slot)this.inventorySlots.get(invSlot);

	        if (slot != null && slot.getHasStack()) {
	        	
	            ItemStack itemstack1 = slot.getStack();
	            itemstack = itemstack1.copy();

	            if (invSlot == 0) {
	            	
	                if (!this.mergeItemStack(itemstack1, 10, 46, true)) {
	                	
	                    return null;
	                    
	                }

	                slot.onSlotChange(itemstack1, itemstack);
	                
	            } else if (invSlot >= 10 && invSlot < 37) {
	            	
	                if (!this.mergeItemStack(itemstack1, 37, 46, false)) {
	                	
	                    return null;
	                    
	                }
	                
	            } else if (invSlot >= 37 && invSlot < 46) {
	            	
	                if (!this.mergeItemStack(itemstack1, 10, 37, false)) {
	                	
	                    return null;
	                    
	                }
	                
	            } else if (!this.mergeItemStack(itemstack1, 10, 46, false)) {
	            	
	                return null;
	                
	            }

	            if (itemstack1.stackSize == 0) {
	            	
	                slot.putStack((ItemStack)null);
	                
	            } else {
	            	
	                slot.onSlotChanged();
	                
	            }

	            if (itemstack1.stackSize == itemstack.stackSize) {
	            	
	                return null;
	                
	            }

	            slot.onPickupFromSlot(p_82846_1_, itemstack1);
	        }

	        return itemstack;
	        
	    }

}

 

 

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.