Paranoia null checks.
This commit is contained in:
@@ -53,11 +53,13 @@ public final class BlockEntityDeviceBusController extends CommonDeviceBusControl
|
||||
if (element instanceof final BlockDeviceBusElement blockElement) {
|
||||
final LevelAccessor elementLevel = blockElement.getLevel();
|
||||
final BlockPos elementPosition = blockElement.getPosition();
|
||||
newTrackedChunks.add(new TrackedChunk(elementLevel, elementPosition));
|
||||
newTrackedChunks.add(new TrackedChunk(elementLevel, elementPosition.relative(Direction.NORTH)));
|
||||
newTrackedChunks.add(new TrackedChunk(elementLevel, elementPosition.relative(Direction.EAST)));
|
||||
newTrackedChunks.add(new TrackedChunk(elementLevel, elementPosition.relative(Direction.SOUTH)));
|
||||
newTrackedChunks.add(new TrackedChunk(elementLevel, elementPosition.relative(Direction.WEST)));
|
||||
if (elementLevel != null) {
|
||||
newTrackedChunks.add(new TrackedChunk(elementLevel, elementPosition));
|
||||
newTrackedChunks.add(new TrackedChunk(elementLevel, elementPosition.relative(Direction.NORTH)));
|
||||
newTrackedChunks.add(new TrackedChunk(elementLevel, elementPosition.relative(Direction.EAST)));
|
||||
newTrackedChunks.add(new TrackedChunk(elementLevel, elementPosition.relative(Direction.SOUTH)));
|
||||
newTrackedChunks.add(new TrackedChunk(elementLevel, elementPosition.relative(Direction.WEST)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package li.cil.oc2.common.item;
|
||||
|
||||
import li.cil.oc2.common.tags.BlockTags;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -53,7 +54,10 @@ public final class WrenchItem extends ModItem {
|
||||
}
|
||||
|
||||
if (level.isClientSide()) {
|
||||
Minecraft.getInstance().gameMode.destroyBlock(pos);
|
||||
final MultiPlayerGameMode gameMode = Minecraft.getInstance().gameMode;
|
||||
if (gameMode != null) {
|
||||
gameMode.destroyBlock(pos);
|
||||
}
|
||||
} else if (player instanceof final ServerPlayer serverPlayer) {
|
||||
serverPlayer.gameMode.destroyBlock(pos);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.advancements.critereon.RecipeUnlockedTrigger;
|
||||
import net.minecraft.data.recipes.FinishedRecipe;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
@@ -84,7 +85,10 @@ public final class WrenchRecipeBuilder {
|
||||
}
|
||||
|
||||
public void save(final Consumer<FinishedRecipe> consumerIn) {
|
||||
this.save(consumerIn, ForgeRegistries.ITEMS.getKey(this.result));
|
||||
final ResourceLocation key = ForgeRegistries.ITEMS.getKey(this.result);
|
||||
if (key != null) {
|
||||
this.save(consumerIn, key);
|
||||
}
|
||||
}
|
||||
|
||||
public void save(final Consumer<FinishedRecipe> consumerIn, final String save) {
|
||||
@@ -99,7 +103,10 @@ public final class WrenchRecipeBuilder {
|
||||
public void save(final Consumer<FinishedRecipe> consumerIn, final ResourceLocation id) {
|
||||
this.validate(id);
|
||||
this.advancementBuilder.parent(new ResourceLocation("recipes/root")).addCriterion("has_the_recipe", RecipeUnlockedTrigger.unlocked(id)).rewards(AdvancementRewards.Builder.recipe(id)).requirements(RequirementsStrategy.OR);
|
||||
consumerIn.accept(new WrenchRecipeBuilder.Result(id, this.result, this.count, this.group == null ? "" : this.group, this.ingredients, this.advancementBuilder, new ResourceLocation(id.getNamespace(), "recipes/" + this.result.getItemCategory().getRecipeFolderName() + "/" + id.getPath())));
|
||||
final CreativeModeTab itemCategory = this.result.getItemCategory();
|
||||
if (itemCategory != null) {
|
||||
consumerIn.accept(new WrenchRecipeBuilder.Result(id, this.result, this.count, this.group == null ? "" : this.group, this.ingredients, this.advancementBuilder, new ResourceLocation(id.getNamespace(), "recipes/" + itemCategory.getRecipeFolderName() + "/" + id.getPath())));
|
||||
}
|
||||
}
|
||||
|
||||
private void validate(final ResourceLocation id) {
|
||||
@@ -140,7 +147,10 @@ public final class WrenchRecipeBuilder {
|
||||
|
||||
json.add("ingredients", jsonarray);
|
||||
final JsonObject jsonobject = new JsonObject();
|
||||
jsonobject.addProperty("item", ForgeRegistries.ITEMS.getKey(this.result).toString());
|
||||
final ResourceLocation key = ForgeRegistries.ITEMS.getKey(this.result);
|
||||
if (key != null) {
|
||||
jsonobject.addProperty("item", key.toString());
|
||||
}
|
||||
if (this.count > 1) {
|
||||
jsonobject.addProperty("count", this.count);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user