mirror of
https://github.com/GTNewHorizons/Mantle.git
synced 2026-11-17 02:45:19 +00:00
Add package info and fix nullability
Everything defaults to nonnull now, and is labeled where null is likely
This commit is contained in:
1 parent
c96d1f4f05
commit
f1037ce21a
61 files changed
+386
-256
No files matched your search
@@ -8,8 +8,6 @@ import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Creates a block with textures that connect to other blocks
|
||||
* <p>
|
||||
@@ -69,8 +67,7 @@ public class ConnectedTextureBlock extends Block {
|
||||
* @return Whether or not the side is connectable.
|
||||
*/
|
||||
private boolean isSideConnectable(BlockState state, IWorld world, BlockPos pos, Direction side) {
|
||||
final BlockState connected = world.getBlockState(pos.offset(side));
|
||||
return connected != null && this.canConnect(state, connected);
|
||||
return this.canConnect(state, world.getBlockState(pos.offset(side)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,7 +76,7 @@ public class ConnectedTextureBlock extends Block {
|
||||
* @param connected BlockState to check
|
||||
* @return True if the block is valid to connect
|
||||
*/
|
||||
protected boolean canConnect(@Nonnull BlockState original, @Nonnull BlockState connected) {
|
||||
protected boolean canConnect(BlockState original, BlockState connected) {
|
||||
return original.getBlock() == connected.getBlock();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package slimeknights.mantle.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -18,7 +17,6 @@ import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
import slimeknights.mantle.tileentity.InventoryTileEntity;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class InventoryBlock extends Block {
|
||||
@@ -33,7 +31,6 @@ public abstract class InventoryBlock extends Block {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public abstract TileEntity createTileEntity(BlockState state, IBlockReader world);
|
||||
|
||||
@@ -57,7 +54,7 @@ public abstract class InventoryBlock extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
|
||||
public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
|
||||
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
|
||||
|
||||
// set custom name from named stack
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.block;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -5,8 +5,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class CreativeTab extends ItemGroup {
|
||||
|
||||
private ItemStack icon;
|
||||
@@ -24,14 +22,12 @@ public class CreativeTab extends ItemGroup {
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public ItemStack getIcon() {
|
||||
return this.icon;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public ItemStack createIcon() {
|
||||
|
||||
@@ -13,13 +13,25 @@ import net.minecraftforge.fml.ModLoadingContext;
|
||||
import slimeknights.mantle.client.book.action.StringActionProcessor;
|
||||
import slimeknights.mantle.client.book.action.protocol.ProtocolGoToPage;
|
||||
import slimeknights.mantle.client.book.data.BookData;
|
||||
import slimeknights.mantle.client.book.data.content.*;
|
||||
import slimeknights.mantle.client.book.data.content.ContentBlank;
|
||||
import slimeknights.mantle.client.book.data.content.ContentBlockInteraction;
|
||||
import slimeknights.mantle.client.book.data.content.ContentCrafting;
|
||||
import slimeknights.mantle.client.book.data.content.ContentImage;
|
||||
import slimeknights.mantle.client.book.data.content.ContentImageText;
|
||||
import slimeknights.mantle.client.book.data.content.ContentSmelting;
|
||||
import slimeknights.mantle.client.book.data.content.ContentSmithing;
|
||||
import slimeknights.mantle.client.book.data.content.ContentStructure;
|
||||
import slimeknights.mantle.client.book.data.content.ContentText;
|
||||
import slimeknights.mantle.client.book.data.content.ContentTextImage;
|
||||
import slimeknights.mantle.client.book.data.content.ContentTextLeftImage;
|
||||
import slimeknights.mantle.client.book.data.content.ContentTextRightImage;
|
||||
import slimeknights.mantle.client.book.data.content.PageContent;
|
||||
import slimeknights.mantle.client.book.data.deserializer.HexStringDeserializer;
|
||||
import slimeknights.mantle.client.book.repository.BookRepository;
|
||||
import slimeknights.mantle.network.BookNetwork;
|
||||
import slimeknights.mantle.network.book.UpdateSavedPagePacket;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@@ -117,7 +129,7 @@ public class BookLoader implements IResourceManagerReloadListener {
|
||||
return info;
|
||||
}
|
||||
|
||||
public static void updateSavedPage(PlayerEntity player, ItemStack item, String page) {
|
||||
public static void updateSavedPage(@Nullable PlayerEntity player, ItemStack item, String page) {
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
@@ -133,7 +145,7 @@ public class BookLoader implements IResourceManagerReloadListener {
|
||||
* Reloads all the books, called when the resource manager reloads, such as when the resource pack or the language is changed
|
||||
*/
|
||||
@Override
|
||||
public void onResourceManagerReload(@Nonnull IResourceManager resourceManager) {
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {
|
||||
books.forEach((s, bookData) -> bookData.reset());
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import slimeknights.mantle.client.book.data.content.ContentTableOfContents;
|
||||
import slimeknights.mantle.client.book.data.element.TextData;
|
||||
import slimeknights.mantle.client.screen.book.BookScreen;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -41,7 +42,7 @@ public abstract class BookTransformer {
|
||||
public void transform(BookData book) {
|
||||
SectionData index = new SectionData(true) {
|
||||
@Override
|
||||
public void update(BookScreen.AdvancementCache advancementCache) {
|
||||
public void update(@Nullable BookScreen.AdvancementCache advancementCache) {
|
||||
this.pages.clear();
|
||||
|
||||
List<SectionData> visibleSections = this.parent.getVisibleSections(advancementCache);
|
||||
|
||||
@@ -3,8 +3,8 @@ package slimeknights.mantle.client.book;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
@@ -48,7 +48,7 @@ public class StructureBlockAccess implements IWorldReader {
|
||||
|
||||
@Override
|
||||
public WorldLightManager getLightManager() {
|
||||
return null;
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,12 +82,12 @@ public class StructureBlockAccess implements IWorldReader {
|
||||
|
||||
@Override
|
||||
public Biome getBiome(BlockPos pos) {
|
||||
return null;
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getNoiseBiomeRaw(int p_225604_1_, int p_225604_2_, int p_225604_3_) {
|
||||
return null;
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -133,22 +133,22 @@ public class StructureBlockAccess implements IWorldReader {
|
||||
|
||||
@Override
|
||||
public BiomeManager getBiomeManager() {
|
||||
return null;
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldBorder getWorldBorder() {
|
||||
return null;
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkNoEntityCollision(Entity entityIn, VoxelShape shape) {
|
||||
public boolean checkNoEntityCollision(@Nullable Entity entityIn, VoxelShape shape) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<VoxelShape> func_230318_c_(@Nullable Entity p_230318_1_, AxisAlignedBB p_230318_2_, Predicate<Entity> p_230318_3_) {
|
||||
return null;
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -163,7 +163,7 @@ public class StructureBlockAccess implements IWorldReader {
|
||||
|
||||
@Override
|
||||
public DimensionType func_230315_m_() {
|
||||
return null;
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
package slimeknights.mantle.client.book.action;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import slimeknights.mantle.client.book.action.protocol.ActionProtocol;
|
||||
import slimeknights.mantle.client.screen.book.BookScreen;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class StringActionProcessor {
|
||||
|
||||
public static final String PROTOCOL_SEPARATOR = ":";
|
||||
|
||||
private static final HashMap<String, ActionProtocol> protocols = new HashMap<>();
|
||||
|
||||
public static void registerProtocol(ActionProtocol protocol) {
|
||||
public static void registerProtocol(@Nullable ActionProtocol protocol) {
|
||||
if (protocol == null || protocol.protocol == null || protocol.protocol.isEmpty()) {
|
||||
throw new IllegalArgumentException("Protocol must be defined and must not have an empty protocol identifier.");
|
||||
}
|
||||
@@ -23,8 +24,8 @@ public class StringActionProcessor {
|
||||
}
|
||||
|
||||
//Format: action://param
|
||||
public static void process(String action, BookScreen book) {
|
||||
if (!action.contains(PROTOCOL_SEPARATOR)) {
|
||||
public static void process(@Nullable String action, BookScreen book) {
|
||||
if (action == null || !action.contains(PROTOCOL_SEPARATOR)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.client.book.action;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.client.book.action.protocol;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -15,7 +15,6 @@ import slimeknights.mantle.client.book.data.element.ItemStackData;
|
||||
import slimeknights.mantle.client.book.repository.BookRepository;
|
||||
import slimeknights.mantle.client.screen.book.BookScreen;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -198,11 +197,13 @@ public class BookData implements IDataItem {
|
||||
Mantle.logger.info("Finished loading book");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SectionData findSection(String name) {
|
||||
return this.findSection(name, null);
|
||||
}
|
||||
|
||||
public SectionData findSection(String name, BookScreen.AdvancementCache advancementCache) {
|
||||
@Nullable
|
||||
public SectionData findSection(String name, @Nullable BookScreen.AdvancementCache advancementCache) {
|
||||
for (SectionData section : this.sections) {
|
||||
section.update(advancementCache);
|
||||
|
||||
@@ -237,10 +238,12 @@ public class BookData implements IDataItem {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PageData findPage(int number) {
|
||||
return this.findPage(number, null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PageData findPage(int number, @Nullable BookScreen.AdvancementCache advancementCache) {
|
||||
if (number < 0) {
|
||||
return null;
|
||||
@@ -265,10 +268,12 @@ public class BookData implements IDataItem {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PageData findPage(String location) {
|
||||
return this.findPage(location, null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PageData findPage(String location, @Nullable BookScreen.AdvancementCache advancementCache) {
|
||||
return this.findPage(this.findPageNumber(location, advancementCache));
|
||||
}
|
||||
@@ -363,7 +368,7 @@ public class BookData implements IDataItem {
|
||||
return out != null ? out : string;
|
||||
}
|
||||
|
||||
public void openGui(@Nonnull ITextComponent title, @Nullable ItemStack item) {
|
||||
public void openGui(ITextComponent title, @Nullable ItemStack item) {
|
||||
if (!this.initialized) {
|
||||
this.load();
|
||||
}
|
||||
@@ -372,13 +377,13 @@ public class BookData implements IDataItem {
|
||||
}
|
||||
}
|
||||
|
||||
public void addRepository(BookRepository repository) {
|
||||
public void addRepository(@Nullable BookRepository repository) {
|
||||
if (repository != null && !this.repositories.contains(repository)) {
|
||||
this.repositories.add(repository);
|
||||
}
|
||||
}
|
||||
|
||||
public void addTransformer(BookTransformer transformer) {
|
||||
public void addTransformer(@Nullable BookTransformer transformer) {
|
||||
if (transformer != null && !this.transformers.contains(transformer)) {
|
||||
this.transformers.add(transformer);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class SectionData implements IDataItem {
|
||||
return this.pages.size();
|
||||
}
|
||||
|
||||
public boolean isUnlocked(BookScreen.AdvancementCache advancementCache) {
|
||||
public boolean isUnlocked(@Nullable BookScreen.AdvancementCache advancementCache) {
|
||||
if (advancementCache == null || this.requirements == null || this.requirements.size() == 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class SectionData implements IDataItem {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean requirementSatisfied(String requirement, BookScreen.AdvancementCache advancementCache) {
|
||||
public static boolean requirementSatisfied(String requirement, @Nullable BookScreen.AdvancementCache advancementCache) {
|
||||
if (advancementCache == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.client.book.data.content;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.client.book.data.deserializer;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.client.book.data.element;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.client.book.data;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.client.book;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -2,26 +2,26 @@ package slimeknights.mantle.client.book.repository;
|
||||
|
||||
import net.minecraft.resources.IResource;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import slimeknights.mantle.client.book.data.SectionData;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class DummyRepository extends BookRepository {
|
||||
|
||||
@Override
|
||||
public List<SectionData> getSections() {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getResourceLocation(String path, boolean safe) {
|
||||
return null;
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IResource getResource(ResourceLocation loc) {
|
||||
return null;
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -31,6 +31,6 @@ public class DummyRepository extends BookRepository {
|
||||
|
||||
@Override
|
||||
public String resourceToString(IResource resource, boolean skipCommments) {
|
||||
return null;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.client.book.repository;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -1,21 +1,17 @@
|
||||
package slimeknights.mantle.client.model;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Groups multiple baked models into a single one. Does not respect state etc. when getting quads.
|
||||
@@ -31,17 +27,9 @@ public class BakedCompositeModel extends BakedWrapper {
|
||||
this.parts = parts;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand) {
|
||||
return this.getQuads(state, side, rand, EmptyModelData.INSTANCE);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) {
|
||||
return this.parts.get(Optional.fromNullable(side));
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData extraData) {
|
||||
return this.parts.get(Optional.ofNullable(side));
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
@@ -63,7 +51,7 @@ public class BakedCompositeModel extends BakedWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
public void add(IBakedModel model, BlockState state, Direction side, Random rand) {
|
||||
public void add(IBakedModel model, BlockState state, @Nullable Direction side, Random rand) {
|
||||
int index;
|
||||
if (side == null) {
|
||||
index = 6;
|
||||
@@ -76,9 +64,9 @@ public class BakedCompositeModel extends BakedWrapper {
|
||||
}
|
||||
|
||||
public BakedCompositeModel build(IBakedModel parent) {
|
||||
ImmutableMap.Builder<Optional<Direction>, ImmutableList<BakedQuad>> map = ImmutableMap.builder();
|
||||
ImmutableMap.Builder<Optional<Direction>,ImmutableList<BakedQuad>> map = ImmutableMap.builder();
|
||||
|
||||
map.put(Optional.absent(), this.builders[6].build());
|
||||
map.put(Optional.empty(), this.builders[6].build());
|
||||
for (Direction side : Direction.values()) {
|
||||
map.put(Optional.of(side), this.builders[side.getIndex()].build());
|
||||
}
|
||||
|
||||
@@ -4,18 +4,17 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraftforge.client.model.PerspectiveMapWrapper;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
@@ -60,16 +59,14 @@ public class BakedSimple implements IBakedModel {
|
||||
this.overrides = overrides;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand) {
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) {
|
||||
return this.getQuads(state, side, rand, EmptyModelData.INSTANCE);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) {
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData extraData) {
|
||||
return this.quads;
|
||||
}
|
||||
|
||||
@@ -93,27 +90,23 @@ public class BakedSimple implements IBakedModel {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public TextureAtlasSprite getParticleTexture() {
|
||||
return this.particle;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture(@Nonnull IModelData data) {
|
||||
public TextureAtlasSprite getParticleTexture(IModelData data) {
|
||||
return this.particle;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public ItemCameraTransforms getItemCameraTransforms() {
|
||||
return ItemCameraTransforms.DEFAULT;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemOverrideList getOverrides() {
|
||||
return this.overrides;
|
||||
@@ -128,9 +121,9 @@ public class BakedSimple implements IBakedModel {
|
||||
|
||||
private final IBakedModel parent;
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public Wrapper(ImmutableList<BakedQuad> quads, IBakedModel base) {
|
||||
super(quads, null, base);
|
||||
|
||||
this.parent = base;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package slimeknights.mantle.client.model;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
@@ -11,12 +10,12 @@ import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraft.world.IBlockDisplayReader;
|
||||
import net.minecraftforge.client.model.PerspectiveMapWrapper;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
@@ -29,16 +28,14 @@ public class BakedWrapper implements IBakedModel {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand) {
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) {
|
||||
return this.getQuads(state, side, rand, EmptyModelData.INSTANCE);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) {
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData extraData) {
|
||||
return this.parent.getQuads(state, side, rand, extraData);
|
||||
}
|
||||
|
||||
@@ -62,35 +59,30 @@ public class BakedWrapper implements IBakedModel {
|
||||
return this.parent.isBuiltInRenderer();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public TextureAtlasSprite getParticleTexture() {
|
||||
return this.parent.getParticleTexture();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture(@Nonnull IModelData data) {
|
||||
public TextureAtlasSprite getParticleTexture(IModelData data) {
|
||||
return this.parent.getParticleTexture(data);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public ItemCameraTransforms getItemCameraTransforms() {
|
||||
return this.parent.getItemCameraTransforms();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemOverrideList getOverrides() {
|
||||
return this.parent.getOverrides();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData(@Nonnull IBlockDisplayReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData) {
|
||||
public IModelData getModelData(IBlockDisplayReader world, BlockPos pos, BlockState state, IModelData tileData) {
|
||||
return this.parent.getModelData(world, pos, state, tileData);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package slimeknights.mantle.client.model;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
@@ -11,12 +10,12 @@ import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraft.world.IBlockDisplayReader;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import slimeknights.mantle.client.ModelHelper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
@@ -49,16 +48,14 @@ public class BlockItemModelWrapper implements IBakedModel {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand) {
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) {
|
||||
return this.getQuads(state, side, rand, EmptyModelData.INSTANCE);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) {
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData extraData) {
|
||||
return this.parent.getQuads(state, side, rand, extraData);
|
||||
}
|
||||
|
||||
@@ -82,33 +79,28 @@ public class BlockItemModelWrapper implements IBakedModel {
|
||||
return this.parent.isBuiltInRenderer();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public TextureAtlasSprite getParticleTexture() {
|
||||
return this.parent.getParticleTexture();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture(@Nonnull IModelData data) {
|
||||
public TextureAtlasSprite getParticleTexture(IModelData data) {
|
||||
return this.parent.getParticleTexture(data);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData(@Nonnull IBlockDisplayReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData) {
|
||||
public IModelData getModelData(IBlockDisplayReader world, BlockPos pos, BlockState state, IModelData tileData) {
|
||||
return this.parent.getModelData(world, pos, state, tileData);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public ItemCameraTransforms getItemCameraTransforms() {
|
||||
return this.parent.getItemCameraTransforms();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemOverrideList getOverrides() {
|
||||
return ItemOverrideList.EMPTY;
|
||||
|
||||
@@ -2,27 +2,26 @@ package slimeknights.mantle.client.model;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.util.math.vector.Matrix3f;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.util.math.vector.Vector4f;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.math.vector.Matrix3f;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.util.math.vector.Vector4f;
|
||||
import net.minecraftforge.client.model.pipeline.BakedQuadBuilder;
|
||||
import net.minecraftforge.client.model.pipeline.VertexTransformer;
|
||||
import net.minecraftforge.common.model.TransformationHelper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@@ -67,9 +66,8 @@ public class TRSRBakedModel implements IBakedModel {
|
||||
this.transformation = new TransformationMatrix(null, null, null, TransformationHelper.quatFromXYZ(new float[] { 0, (float) r, 0 }, false)).blockCenterToCorner();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(BlockState state, Direction side, Random rand) {
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) {
|
||||
// transform quads obtained from parent
|
||||
|
||||
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
|
||||
@@ -114,20 +112,17 @@ public class TRSRBakedModel implements IBakedModel {
|
||||
return this.original.isBuiltInRenderer();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture() {
|
||||
return this.original.getParticleTexture();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public ItemCameraTransforms getItemCameraTransforms() {
|
||||
return this.original.getItemCameraTransforms();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemOverrideList getOverrides() {
|
||||
return this.override;
|
||||
@@ -141,11 +136,13 @@ public class TRSRBakedModel implements IBakedModel {
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel func_239290_a_(@Nonnull IBakedModel originalModel, ItemStack stack, @Nonnull ClientWorld world, @Nonnull LivingEntity entity) {
|
||||
public IBakedModel func_239290_a_(IBakedModel originalModel, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity) {
|
||||
IBakedModel baked = this.model.original.getOverrides().func_239290_a_(originalModel, stack, world, entity);
|
||||
|
||||
if (baked == null) {
|
||||
return null;
|
||||
}
|
||||
return new TRSRBakedModel(baked, this.model.transformation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.client.model;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.client;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.util.text.ITextComponent;
|
||||
import slimeknights.mantle.inventory.MultiModuleContainer;
|
||||
import slimeknights.mantle.inventory.WrapperSlot;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -101,6 +101,7 @@ public class MultiModuleScreen<CONTAINER extends MultiModuleContainer<?>> extend
|
||||
}
|
||||
|
||||
protected void drawPlayerInventoryName(MatrixStack matrixStack) {
|
||||
assert Minecraft.getInstance().player != null;
|
||||
ITextComponent localizedName = Minecraft.getInstance().player.inventory.getDisplayName();
|
||||
this.font.func_238422_b_(matrixStack, localizedName, 8, this.ySize - 96 + 2, 0x404040);
|
||||
}
|
||||
@@ -116,7 +117,7 @@ public class MultiModuleScreen<CONTAINER extends MultiModuleContainer<?>> extend
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resize(@Nonnull Minecraft mc, int width, int height) {
|
||||
public void resize(Minecraft mc, int width, int height) {
|
||||
super.resize(mc, width, height);
|
||||
|
||||
for (ModuleScreen module : this.modules) {
|
||||
@@ -272,6 +273,7 @@ public class MultiModuleScreen<CONTAINER extends MultiModuleContainer<?>> extend
|
||||
return super.mouseReleased(mouseX, mouseY, state);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected ModuleScreen getModuleForPoint(double x, double y) {
|
||||
for (ModuleScreen module : this.modules) {
|
||||
if (this.isPointInRegion(module.guiLeft, module.guiTop, module.guiRight(), module.guiBottom(), x + this.cornerX, y + this.cornerY)) {
|
||||
@@ -282,10 +284,12 @@ public class MultiModuleScreen<CONTAINER extends MultiModuleContainer<?>> extend
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected ModuleScreen getModuleForSlot(int slotNumber) {
|
||||
return this.getModuleForContainer(this.getContainer().getSlotContainer(slotNumber));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected ModuleScreen getModuleForContainer(Container container) {
|
||||
for (ModuleScreen module : this.modules) {
|
||||
if (module.getContainer() == container) {
|
||||
@@ -296,7 +300,6 @@ public class MultiModuleScreen<CONTAINER extends MultiModuleContainer<?>> extend
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CONTAINER getContainer() {
|
||||
return this.container;
|
||||
|
||||
@@ -627,10 +627,12 @@ public class BookScreen extends Screen {
|
||||
private HashMap<Advancement, AdvancementProgress> progress = new HashMap<>();
|
||||
private HashMap<ResourceLocation, Advancement> nameCache = new HashMap<>();
|
||||
|
||||
@Nullable
|
||||
public AdvancementProgress getProgress(String id) {
|
||||
return this.getProgress(this.getAdvancement(id));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public AdvancementProgress getProgress(Advancement advancement) {
|
||||
return this.progress.get(advancement);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import slimeknights.mantle.Mantle;
|
||||
import slimeknights.mantle.client.book.data.element.TextData;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -29,6 +29,7 @@ public class TextDataRenderer {
|
||||
/**
|
||||
* @deprecated Call drawText with tooltip param and then call drawTooltip separately on the tooltip layer to prevent overlap
|
||||
*/
|
||||
@Nullable
|
||||
public static String drawText(MatrixStack matrixStack, int x, int y, int boxWidth, int boxHeight, TextData[] data, int mouseX, int mouseY, FontRenderer fr) {
|
||||
List<ITextComponent> tooltip = new ArrayList<ITextComponent>();
|
||||
String action = drawText(matrixStack, x, y, boxWidth, boxHeight, data, mouseX, mouseY, fr, tooltip);
|
||||
@@ -40,7 +41,8 @@ public class TextDataRenderer {
|
||||
return action;
|
||||
}
|
||||
|
||||
public static String drawText(MatrixStack matrixStack, int x, int y, int boxWidth, int boxHeight, TextData[] data, int mouseX, int mouseY, FontRenderer fr, @Nonnull List<ITextComponent> tooltip) {
|
||||
@Nullable
|
||||
public static String drawText(MatrixStack matrixStack, int x, int y, int boxWidth, int boxHeight, TextData[] data, int mouseX, int mouseY, FontRenderer fr, List<ITextComponent> tooltip) {
|
||||
String action = "";
|
||||
|
||||
int atX = x;
|
||||
|
||||
@@ -15,7 +15,6 @@ import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
import slimeknights.mantle.client.screen.book.BookScreen;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract class BookElement extends AbstractGui {
|
||||
@@ -54,17 +53,15 @@ public abstract class BookElement extends AbstractGui {
|
||||
}
|
||||
|
||||
public void renderToolTip(MatrixStack matrixStack, FontRenderer fontRenderer, ItemStack stack, int x, int y) {
|
||||
if (stack != null) {
|
||||
List<ITextComponent> list = stack.getTooltip(this.mc.player, this.mc.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL);
|
||||
List<ITextComponent> list = stack.getTooltip(this.mc.player, this.mc.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL);
|
||||
|
||||
FontRenderer font = stack.getItem().getFontRenderer(stack);
|
||||
if (font == null) {
|
||||
font = fontRenderer;
|
||||
}
|
||||
|
||||
this.drawHoveringText(matrixStack, list, x, y, font);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
FontRenderer font = stack.getItem().getFontRenderer(stack);
|
||||
if (font == null) {
|
||||
font = fontRenderer;
|
||||
}
|
||||
|
||||
this.drawHoveringText(matrixStack, list, x, y, font);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
}
|
||||
|
||||
public void drawHoveringText(MatrixStack matrixStack, List<ITextComponent> textLines, int x, int y, FontRenderer font) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import slimeknights.mantle.client.book.action.StringActionProcessor;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@@ -25,6 +26,7 @@ public class ItemElement extends SizedBookElement {
|
||||
|
||||
public NonNullList<ItemStack> itemCycle;
|
||||
public float scale;
|
||||
@Nullable
|
||||
public String action;
|
||||
public List<ITextComponent> tooltip;
|
||||
|
||||
@@ -44,18 +46,18 @@ public class ItemElement extends SizedBookElement {
|
||||
}
|
||||
|
||||
public ItemElement(int x, int y, float scale, Collection<ItemStack> itemCycle) {
|
||||
this(x, y, scale, itemCycle.toArray(new ItemStack[itemCycle.size()]));
|
||||
this(x, y, scale, itemCycle.toArray(new ItemStack[0]));
|
||||
}
|
||||
|
||||
public ItemElement(int x, int y, float scale, Collection<ItemStack> itemCycle, String action) {
|
||||
this(x, y, scale, itemCycle.toArray(new ItemStack[itemCycle.size()]), action);
|
||||
this(x, y, scale, itemCycle.toArray(new ItemStack[0]), action);
|
||||
}
|
||||
|
||||
public ItemElement(int x, int y, float scale, ItemStack... itemCycle) {
|
||||
this(x, y, scale, itemCycle, null);
|
||||
}
|
||||
|
||||
public ItemElement(int x, int y, float scale, ItemStack[] itemCycle, String action) {
|
||||
public ItemElement(int x, int y, float scale, ItemStack[] itemCycle, @Nullable String action) {
|
||||
super(x, y, MathHelper.floor(ITEM_SIZE_HARDCODED * scale), MathHelper.floor(ITEM_SIZE_HARDCODED * scale));
|
||||
|
||||
NonNullList<ItemStack> nonNullStacks = NonNullList.withSize(itemCycle.length, ItemStack.EMPTY);
|
||||
|
||||
@@ -26,7 +26,7 @@ public class TextElement extends SizedBookElement {
|
||||
}
|
||||
|
||||
public TextElement(int x, int y, int width, int height, Collection<TextData> text) {
|
||||
this(x, y, width, height, text.toArray(new TextData[text.size()]));
|
||||
this(x, y, width, height, text.toArray(new TextData[0]));
|
||||
}
|
||||
|
||||
public TextElement(int x, int y, int width, int height, TextData... text) {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.client.screen.book.element;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.client.screen.book;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.client.screen;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.common;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -19,6 +19,7 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializers;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
@@ -125,6 +126,7 @@ public abstract class AbstractConfigFile implements Serializable {
|
||||
return fields;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public byte[] getPacketData() {
|
||||
try {
|
||||
return Files.readAllBytes(this.file.toPath());
|
||||
|
||||
@@ -9,6 +9,8 @@ import ninja.leaping.configurate.ConfigurationNode;
|
||||
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class BlockState {
|
||||
|
||||
private static final BlockState MISSING = new BlockState(Blocks.AIR, "");
|
||||
@@ -20,7 +22,7 @@ public class BlockState {
|
||||
String[] parts = val.split(":");
|
||||
|
||||
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(parts[0], parts[1]));
|
||||
if (block == Blocks.AIR) {
|
||||
if (block == null || block == Blocks.AIR) {
|
||||
return MISSING;
|
||||
}
|
||||
String state = "";
|
||||
@@ -80,7 +82,7 @@ public class BlockState {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String val = this.block.getRegistryName().toString();
|
||||
String val = Objects.requireNonNull(this.block.getRegistryName()).toString();
|
||||
if (!this.state.equals("")) {
|
||||
val += ":" + this.state;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ class ExampleSync {
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void playerJoinedWorld(TickEvent.ClientTickEvent event) {
|
||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
||||
assert player != null;
|
||||
if (needsRestart) {
|
||||
player.sendMessage(new StringTextComponent("Configs synced with server. Configs require a restart"), Util.DUMMY_UUID);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.config;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -18,7 +18,6 @@ import net.minecraftforge.fml.DistExecutor;
|
||||
import slimeknights.mantle.util.SlimeknightException;
|
||||
import slimeknights.mantle.util.TileEntityUtil;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BaseContainer<TILE extends TileEntity> extends Container {
|
||||
@@ -38,7 +37,8 @@ public class BaseContainer<TILE extends TileEntity> extends Container {
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
public TILE getTileEntity() {
|
||||
@Nullable
|
||||
public TILE getTile() {
|
||||
return this.tile;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public class BaseContainer<TILE extends TileEntity> extends Container {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(@Nonnull PlayerEntity playerIn) {
|
||||
public boolean canInteractWith(PlayerEntity playerIn) {
|
||||
if (this.tile == null) {
|
||||
return true;
|
||||
}
|
||||
@@ -105,7 +105,6 @@ public class BaseContainer<TILE extends TileEntity> extends Container {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NonNullList<ItemStack> getInventory() {
|
||||
return super.getInventory();
|
||||
@@ -136,7 +135,7 @@ public class BaseContainer<TILE extends TileEntity> extends Container {
|
||||
return BASE_Y_OFFSET;
|
||||
}
|
||||
|
||||
protected void addInventorySlots(@Nonnull PlayerInventory inv) {
|
||||
protected void addInventorySlots(PlayerInventory inv) {
|
||||
int yOffset = this.getInventoryYOffset();
|
||||
int xOffset = this.getInventoryXOffset();
|
||||
|
||||
@@ -156,7 +155,6 @@ public class BaseContainer<TILE extends TileEntity> extends Container {
|
||||
this.playerInventoryStart = start;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected Slot addSlot(Slot slotIn) {
|
||||
if (this.playerInventoryStart >= 0) {
|
||||
@@ -165,7 +163,6 @@ public class BaseContainer<TILE extends TileEntity> extends Container {
|
||||
return super.addSlot(slotIn);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) {
|
||||
// we can only support inventory <-> playerInventory
|
||||
@@ -207,7 +204,7 @@ public class BaseContainer<TILE extends TileEntity> extends Container {
|
||||
|
||||
// Fix for a vanilla bug: doesn't take Slot.getMaxStackSize into account
|
||||
@Override
|
||||
protected boolean mergeItemStack(@Nonnull ItemStack stack, int startIndex, int endIndex, boolean useEndIndex) {
|
||||
protected boolean mergeItemStack(ItemStack stack, int startIndex, int endIndex, boolean useEndIndex) {
|
||||
boolean ret = this.mergeItemStackRefill(stack, startIndex, endIndex, useEndIndex);
|
||||
if (!stack.isEmpty() && stack.getCount() > 0) {
|
||||
ret |= this.mergeItemStackMove(stack, startIndex, endIndex, useEndIndex);
|
||||
@@ -216,7 +213,7 @@ public class BaseContainer<TILE extends TileEntity> extends Container {
|
||||
}
|
||||
|
||||
// only refills items that are already present
|
||||
protected boolean mergeItemStackRefill(@Nonnull ItemStack stack, int startIndex, int endIndex, boolean useEndIndex) {
|
||||
protected boolean mergeItemStackRefill(ItemStack stack, int startIndex, int endIndex, boolean useEndIndex) {
|
||||
if (stack.getCount() <= 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -265,7 +262,7 @@ public class BaseContainer<TILE extends TileEntity> extends Container {
|
||||
}
|
||||
|
||||
// only moves items into empty slots
|
||||
protected boolean mergeItemStackMove(@Nonnull ItemStack stack, int startIndex, int endIndex, boolean useEndIndex) {
|
||||
protected boolean mergeItemStackMove(ItemStack stack, int startIndex, int endIndex, boolean useEndIndex) {
|
||||
if (stack.getCount() <= 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -314,7 +311,8 @@ public class BaseContainer<TILE extends TileEntity> extends Container {
|
||||
return flag1;
|
||||
}
|
||||
|
||||
public static <TILE extends TileEntity> TILE getTileEntityFromBuf(PacketBuffer buf, Class<TILE> type) {
|
||||
@Nullable
|
||||
public static <TILE extends TileEntity> TILE getTileEntityFromBuf(@Nullable PacketBuffer buf, Class<TILE> type) {
|
||||
if (buf == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@ import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.container.CraftingResultSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraftforge.fml.hooks.BasicEventHooks;
|
||||
|
||||
public class CraftingCustomSlot extends CraftingResultSlot {
|
||||
|
||||
@@ -27,9 +26,8 @@ public class CraftingCustomSlot extends CraftingResultSlot {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack onTake(PlayerEntity playerIn, @Nonnull ItemStack stack) {
|
||||
net.minecraftforge.fml.hooks.BasicEventHooks.firePlayerCraftingEvent(playerIn, stack, this.craftMatrix);
|
||||
public ItemStack onTake(PlayerEntity playerIn, ItemStack stack) {
|
||||
BasicEventHooks.firePlayerCraftingEvent(playerIn, stack, this.craftMatrix);
|
||||
this.onCrafting(stack);
|
||||
|
||||
this.callback.onCrafting(playerIn, stack, this.craftMatrix);
|
||||
|
||||
@@ -16,7 +16,6 @@ import net.minecraft.util.math.BlockPos;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -61,10 +60,12 @@ public class MultiModuleContainer<TILE extends TileEntity & IInventory> extends
|
||||
this.subContainerSlotRanges.put(subcontainer, Pair.of(begin, end));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public <CONTAINER extends Container> CONTAINER getSubContainer(Class<CONTAINER> clazz) {
|
||||
return this.getSubContainer(clazz, 0);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public <CONTAINER extends Container> CONTAINER getSubContainer(Class<CONTAINER> clazz, int index) {
|
||||
for (Container sub : this.subContainers) {
|
||||
if (clazz.isAssignableFrom(sub.getClass())) {
|
||||
@@ -72,7 +73,7 @@ public class MultiModuleContainer<TILE extends TileEntity & IInventory> extends
|
||||
}
|
||||
|
||||
if (index < 0) {
|
||||
return (CONTAINER) sub;
|
||||
return clazz.cast(sub);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ public class MultiModuleContainer<TILE extends TileEntity & IInventory> extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(@Nonnull PlayerEntity playerIn) {
|
||||
public boolean canInteractWith(PlayerEntity playerIn) {
|
||||
// check if subcontainers are valid
|
||||
for (Container sub : this.subContainers) {
|
||||
if (!sub.canInteractWith(playerIn)) {
|
||||
@@ -108,7 +109,6 @@ public class MultiModuleContainer<TILE extends TileEntity & IInventory> extends
|
||||
super.onContainerClosed(playerIn);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack slotClick(int slotId, int dragType, ClickType type, PlayerEntity player) {
|
||||
if (slotId == -999 && type == ClickType.QUICK_CRAFT) {
|
||||
@@ -122,7 +122,6 @@ public class MultiModuleContainer<TILE extends TileEntity & IInventory> extends
|
||||
|
||||
// More sophisticated version of the one in BaseContainer
|
||||
// Takes submodules into account when shiftclicking!
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) {
|
||||
Slot slot = this.inventorySlots.get(index);
|
||||
@@ -176,8 +175,7 @@ public class MultiModuleContainer<TILE extends TileEntity & IInventory> extends
|
||||
return this.notifySlotAfterTransfer(playerIn, itemstack, ret, slot);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
protected ItemStack notifySlotAfterTransfer(PlayerEntity player, @Nonnull ItemStack stack, @Nonnull ItemStack original, Slot slot) {
|
||||
protected ItemStack notifySlotAfterTransfer(PlayerEntity player, ItemStack stack, ItemStack original, Slot slot) {
|
||||
// notify slot
|
||||
slot.onSlotChange(stack, original);
|
||||
|
||||
@@ -196,7 +194,7 @@ public class MultiModuleContainer<TILE extends TileEntity & IInventory> extends
|
||||
return original;
|
||||
}
|
||||
|
||||
protected boolean moveToTileInventory(@Nonnull ItemStack itemstack) {
|
||||
protected boolean moveToTileInventory(ItemStack itemstack) {
|
||||
if (itemstack.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
@@ -208,7 +206,7 @@ public class MultiModuleContainer<TILE extends TileEntity & IInventory> extends
|
||||
return !this.mergeItemStack(itemstack, 0, end, false);
|
||||
}
|
||||
|
||||
protected boolean moveToPlayerInventory(@Nonnull ItemStack itemstack) {
|
||||
protected boolean moveToPlayerInventory(ItemStack itemstack) {
|
||||
if (itemstack.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
@@ -216,7 +214,7 @@ public class MultiModuleContainer<TILE extends TileEntity & IInventory> extends
|
||||
return this.playerInventoryStart > 0 && !this.mergeItemStack(itemstack, this.playerInventoryStart, this.inventorySlots.size(), true);
|
||||
}
|
||||
|
||||
protected boolean moveToAnyContainer(@Nonnull ItemStack itemstack, Collection<Container> containers) {
|
||||
protected boolean moveToAnyContainer(ItemStack itemstack, Collection<Container> containers) {
|
||||
if (itemstack.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
@@ -230,12 +228,12 @@ public class MultiModuleContainer<TILE extends TileEntity & IInventory> extends
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean moveToContainer(@Nonnull ItemStack itemstack, Container container) {
|
||||
protected boolean moveToContainer(ItemStack itemstack, Container container) {
|
||||
Pair<Integer, Integer> range = this.subContainerSlotRanges.get(container);
|
||||
return !this.mergeItemStack(itemstack, range.getLeft(), range.getRight(), false);
|
||||
}
|
||||
|
||||
protected boolean refillAnyContainer(@Nonnull ItemStack itemstack, Collection<Container> containers) {
|
||||
protected boolean refillAnyContainer(ItemStack itemstack, Collection<Container> containers) {
|
||||
if (itemstack.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
@@ -249,7 +247,7 @@ public class MultiModuleContainer<TILE extends TileEntity & IInventory> extends
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean refillContainer(@Nonnull ItemStack itemstack, Container container) {
|
||||
protected boolean refillContainer(ItemStack itemstack, Container container) {
|
||||
Pair<Integer, Integer> range = this.subContainerSlotRanges.get(container);
|
||||
return !this.mergeItemStackRefill(itemstack, range.getLeft(), range.getRight(), false);
|
||||
}
|
||||
@@ -257,6 +255,7 @@ public class MultiModuleContainer<TILE extends TileEntity & IInventory> extends
|
||||
/**
|
||||
* Searches for a sidechest to display in the UI
|
||||
*/
|
||||
@Nullable
|
||||
public <TE extends TileEntity> TE detectTE(Class<TE> clazz) {
|
||||
if (this.tile == null) {
|
||||
return null;
|
||||
@@ -268,6 +267,7 @@ public class MultiModuleContainer<TILE extends TileEntity & IInventory> extends
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private <TE extends TileEntity> TE detectChest(BlockPos pos, Class<TE> clazz) {
|
||||
if (this.tile == null) {
|
||||
return null;
|
||||
@@ -276,9 +276,8 @@ public class MultiModuleContainer<TILE extends TileEntity & IInventory> extends
|
||||
return null;
|
||||
} else {
|
||||
TileEntity te = this.tile.getWorld().getTileEntity(pos);
|
||||
|
||||
if (te != null && clazz.isAssignableFrom(te.getClass())) {
|
||||
return (TE) te;
|
||||
if (clazz.isInstance(te)) {
|
||||
return clazz.cast(te);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,6 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/** Slot that can only be taken out of */
|
||||
public class OutSlot extends Slot {
|
||||
|
||||
@@ -14,7 +12,7 @@ public class OutSlot extends Slot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(@Nonnull ItemStack stack) {
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,6 @@ import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class RestrictedItemSlot extends Slot {
|
||||
|
||||
private final Item allowedItem;
|
||||
@@ -17,7 +15,7 @@ public class RestrictedItemSlot extends Slot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(@Nonnull ItemStack stack) {
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return !stack.isEmpty() && stack.getItem() == this.allowedItem;
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,6 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Used to wrap the slots inside Modules/Subcontainers
|
||||
*/
|
||||
@@ -43,12 +41,11 @@ public class WrapperSlot extends Slot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(@Nonnull ItemStack stack) {
|
||||
public void putStack(ItemStack stack) {
|
||||
this.parent.putStack(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack onTake(PlayerEntity playerIn, ItemStack stack) {
|
||||
this.parent.onTake(playerIn, stack);
|
||||
|
||||
@@ -56,7 +53,6 @@ public class WrapperSlot extends Slot {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStack() {
|
||||
return this.parent.getStack();
|
||||
}
|
||||
@@ -87,7 +83,6 @@ public class WrapperSlot extends Slot {
|
||||
return this.parent.setBackground(atlas, sprite);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack decrStackSize(int amount) {
|
||||
return this.parent.decrStackSize(amount);
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.inventory;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.item;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -12,7 +12,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import slimeknights.mantle.tileentity.MantleTileEntity;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
||||
public class MultiServantLogic extends MantleTileEntity implements IServantLogic {
|
||||
|
||||
@@ -38,6 +38,7 @@ public class MultiServantLogic extends MantleTileEntity implements IServantLogic
|
||||
return false;
|
||||
}
|
||||
|
||||
assert this.world != null;
|
||||
if (this.world.getBlockState(this.master).getBlock() == this.masterBlock && this.world.getBlockState(this.master) == this.state) {
|
||||
return true;
|
||||
}
|
||||
@@ -54,6 +55,7 @@ public class MultiServantLogic extends MantleTileEntity implements IServantLogic
|
||||
}
|
||||
|
||||
public void overrideMaster(BlockPos pos) {
|
||||
assert this.world != null;
|
||||
this.hasMaster = true;
|
||||
this.master = pos;
|
||||
this.state = this.world.getBlockState(this.master);
|
||||
@@ -76,8 +78,9 @@ public class MultiServantLogic extends MantleTileEntity implements IServantLogic
|
||||
|
||||
@Deprecated
|
||||
public boolean verifyMaster(IMasterLogic logic, BlockPos pos) {
|
||||
assert this.world != null;
|
||||
return this.master.equals(pos) && this.world.getBlockState(pos) == this.state
|
||||
&& this.world.getBlockState(pos).getBlock() == this.masterBlock;
|
||||
&& this.world.getBlockState(pos).getBlock() == this.masterBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,6 +102,7 @@ public class MultiServantLogic extends MantleTileEntity implements IServantLogic
|
||||
@Override
|
||||
public void notifyMasterOfChange() {
|
||||
if (this.hasValidMaster()) {
|
||||
assert this.world != null;
|
||||
IMasterLogic logic = (IMasterLogic) this.world.getTileEntity(this.master);
|
||||
logic.notifyChange(this, this.pos);
|
||||
}
|
||||
@@ -122,7 +126,7 @@ public class MultiServantLogic extends MantleTileEntity implements IServantLogic
|
||||
tags.putInt("xCenter", this.master.getX());
|
||||
tags.putInt("yCenter", this.master.getY());
|
||||
tags.putInt("zCenter", this.master.getZ());
|
||||
tags.putString("MasterBlockName", ForgeRegistries.BLOCKS.getKey(this.masterBlock).toString());
|
||||
tags.putString("MasterBlockName", Objects.requireNonNull(this.masterBlock.getRegistryName()).toString());
|
||||
tags.putInt("masterState", Block.getStateId(this.state));
|
||||
}
|
||||
return tags;
|
||||
@@ -134,7 +138,6 @@ public class MultiServantLogic extends MantleTileEntity implements IServantLogic
|
||||
this.readCustomNBT(tags);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompoundNBT write(CompoundNBT tags) {
|
||||
tags = super.write(tags);
|
||||
@@ -142,7 +145,6 @@ public class MultiServantLogic extends MantleTileEntity implements IServantLogic
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompoundNBT getUpdateTag() {
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
@@ -154,18 +156,14 @@ public class MultiServantLogic extends MantleTileEntity implements IServantLogic
|
||||
public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket packet) {
|
||||
this.readCustomNBT(packet.getNbtCompound());
|
||||
//this.world.notifyLightSet(this.pos);
|
||||
assert world != null;
|
||||
BlockState state = world.getBlockState(this.pos);
|
||||
this.world.notifyBlockUpdate(this.pos, state, state, 3);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean setMaster(BlockPos pos) {
|
||||
assert this.world != null;
|
||||
if (!this.hasMaster || this.world.getBlockState(this.master) != this.state || (this.world.getBlockState(this.master).getBlock() != this.masterBlock)) {
|
||||
this.overrideMaster(pos);
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.multiblock;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -32,11 +32,11 @@ public class UpdateSavedPagePacket extends AbstractPacket {
|
||||
context.get().enqueueWork(() -> {
|
||||
if (context.get().getSender() != null && this.pageName != null) {
|
||||
PlayerEntity player = context.get().getSender();
|
||||
|
||||
ItemStack is = player.getHeldItem(Hand.MAIN_HAND);
|
||||
|
||||
if (!is.isEmpty()) {
|
||||
BookHelper.writeSavedPage(is, this.pageName);
|
||||
if (player != null) {
|
||||
ItemStack is = player.getHeldItem(Hand.MAIN_HAND);
|
||||
if (!is.isEmpty()) {
|
||||
BookHelper.writeSavedPage(is, this.pageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.network.book;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.network;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -22,7 +22,6 @@ import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
||||
import slimeknights.mantle.util.ItemStackList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
// Updated version of InventoryLogic in Mantle. Also contains a few bugfixes DOES NOT OVERRIDE createMenu
|
||||
@@ -56,7 +55,7 @@ public abstract class InventoryTileEntity extends MantleTileEntity implements II
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> net.minecraftforge.common.util.LazyOptional<T> getCapability(@Nonnull Capability<T> capability, Direction facing) {
|
||||
public <T> net.minecraftforge.common.util.LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing) {
|
||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
return this.itemHandlerCap.cast();
|
||||
}
|
||||
@@ -69,7 +68,6 @@ public abstract class InventoryTileEntity extends MantleTileEntity implements II
|
||||
|
||||
/* Inventory management */
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
if (slot < 0 || slot >= this.inventory.size()) {
|
||||
@@ -115,7 +113,7 @@ public abstract class InventoryTileEntity extends MantleTileEntity implements II
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, @Nonnull ItemStack itemstack) {
|
||||
public void setInventorySlotContents(int slot, ItemStack itemstack) {
|
||||
if (slot < 0 || slot >= this.inventory.size()) {
|
||||
return;
|
||||
}
|
||||
@@ -131,7 +129,6 @@ public abstract class InventoryTileEntity extends MantleTileEntity implements II
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int quantity) {
|
||||
if (quantity <= 0) {
|
||||
@@ -163,7 +160,6 @@ public abstract class InventoryTileEntity extends MantleTileEntity implements II
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int slot) {
|
||||
ItemStack itemStack = this.getStackInSlot(slot);
|
||||
@@ -172,7 +168,7 @@ public abstract class InventoryTileEntity extends MantleTileEntity implements II
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, @Nonnull ItemStack itemstack) {
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
|
||||
if (slot < this.getSizeInventory()) {
|
||||
return this.inventory.get(slot).isEmpty() || itemstack.getCount() + this.inventory.get(slot).getCount() <= this.getInventoryStackLimit();
|
||||
}
|
||||
@@ -186,7 +182,6 @@ public abstract class InventoryTileEntity extends MantleTileEntity implements II
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ITextComponent getName() {
|
||||
return this.inventoryTitle;
|
||||
@@ -207,7 +202,6 @@ public abstract class InventoryTileEntity extends MantleTileEntity implements II
|
||||
return this.inventoryTitle;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ITextComponent getDisplayName() {
|
||||
if (this.hasCustomName()) {
|
||||
@@ -219,9 +213,9 @@ public abstract class InventoryTileEntity extends MantleTileEntity implements II
|
||||
|
||||
/* Supporting methods */
|
||||
@Override
|
||||
public boolean isUsableByPlayer(@Nonnull PlayerEntity entityplayer) {
|
||||
public boolean isUsableByPlayer(PlayerEntity entityplayer) {
|
||||
// block changed/got broken?
|
||||
if (this.world.getTileEntity(this.pos) != this || this.world.getBlockState(this.pos).getBlock() == Blocks.AIR) {
|
||||
if (world == null || this.world.getTileEntity(this.pos) != this || this.getBlockState().getBlock() == Blocks.AIR) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -229,14 +223,10 @@ public abstract class InventoryTileEntity extends MantleTileEntity implements II
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(@Nonnull PlayerEntity player) {
|
||||
|
||||
}
|
||||
public void openInventory(PlayerEntity player) {}
|
||||
|
||||
@Override
|
||||
public void closeInventory(@Nonnull PlayerEntity player) {
|
||||
|
||||
}
|
||||
public void closeInventory(PlayerEntity player) {}
|
||||
|
||||
/* NBT */
|
||||
@Override
|
||||
@@ -250,8 +240,7 @@ public abstract class InventoryTileEntity extends MantleTileEntity implements II
|
||||
this.inventoryTitle = ITextComponent.Serializer.func_240643_a_(tags.getString("CustomName"));
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(CompoundNBT tags) {
|
||||
super.write(tags);
|
||||
@@ -296,8 +285,7 @@ public abstract class InventoryTileEntity extends MantleTileEntity implements II
|
||||
for (int i = 0; i < nbttaglist.size(); ++i) {
|
||||
CompoundNBT itemTag = nbttaglist.getCompound(i);
|
||||
int slot = itemTag.getByte("Slot") & 255;
|
||||
|
||||
if (slot >= 0 && slot < this.inventory.size()) {
|
||||
if (slot < this.inventory.size()) {
|
||||
stack = ItemStack.read(itemTag);
|
||||
if (!stack.isEmpty() && stack.getCount() > limit) {
|
||||
stack.setCount(limit);
|
||||
@@ -308,7 +296,6 @@ public abstract class InventoryTileEntity extends MantleTileEntity implements II
|
||||
}
|
||||
|
||||
/* Default implementations of hardly used methods */
|
||||
@Nonnull
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.tileentity;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -4,7 +4,6 @@ import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.UnmodifiableListIterator;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -40,21 +39,18 @@ public class ImmutableConcatList<E> implements List<E> {
|
||||
return this.iterable.contains(o);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return this.iterable.iterator();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return this.iterable.toList().toArray();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> T[] toArray(@Nonnull T[] a) {
|
||||
public <T> T[] toArray(T[] a) {
|
||||
return this.iterable.toList().toArray(a);
|
||||
}
|
||||
|
||||
@@ -69,7 +65,7 @@ public class ImmutableConcatList<E> implements List<E> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(@Nonnull Collection<?> c) {
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
for (Object e : c) {
|
||||
if (!this.contains(e)) {
|
||||
return false;
|
||||
@@ -79,22 +75,22 @@ public class ImmutableConcatList<E> implements List<E> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(@Nonnull Collection<? extends E> c) {
|
||||
public boolean addAll(Collection<? extends E> c) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(int index, @Nonnull Collection<? extends E> c) {
|
||||
public boolean addAll(int index, Collection<? extends E> c) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(@Nonnull Collection<?> c) {
|
||||
public boolean removeAll(Collection<?> c) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(@Nonnull Collection<?> c) {
|
||||
public boolean retainAll(Collection<?> c) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@@ -148,13 +144,11 @@ public class ImmutableConcatList<E> implements List<E> {
|
||||
return j;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ListIterator<E> listIterator() {
|
||||
return this.listIterator(0);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ListIterator<E> listIterator(int index) {
|
||||
return new ListItr<E>(this.size(), index) {
|
||||
@@ -165,7 +159,6 @@ public class ImmutableConcatList<E> implements List<E> {
|
||||
};
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<E> subList(int fromIndex, int toIndex) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraftforge.fml.ForgeI18n;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -51,7 +52,8 @@ public abstract class LocUtils {
|
||||
return list;
|
||||
}
|
||||
|
||||
public static String convertNewlines(String line) {
|
||||
@Nullable
|
||||
public static String convertNewlines(@Nullable String line) {
|
||||
if (line == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
package slimeknights.mantle.util;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.nbt.StringNBT;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class TagHelper {
|
||||
|
||||
public static int TAG_TYPE_STRING = (StringNBT.valueOf("")).getId();
|
||||
public static int TAG_TYPE_COMPOUND = (new CompoundNBT()).getId();
|
||||
|
||||
private TagHelper() {
|
||||
}
|
||||
|
||||
/* Generic Tag Operations */
|
||||
/**
|
||||
* Gets the tag from a stack, or an empty tag if the stack has none
|
||||
* @param stack Stack to fetch tag
|
||||
* @return Stack tag or an empty tag
|
||||
*/
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public static CompoundNBT getTagSafe(ItemStack stack) {
|
||||
if (stack.isEmpty() || !stack.hasTag()) {
|
||||
return new CompoundNBT();
|
||||
@@ -22,20 +27,30 @@ public class TagHelper {
|
||||
return stack.getTag();
|
||||
}
|
||||
|
||||
public static CompoundNBT getTagSafe(CompoundNBT tag, String key) {
|
||||
if (tag == null || !tag.contains(key)) {
|
||||
/**
|
||||
* Gets the value from the given tag
|
||||
* @param tag Parent tag
|
||||
* @param key Key to get
|
||||
* @return Compound at the key, or empty tag if no value
|
||||
*/
|
||||
public static CompoundNBT getTagSafe(@Nullable CompoundNBT tag, String key) {
|
||||
if (tag == null || !tag.contains(key, NBT.TAG_COMPOUND)) {
|
||||
return new CompoundNBT();
|
||||
}
|
||||
|
||||
return tag.getCompound(key);
|
||||
}
|
||||
|
||||
public static ListNBT getTagListSafe(CompoundNBT tag, String key, int type) {
|
||||
if (tag == null || !tag.contains(key)) {
|
||||
/**
|
||||
* Gets a tag list from an object, or an empty list if its missing
|
||||
* @param tag Parent tag
|
||||
* @param key List key
|
||||
* @param type List type
|
||||
* @return List at key, or empty list if missing
|
||||
*/
|
||||
public static ListNBT getTagListSafe(@Nullable CompoundNBT tag, String key, int type) {
|
||||
if (tag == null || !tag.contains(key, NBT.TAG_LIST)) {
|
||||
return new ListNBT();
|
||||
}
|
||||
|
||||
return tag.getList(key, type);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,18 +6,17 @@ import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import slimeknights.mantle.Mantle;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class TileEntityUtil {
|
||||
|
||||
@Nullable
|
||||
public static <T extends TileEntity> T getTileEntity(@Nonnull Class<T> clazz, @Nullable IBlockReader world, @Nonnull BlockPos pos) {
|
||||
public static <T extends TileEntity> T getTileEntity(Class<T> clazz, @Nullable IBlockReader world, BlockPos pos) {
|
||||
return getTileEntity(clazz, world, pos, false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static <T extends TileEntity> T getTileEntity(@Nonnull Class<T> clazz, @Nullable IBlockReader world, @Nonnull BlockPos pos, boolean logWrongType) {
|
||||
public static <T extends TileEntity> T getTileEntity(Class<T> clazz, @Nullable IBlockReader world, BlockPos pos, boolean logWrongType) {
|
||||
if (!isBlockLoaded(world, pos)) {
|
||||
return null;
|
||||
}
|
||||
@@ -38,7 +37,7 @@ public class TileEntityUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isBlockLoaded(@Nullable IBlockReader world, @Nonnull BlockPos pos) {
|
||||
public static boolean isBlockLoaded(@Nullable IBlockReader world, BlockPos pos) {
|
||||
if (world == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package slimeknights.mantle.util;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
Reference in new issue
Block a user