Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address compatibility issues with JED dimensions #24

Merged
merged 4 commits into from
Apr 12, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions src/main/java/jackyy/dimensionaledibles/block/BlockCustomCake.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
import net.minecraft.util.*;
import net.minecraft.util.math.*;
import net.minecraft.world.*;
import net.minecraftforge.common.*;
import net.minecraftforge.fml.relauncher.*;

import javax.annotation.*;

import static jackyy.dimensionaledibles.DimensionalEdibles.*;
import static net.minecraftforge.common.DimensionManager.isDimensionRegistered;

public class BlockCustomCake extends BlockCakeBase implements ITileEntityProvider {

Expand Down Expand Up @@ -62,11 +62,9 @@ public boolean onBlockActivated(World world,
float hitY,
float hitZ) {



int dim = getDimension(world, pos);
if(!cache.containsKey(dim)) {
logger.error("No such dimension: \"{}\"", dim);
if(!isDimensionRegistered(dim)) {
logger.error("Requested dimension: \"{}\" does not exist. Please verify your configs.", dim);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of just logging, a chat message should be displayed as well, because I imagine that most players will not have their log open while playing the game, and so will miss the logger warning, leaving them wondering why the cake is not working.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a fair point. I've reworked this such that the server thread will log an error and the client thread will print a message to the user in-game.

return true;
}

Expand Down Expand Up @@ -156,19 +154,18 @@ public void getSubBlocks(CreativeTabs tab,
continue;
}
int dimension = Integer.parseInt(parts[0].trim());
if (DimensionManager.isDimensionRegistered(dimension)) {
stack = new ItemStack(this);
NBTTagCompound nbt = stack.getTagCompound();
if (nbt == null) {
nbt = new NBTTagCompound();
stack.setTagCompound(nbt);
}
nbt.setInteger("dimID", dimension);
nbt.setString("cakeName", parts[1].trim());
list.add(stack);
} else {
logger.error("\"{}\" is not a valid dimension ID!", parts[0]);

// Always register the requested cakes; JED dimensions may not be loaded yet
stack = new ItemStack(this);
NBTTagCompound nbt = stack.getTagCompound();
if (nbt == null) {
nbt = new NBTTagCompound();
stack.setTagCompound(nbt);
}
nbt.setInteger("dimID", dimension);
nbt.setString("cakeName", parts[1].trim());
list.add(stack);

} catch(NumberFormatException e) {
logger.error("\"{}\" is not a valid line input! The dimension ID needs to be a number!", s, e);
}
Expand Down