diff --git a/build.gradle b/build.gradle index 418704f..7fa839e 100644 --- a/build.gradle +++ b/build.gradle @@ -142,9 +142,9 @@ dependencies { minecraft 'net.minecraftforge:forge:' + minecraft_version + '-' + forge_version // compile against the JEI API but do not include it at runtime - compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}:api") + //compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}:api") // at runtime, use the full JEI jar - runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}") + //runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}") // Configuration shadow "ninja.leaping.configurate:configurate-hocon:${configurate_version}" diff --git a/gradle.properties b/gradle.properties index 8ff4947..da2d789 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,18 +3,18 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -mod_version=1.5 +mod_version=1.6 # Minecraft Version Information -minecraft_version=1.15.2 -minecraft_version_toml=15 +minecraft_version=1.16.1 +minecraft_version_toml=16 # Forge Version Information -forge_version=31.1.25 +forge_version=32.0.6 forge_version_toml=31 # Mappings Information -mappings_version=20200317-1.15.1 +mappings_version=20200514-1.16 jei_version=6.0.0.2 configurate_version=3.3 diff --git a/src/main/java/slimeknights/mantle/client/ExtraHeartRenderHandler.java b/src/main/java/slimeknights/mantle/client/ExtraHeartRenderHandler.java index 1f0297c..59ddbe0 100644 --- a/src/main/java/slimeknights/mantle/client/ExtraHeartRenderHandler.java +++ b/src/main/java/slimeknights/mantle/client/ExtraHeartRenderHandler.java @@ -1,11 +1,12 @@ package slimeknights.mantle.client; +import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.AbstractGui; import net.minecraft.entity.Entity; -import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.ai.attributes.Attributes; +import net.minecraft.entity.ai.attributes.ModifiableAttributeInstance; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; @@ -27,7 +28,7 @@ public class ExtraHeartRenderHandler { private static final ResourceLocation ICON_HEARTS = new ResourceLocation(Mantle.modId, "textures/gui/hearts.png"); private static final ResourceLocation ICON_ABSORB = new ResourceLocation(Mantle.modId, "textures/gui/absorb.png"); - private static final ResourceLocation ICON_VANILLA = AbstractGui.GUI_ICONS_LOCATION; + private static final ResourceLocation ICON_VANILLA = AbstractGui.field_230665_h_; private final Minecraft mc = Minecraft.getInstance(); @@ -43,8 +44,8 @@ public class ExtraHeartRenderHandler { private static int left_height = 39; - public void blit(int x, int y, int textureX, int textureY, int width, int height) { - Minecraft.getInstance().ingameGUI.blit(x, y, textureX, textureY, width, height); + public void blit(MatrixStack matrixStack, int x, int y, int textureX, int textureY, int width, int height) { + Minecraft.getInstance().ingameGUI.func_238474_b_(matrixStack, x, y, textureX, textureY, width, height); } /* HUD */ @@ -57,6 +58,7 @@ public class ExtraHeartRenderHandler { return; } PlayerEntity player = (PlayerEntity) this.mc.getRenderViewEntity(); + MatrixStack matrixStack = new MatrixStack(); // extra setup stuff from us left_height = ForgeIngameGui.left_height; @@ -91,7 +93,7 @@ public class ExtraHeartRenderHandler { this.playerHealth = health; int healthLast = this.lastPlayerHealth; - IAttributeInstance attrMaxHealth = player.getAttribute(SharedMonsterAttributes.MAX_HEALTH); + ModifiableAttributeInstance attrMaxHealth = player.getAttribute(Attributes.field_233818_a_); float healthMax = (float) attrMaxHealth.getValue(); float absorb = MathHelper.ceil(player.getAbsorptionAmount()); @@ -141,39 +143,39 @@ public class ExtraHeartRenderHandler { y -= 2; } - this.blit(x, y, BACKGROUND, TOP, 9, 9); + this.blit(matrixStack, x, y, BACKGROUND, TOP, 9, 9); if (highlight) { if (i * 2 + 1 < healthLast) { - this.blit(x, y, MARGIN + 54, TOP, 9, 9); //6 + this.blit(matrixStack, x, y, MARGIN + 54, TOP, 9, 9); //6 } else if (i * 2 + 1 == healthLast) { - this.blit(x, y, MARGIN + 63, TOP, 9, 9); //7 + this.blit(matrixStack, x, y, MARGIN + 63, TOP, 9, 9); //7 } } if (absorbRemaining > 0.0F) { if (absorbRemaining == absorb && absorb % 2.0F == 1.0F) { - this.blit(x, y, MARGIN + 153, TOP, 9, 9); //17 + this.blit(matrixStack, x, y, MARGIN + 153, TOP, 9, 9); //17 absorbRemaining -= 1.0F; } else { - this.blit(x, y, MARGIN + 144, TOP, 9, 9); //16 + this.blit(matrixStack, x, y, MARGIN + 144, TOP, 9, 9); //16 absorbRemaining -= 2.0F; } } else { if (i * 2 + 1 < health) { - this.blit(x, y, MARGIN + 36, TOP, 9, 9); //4 + this.blit(matrixStack, x, y, MARGIN + 36, TOP, 9, 9); //4 } else if (i * 2 + 1 == health) { - this.blit(x, y, MARGIN + 45, TOP, 9, 9); //5 + this.blit(matrixStack, x, y, MARGIN + 45, TOP, 9, 9); //5 } } } - this.renderExtraHearts(left, top, player); - this.renderExtraAbsorption(left, top - rowHeight, player); + this.renderExtraHearts(matrixStack, left, top, player); + this.renderExtraAbsorption(matrixStack, left, top - rowHeight, player); this.mc.getTextureManager().bindTexture(ICON_VANILLA); ForgeIngameGui.left_height += 10; @@ -187,17 +189,17 @@ public class ExtraHeartRenderHandler { this.mc.getProfiler().endSection(); } - private void renderExtraHearts(int xBasePos, int yBasePos, PlayerEntity player) { + private void renderExtraHearts(MatrixStack matrixStack, int xBasePos, int yBasePos, PlayerEntity player) { int potionOffset = this.getPotionOffset(player); // Extra hearts this.mc.getTextureManager().bindTexture(ICON_HEARTS); int hp = MathHelper.ceil(player.getHealth()); - this.renderCustomHearts(xBasePos, yBasePos, potionOffset, hp, false); + this.renderCustomHearts(matrixStack, xBasePos, yBasePos, potionOffset, hp, false); } - private void renderCustomHearts(int xBasePos, int yBasePos, int potionOffset, int count, boolean absorb) { + private void renderCustomHearts(MatrixStack matrixStack, int xBasePos, int yBasePos, int potionOffset, int count, boolean absorb) { int regenOffset = absorb ? 10 : 0; for (int iter = 0; iter < count / 20; iter++) { int renderHearts = (count - 20 * (iter + 1)) / 2; @@ -208,16 +210,16 @@ public class ExtraHeartRenderHandler { for (int i = 0; i < renderHearts; i++) { int y = this.getYRegenOffset(i, regenOffset); if (absorb) { - this.blit(xBasePos + 8 * i, yBasePos + y, 0, 54, 9, 9); + this.blit(matrixStack, xBasePos + 8 * i, yBasePos + y, 0, 54, 9, 9); } - this.blit(xBasePos + 8 * i, yBasePos + y, 18 * heartIndex, potionOffset, 9, 9); + this.blit(matrixStack, xBasePos + 8 * i, yBasePos + y, 18 * heartIndex, potionOffset, 9, 9); } if (count % 2 == 1 && renderHearts < 10) { int y = this.getYRegenOffset(renderHearts, regenOffset); if (absorb) { - this.blit(xBasePos + 8 * renderHearts, yBasePos + y, 0, 54, 9, 9); + this.blit(matrixStack, xBasePos + 8 * renderHearts, yBasePos + y, 0, 54, 9, 9); } - this.blit(xBasePos + 8 * renderHearts, yBasePos + y, 9 + 18 * heartIndex, potionOffset, 9, 9); + this.blit(matrixStack, xBasePos + 8 * renderHearts, yBasePos + y, 9 + 18 * heartIndex, potionOffset, 9, 9); } } } @@ -242,13 +244,13 @@ public class ExtraHeartRenderHandler { return potionOffset; } - private void renderExtraAbsorption(int xBasePos, int yBasePos, PlayerEntity player) { + private void renderExtraAbsorption(MatrixStack matrixStack, int xBasePos, int yBasePos, PlayerEntity player) { int potionOffset = this.getPotionOffset(player); // Extra hearts this.mc.getTextureManager().bindTexture(ICON_ABSORB); int absorb = MathHelper.ceil(player.getAbsorptionAmount()); - this.renderCustomHearts(xBasePos, yBasePos, potionOffset, absorb, true); + this.renderCustomHearts(matrixStack, xBasePos, yBasePos, potionOffset, absorb, true); } } diff --git a/src/main/java/slimeknights/mantle/client/ModelHelper.java b/src/main/java/slimeknights/mantle/client/ModelHelper.java index 9c3e387..550d5be 100644 --- a/src/main/java/slimeknights/mantle/client/ModelHelper.java +++ b/src/main/java/slimeknights/mantle/client/ModelHelper.java @@ -3,8 +3,8 @@ package slimeknights.mantle.client; import com.google.common.collect.ImmutableMap; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.TransformationMatrix; -import net.minecraft.client.renderer.Vector3f; +import net.minecraft.util.math.vector.TransformationMatrix; +import net.minecraft.util.math.vector.Vector3f; import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.model.IModelTransform; import net.minecraft.client.renderer.model.ItemCameraTransforms; diff --git a/src/main/java/slimeknights/mantle/client/book/StructureBlockAccess.java b/src/main/java/slimeknights/mantle/client/book/StructureBlockAccess.java index 65063d1..6ac0bcb 100644 --- a/src/main/java/slimeknights/mantle/client/book/StructureBlockAccess.java +++ b/src/main/java/slimeknights/mantle/client/book/StructureBlockAccess.java @@ -4,11 +4,13 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.entity.Entity; import net.minecraft.fluid.Fluids; -import net.minecraft.fluid.IFluidState; +import net.minecraft.fluid.FluidState; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; +import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.world.DimensionType; import net.minecraft.world.IWorldReader; import net.minecraft.world.LightType; import net.minecraft.world.biome.Biome; @@ -16,11 +18,12 @@ import net.minecraft.world.biome.BiomeManager; import net.minecraft.world.border.WorldBorder; import net.minecraft.world.chunk.ChunkStatus; import net.minecraft.world.chunk.IChunk; -import net.minecraft.world.dimension.Dimension; import net.minecraft.world.gen.Heightmap.Type; import net.minecraft.world.lighting.WorldLightManager; import javax.annotation.Nullable; +import java.util.function.Predicate; +import java.util.stream.Stream; public class StructureBlockAccess implements IWorldReader { @@ -38,6 +41,11 @@ public class StructureBlockAccess implements IWorldReader { return null; } + @Override + public float func_230487_a_(Direction p_230487_1_, boolean p_230487_2_) { + return 0; + } + @Override public WorldLightManager getLightManager() { return null; @@ -138,6 +146,11 @@ public class StructureBlockAccess implements IWorldReader { return false; } + @Override + public Stream func_230318_c_(@Nullable Entity p_230318_1_, AxisAlignedBB p_230318_2_, Predicate p_230318_3_) { + return null; + } + @Override public boolean isRemote() { return false; @@ -149,12 +162,12 @@ public class StructureBlockAccess implements IWorldReader { } @Override - public Dimension getDimension() { + public DimensionType func_230315_m_() { return null; } @Override - public IFluidState getFluidState(BlockPos pos) { + public FluidState getFluidState(BlockPos pos) { return Fluids.EMPTY.getDefaultState(); } } diff --git a/src/main/java/slimeknights/mantle/client/book/StructureInfo.java b/src/main/java/slimeknights/mantle/client/book/StructureInfo.java index 08e733e..1237963 100644 --- a/src/main/java/slimeknights/mantle/client/book/StructureInfo.java +++ b/src/main/java/slimeknights/mantle/client/book/StructureInfo.java @@ -7,7 +7,7 @@ import net.minecraft.block.Blocks; import java.util.Map; import java.util.Optional; -import net.minecraft.state.IProperty; +import net.minecraft.state.Property; import net.minecraft.util.ResourceLocation; import net.minecraftforge.registries.ForgeRegistries; import slimeknights.mantle.client.book.data.element.BlockData; @@ -57,7 +57,7 @@ public class StructureInfo { if (data.state != null && !data.state.isEmpty()) { for (Map.Entry entry : data.state.entrySet()) { - Optional> property = state.getProperties().stream().filter(iProperty -> entry.getKey().equals(iProperty.getName())).findFirst(); + Optional> property = state.func_235904_r_().stream().filter(iProperty -> entry.getKey().equals(iProperty.getName())).findFirst(); if (property.isPresent()) { state = this.setProperty(state, property.get(), entry.getValue()); @@ -68,7 +68,7 @@ public class StructureInfo { return state; } - private > BlockState setProperty(BlockState state, IProperty prop, String valueString) { + private > BlockState setProperty(BlockState state, Property prop, String valueString) { java.util.Optional value = prop.parseValue(valueString); if (value.isPresent()) { state = state.with(prop, value.get()); diff --git a/src/main/java/slimeknights/mantle/client/book/data/SectionDataModule.java b/src/main/java/slimeknights/mantle/client/book/data/SectionDataModule.java deleted file mode 100644 index 46611f9..0000000 --- a/src/main/java/slimeknights/mantle/client/book/data/SectionDataModule.java +++ /dev/null @@ -1,28 +0,0 @@ -package slimeknights.mantle.client.book.data; - -import slimeknights.mantle.client.book.BookLoader; -import slimeknights.mantle.client.book.repository.ModuleFileRepository; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -public class SectionDataModule extends SectionData { - - /** Module required to load this section, see {@link slimeknights.mantle.pulsar.control.PulseManager#isPulseLoaded(String)} for more details */ - public String module = ""; - - @Override - protected ArrayList getPages(String data) { - // this should always be the case, but just for safety - if (this.source instanceof ModuleFileRepository) { - // just filters out pages where the module is not loaded - Predicate manager = ((ModuleFileRepository) this.source).getManager(); - return new ArrayList<>(Arrays.stream(BookLoader.GSON.fromJson(data, PageDataModule[].class)) - .filter((page) -> page.module.isEmpty() || manager.test(page.module)) - .collect(Collectors.toList())); - } - return super.getPages(data); - } -} diff --git a/src/main/java/slimeknights/mantle/client/book/data/content/ContentSmelting.java b/src/main/java/slimeknights/mantle/client/book/data/content/ContentSmelting.java index 9bcd0c9..cbf872e 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/content/ContentSmelting.java +++ b/src/main/java/slimeknights/mantle/client/book/data/content/ContentSmelting.java @@ -10,6 +10,7 @@ import net.minecraft.item.crafting.AbstractCookingRecipe; import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.text.TranslationTextComponent; import org.apache.commons.lang3.StringUtils; import slimeknights.mantle.client.book.data.BookData; import slimeknights.mantle.client.book.data.element.ImageData; @@ -58,7 +59,7 @@ public class ContentSmelting extends PageContent { tdTitle.underlined = true; list.add(new TextElement(0, 0, BookScreen.PAGE_WIDTH, 9, tdTitle)); list.add(new ImageElement(x, y, IMG_SMELTING.width, IMG_SMELTING.height, IMG_SMELTING, book.appearance.slotColor)); - list.add(new TooltipElement(ImmutableList.of(I18n.format("mantle:tooltip.cooktime", this.cookTime / 20)), x + 7, y + 42, 60, 28)); + list.add(new TooltipElement(ImmutableList.of(new TranslationTextComponent("mantle:tooltip.cooktime", this.cookTime / 20)), x + 7, y + 42, 60, 28)); if (this.input != null && !this.input.getItems().isEmpty()) { list.add(new ItemElement(x + INPUT_X, y + INPUT_Y, ITEM_SCALE, this.input.getItems(), this.input.action)); diff --git a/src/main/java/slimeknights/mantle/client/book/data/element/ItemStackData.java b/src/main/java/slimeknights/mantle/client/book/data/element/ItemStackData.java index b7ee70d..ce42cb1 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/element/ItemStackData.java +++ b/src/main/java/slimeknights/mantle/client/book/data/element/ItemStackData.java @@ -11,7 +11,7 @@ import net.minecraft.nbt.JsonToNBT; import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.StringNBT; import net.minecraft.tags.ItemTags; -import net.minecraft.tags.Tag; +import net.minecraft.tags.ITag; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StringUtils; @@ -37,7 +37,7 @@ public class ItemStackData implements IDataElement { private transient int tagGeneration; public NonNullList getItems() { - if(this.isTag && this.tagGeneration != ItemTags.getGeneration()) { + if(this.isTag && this.tagGeneration != 0) { //ItemTags.getGeneration()) { TODO FIX this.loadTag(); } @@ -117,11 +117,11 @@ public class ItemStackData implements IDataElement { private void loadTag() { this.isTag = true; - this.tagGeneration = ItemTags.getGeneration(); + this.tagGeneration = 0;//ItemTags.getGeneration(); TODO FIX - Tag values = ItemTags.getCollection().get(new ResourceLocation(this.tag)); + ITag values = ItemTags.getCollection().get(new ResourceLocation(this.tag)); if (values != null) { - this.items = values.getAllElements().stream().map(ItemStack::new).collect(Collectors.toCollection(NonNullList::create)); + this.items = values.func_230236_b_().stream().map(ItemStack::new).collect(Collectors.toCollection(NonNullList::create)); } else { this.items = NonNullList.create(); diff --git a/src/main/java/slimeknights/mantle/client/book/data/element/TextData.java b/src/main/java/slimeknights/mantle/client/book/data/element/TextData.java index 3836ff7..4617d8c 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/element/TextData.java +++ b/src/main/java/slimeknights/mantle/client/book/data/element/TextData.java @@ -1,5 +1,6 @@ package slimeknights.mantle.client.book.data.element; +import net.minecraft.util.text.ITextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -19,7 +20,7 @@ public class TextData { public boolean dropshadow = false; public float scale = 1.F; public String action = ""; - public String[] tooltip = null; + public ITextComponent[] tooltip = null; public TextData() { } diff --git a/src/main/java/slimeknights/mantle/client/book/repository/ModuleFileRepository.java b/src/main/java/slimeknights/mantle/client/book/repository/ModuleFileRepository.java deleted file mode 100644 index 5554926..0000000 --- a/src/main/java/slimeknights/mantle/client/book/repository/ModuleFileRepository.java +++ /dev/null @@ -1,42 +0,0 @@ -package slimeknights.mantle.client.book.repository; - -import slimeknights.mantle.client.book.BookLoader; -import slimeknights.mantle.client.book.data.SectionData; -import slimeknights.mantle.client.book.data.SectionDataModule; -import slimeknights.mantle.pulsar.control.PulseManager; - -import java.util.Arrays; -import java.util.List; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -public class ModuleFileRepository extends FileRepository { - - private Predicate manager; - - public ModuleFileRepository(PulseManager manager, String location) { - super(location); - this.manager = manager::isPulseLoaded; - } - - public ModuleFileRepository(String location) { - super(location); - this.manager = PulseManager::isPulseLoadedGlobal; - } - - @Override - public List getSections() { - // same as super, except we remove any where the related module is not loaded - return Arrays.stream(BookLoader.GSON.fromJson(this.resourceToString(this.getResource(this.getResourceLocation("index.json"))), SectionDataModule[].class)) - .filter((section) -> section.module.isEmpty() || this.manager.test(section.module)) - .collect(Collectors.toList()); - } - - /** - * Gets the manager used to determine if a module is available - * @return Predicate to test a module availability - */ - public Predicate getManager() { - return this.manager; - } -} diff --git a/src/main/java/slimeknights/mantle/client/model/BakedSimple.java b/src/main/java/slimeknights/mantle/client/model/BakedSimple.java index 39ed1db..e5d07eb 100644 --- a/src/main/java/slimeknights/mantle/client/model/BakedSimple.java +++ b/src/main/java/slimeknights/mantle/client/model/BakedSimple.java @@ -4,7 +4,7 @@ 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.client.renderer.TransformationMatrix; +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; diff --git a/src/main/java/slimeknights/mantle/client/model/BakedWrapper.java b/src/main/java/slimeknights/mantle/client/model/BakedWrapper.java index e4aa2e5..98e8084 100644 --- a/src/main/java/slimeknights/mantle/client/model/BakedWrapper.java +++ b/src/main/java/slimeknights/mantle/client/model/BakedWrapper.java @@ -3,7 +3,7 @@ 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.client.renderer.TransformationMatrix; +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,7 +11,7 @@ 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.world.ILightReader; +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; @@ -90,7 +90,7 @@ public class BakedWrapper implements IBakedModel { @Nonnull @Override - public IModelData getModelData(@Nonnull ILightReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData) { + public IModelData getModelData(@Nonnull IBlockDisplayReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData) { return this.parent.getModelData(world, pos, state, tileData); } diff --git a/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java b/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java index d600e92..76c714e 100644 --- a/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java +++ b/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java @@ -1,9 +1,9 @@ package slimeknights.mantle.client.model; -import com.google.common.base.Optional; + import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.TransformationMatrix; +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,7 +11,7 @@ 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.world.ILightReader; +import net.minecraft.world.IBlockDisplayReader; import net.minecraftforge.client.model.data.EmptyModelData; import net.minecraftforge.client.model.data.IModelData; import slimeknights.mantle.client.ModelHelper; @@ -97,7 +97,7 @@ public class BlockItemModelWrapper implements IBakedModel { @Nonnull @Override - public IModelData getModelData(@Nonnull ILightReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData) { + public IModelData getModelData(@Nonnull IBlockDisplayReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData) { return this.parent.getModelData(world, pos, state, tileData); } diff --git a/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java b/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java index a07746f..058b293 100644 --- a/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java +++ b/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java @@ -2,11 +2,12 @@ package slimeknights.mantle.client.model; import com.google.common.collect.ImmutableList; import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.Matrix3f; -import net.minecraft.client.renderer.Matrix4f; -import net.minecraft.client.renderer.TransformationMatrix; -import net.minecraft.client.renderer.Vector3f; -import net.minecraft.client.renderer.Vector4f; +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; @@ -142,8 +143,8 @@ public class TRSRBakedModel implements IBakedModel { @Nonnull @Override - public IBakedModel getModelWithOverrides(@Nonnull IBakedModel originalModel, ItemStack stack, @Nonnull World world, @Nonnull LivingEntity entity) { - IBakedModel baked = this.model.original.getOverrides().getModelWithOverrides(originalModel, stack, world, entity); + public IBakedModel func_239290_a_(@Nonnull IBakedModel originalModel, ItemStack stack, @Nonnull ClientWorld world, @Nonnull LivingEntity entity) { + IBakedModel baked = this.model.original.getOverrides().func_239290_a_(originalModel, stack, world, entity); return new TRSRBakedModel(baked, this.model.transformation); } diff --git a/src/main/java/slimeknights/mantle/client/screen/ElementScreen.java b/src/main/java/slimeknights/mantle/client/screen/ElementScreen.java index ff038c1..63073c6 100644 --- a/src/main/java/slimeknights/mantle/client/screen/ElementScreen.java +++ b/src/main/java/slimeknights/mantle/client/screen/ElementScreen.java @@ -1,5 +1,6 @@ package slimeknights.mantle.client.screen; +import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.gui.screen.Screen; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -54,8 +55,8 @@ public class ElementScreen { * @param xPos X-Coordinate on the screen * @param yPos Y-Coordinate on the screen */ - public int draw(int xPos, int yPos) { - Screen.blit(xPos, yPos, this.x, this.y, this.w, this.h, this.texW, this.texH); + public int draw(MatrixStack matrixStack, int xPos, int yPos) { + Screen.func_238463_a_(matrixStack, xPos, yPos, this.x, this.y, this.w, this.h, this.texW, this.texH); return this.w; } diff --git a/src/main/java/slimeknights/mantle/client/screen/ModuleScreen.java b/src/main/java/slimeknights/mantle/client/screen/ModuleScreen.java index 65b5ba8..cf4953e 100644 --- a/src/main/java/slimeknights/mantle/client/screen/ModuleScreen.java +++ b/src/main/java/slimeknights/mantle/client/screen/ModuleScreen.java @@ -1,5 +1,6 @@ package slimeknights.mantle.client.screen; +import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.gui.screen.inventory.ContainerScreen; import net.minecraft.client.renderer.Rectangle2d; import net.minecraft.entity.player.PlayerInventory; @@ -44,9 +45,9 @@ public abstract class ModuleScreen extends ContainerScreen { } @Override - public void init() { - this.guiLeft = (this.width - this.xSize) / 2; - this.guiTop = (this.height - this.ySize) / 2; + public void func_231160_c_() { + this.guiLeft = (this.field_230708_k_ - this.xSize) / 2; + this.guiTop = (this.field_230709_l_ - this.ySize) / 2; } public void updatePosition(int parentX, int parentY, int parentSizeX, int parentSizeY) { @@ -83,12 +84,12 @@ public abstract class ModuleScreen extends ContainerScreen { return false; } - public void handleDrawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { - this.drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY); + public void handleDrawGuiContainerBackgroundLayer(MatrixStack matrixStack, float partialTicks, int mouseX, int mouseY) { + this.func_230450_a_(matrixStack,partialTicks, mouseX, mouseY); } - public void handleDrawGuiContainerForegroundLayer(int mouseX, int mouseY) { - this.drawGuiContainerForegroundLayer(mouseX, mouseY); + public void handleDrawGuiContainerForegroundLayer(MatrixStack matrixStack, int mouseX, int mouseY) { + this.func_230451_b_(matrixStack, mouseX, mouseY); } /** diff --git a/src/main/java/slimeknights/mantle/client/screen/MultiModuleScreen.java b/src/main/java/slimeknights/mantle/client/screen/MultiModuleScreen.java index 2d49ae8..af1ac2f 100644 --- a/src/main/java/slimeknights/mantle/client/screen/MultiModuleScreen.java +++ b/src/main/java/slimeknights/mantle/client/screen/MultiModuleScreen.java @@ -1,6 +1,7 @@ package slimeknights.mantle.client.screen; import com.google.common.collect.Lists; +import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.inventory.ContainerScreen; @@ -10,8 +11,8 @@ import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.Slot; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; -import slimeknights.mantle.inventory.WrapperSlot; import slimeknights.mantle.inventory.MultiModuleContainer; +import slimeknights.mantle.inventory.WrapperSlot; import javax.annotation.Nonnull; import java.util.ArrayList; @@ -31,7 +32,7 @@ public class MultiModuleScreen> extend this.realWidth = -1; this.realHeight = -1; - this.passEvents = true; + this.field_230711_n_ = true; } protected void addModule(ModuleScreen module) { @@ -47,14 +48,14 @@ public class MultiModuleScreen> extend } @Override - public void init() { + public void func_231160_c_() { if (this.realWidth > -1) { // has to be reset before calling initGui so the position is getting retained this.xSize = this.realWidth; this.ySize = this.realHeight; } - super.init(); + super.func_231160_c_(); this.cornerX = this.guiLeft; this.cornerY = this.guiTop; @@ -67,16 +68,16 @@ public class MultiModuleScreen> extend } @Override - protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { + protected void func_230450_a_(MatrixStack matrixStack, float partialTicks, int mouseX, int mouseY) { for (ModuleScreen module : this.modules) { - module.handleDrawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY); + module.handleDrawGuiContainerBackgroundLayer(matrixStack, partialTicks, mouseX, mouseY); } } @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - this.drawContainerName(); - this.drawPlayerInventoryName(); + protected void func_230451_b_(MatrixStack matrixStack, int mouseX, int mouseY) { + this.drawContainerName(matrixStack); + this.drawPlayerInventoryName(matrixStack); for (ModuleScreen module : this.modules) { // set correct state for the module @@ -84,52 +85,49 @@ public class MultiModuleScreen> extend RenderSystem.translatef(-this.guiLeft, -this.guiTop, 0.0F); RenderSystem.translatef(module.guiLeft, module.guiTop, 0.0F); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - module.handleDrawGuiContainerForegroundLayer(mouseX, mouseY); + module.handleDrawGuiContainerForegroundLayer(matrixStack, mouseX, mouseY); RenderSystem.popMatrix(); } } - protected void drawBackground(ResourceLocation background) { + protected void drawBackground(MatrixStack matrixStack, ResourceLocation background) { RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - this.minecraft.getTextureManager().bindTexture(background); - this.blit(this.cornerX, this.cornerY, 0, 0, this.realWidth, this.realHeight); + this.field_230706_i_.getTextureManager().bindTexture(background); + this.func_238474_b_(matrixStack, this.cornerX, this.cornerY, 0, 0, this.realWidth, this.realHeight); } - protected void drawContainerName() { - String localizedName = this.getTitle().getFormattedText();//multiContainer.getInventoryDisplayName(); - if (localizedName != null) { - this.font.drawString(localizedName, 8, 6, 0x404040); - } + protected void drawContainerName(MatrixStack matrixStack) { + this.field_230712_o_.func_238422_b_(matrixStack, this.func_231171_q_(), 8, 6, 0x404040); } - protected void drawPlayerInventoryName() { - String localizedName = Minecraft.getInstance().player.inventory.getDisplayName().getUnformattedComponentText(); - this.font.drawString(localizedName, 8, this.ySize - 96 + 2, 0x404040); + protected void drawPlayerInventoryName(MatrixStack matrixStack) { + ITextComponent localizedName = Minecraft.getInstance().player.inventory.getDisplayName(); + this.field_230712_o_.func_238422_b_(matrixStack, localizedName, 8, this.ySize - 96 + 2, 0x404040); } @Override - public void init(Minecraft mc, int width, int height) { - super.init(mc, width, height); + public void func_231158_b_(Minecraft mc, int width, int height) { + super.func_231158_b_(mc, width, height); for (ModuleScreen module : this.modules) { - module.init(mc, width, height); + module.func_231158_b_(mc, width, height); this.updateSubmodule(module); } } @Override - public void resize(@Nonnull Minecraft mc, int width, int height) { - super.resize(mc, width, height); + public void func_231152_a_(@Nonnull Minecraft mc, int width, int height) { + super.func_231152_a_(mc, width, height); for (ModuleScreen module : this.modules) { - module.resize(mc, width, height); + module.func_231152_a_(mc, width, height); this.updateSubmodule(module); } } @Override - public void render(int mouseX, int mouseY, float partialTicks) { - this.renderBackground(); + public void func_230430_a_(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { + this.func_230446_a_(matrixStack); int oldX = this.guiLeft; int oldY = this.guiTop; int oldW = this.xSize; @@ -139,8 +137,8 @@ public class MultiModuleScreen> extend this.guiTop = this.cornerY; this.xSize = this.realWidth; this.ySize = this.realHeight; - super.render(mouseX, mouseY, partialTicks); - this.renderHoveredToolTip(mouseX, mouseY); + super.func_230430_a_(matrixStack, mouseX, mouseY, partialTicks); + this.func_230459_a_(matrixStack, mouseX, mouseY); this.guiLeft = oldX; this.guiTop = oldY; this.xSize = oldW; @@ -178,7 +176,7 @@ public class MultiModuleScreen> extend } @Override - public void drawSlot(Slot slotIn) { + public void func_238746_a_(MatrixStack matrixStack, Slot slotIn) { ModuleScreen module = this.getModuleForSlot(slotIn.slotNumber); if (module != null) { @@ -199,7 +197,7 @@ public class MultiModuleScreen> extend slotIn.yPos = ((WrapperSlot) slotIn).parent.yPos; } - super.drawSlot(slotIn); + super.func_238746_a_(matrixStack, slotIn); } @Override @@ -223,7 +221,7 @@ public class MultiModuleScreen> extend } @Override - public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) { + public boolean func_231044_a_(double mouseX, double mouseY, int mouseButton) { ModuleScreen module = this.getModuleForPoint(mouseX, mouseY); if (module != null) { @@ -232,11 +230,11 @@ public class MultiModuleScreen> extend } } - return super.mouseClicked(mouseX, mouseY, mouseButton); + return super.func_231044_a_(mouseX, mouseY, mouseButton); } @Override - public boolean mouseDragged(double mouseX, double mouseY, int clickedMouseButton, double timeSinceLastClick, double unkowwn) { + public boolean func_231045_a_(double mouseX, double mouseY, int clickedMouseButton, double timeSinceLastClick, double unkowwn) { ModuleScreen module = this.getModuleForPoint(mouseX, mouseY); if (module != null) { @@ -245,11 +243,11 @@ public class MultiModuleScreen> extend } } - return super.mouseDragged(mouseX, mouseY, clickedMouseButton, timeSinceLastClick, unkowwn); + return super.func_231045_a_(mouseX, mouseY, clickedMouseButton, timeSinceLastClick, unkowwn); } @Override - public boolean mouseScrolled(double mouseX, double mouseY, double delta) { + public boolean func_231043_a_(double mouseX, double mouseY, double delta) { ModuleScreen module = this.getModuleForPoint(mouseX, mouseY); if (module != null) { @@ -258,11 +256,11 @@ public class MultiModuleScreen> extend } } - return super.mouseScrolled(mouseX, mouseY, delta); + return super.func_231043_a_(mouseX, mouseY, delta); } @Override - public boolean mouseReleased(double mouseX, double mouseY, int state) { + public boolean func_231048_c_(double mouseX, double mouseY, int state) { ModuleScreen module = this.getModuleForPoint(mouseX, mouseY); if (module != null) { @@ -271,7 +269,7 @@ public class MultiModuleScreen> extend } } - return super.mouseReleased(mouseX, mouseY, state); + return super.func_231048_c_(mouseX, mouseY, state); } protected ModuleScreen getModuleForPoint(double x, double y) { diff --git a/src/main/java/slimeknights/mantle/client/screen/ScalableElementScreen.java b/src/main/java/slimeknights/mantle/client/screen/ScalableElementScreen.java index eddc072..7e4e79a 100644 --- a/src/main/java/slimeknights/mantle/client/screen/ScalableElementScreen.java +++ b/src/main/java/slimeknights/mantle/client/screen/ScalableElementScreen.java @@ -1,5 +1,6 @@ package slimeknights.mantle.client.screen; +import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.gui.screen.Screen; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -15,37 +16,37 @@ public class ScalableElementScreen extends ElementScreen { super(x, y, w, h); } - public int drawScaledX(int xPos, int yPos, int width) { + public int drawScaledX(MatrixStack matrixStack, int xPos, int yPos, int width) { for (int i = 0; i < width / this.w; i++) { - this.draw(xPos + i * this.w, yPos); + this.draw(matrixStack, xPos + i * this.w, yPos); } // remainder that doesn't fit total width int remainder = width % this.w; if (remainder > 0) { - Screen.blit(xPos + width - remainder, yPos, this.x, this.y, remainder, this.h, this.texW, this.texH); + Screen.func_238463_a_(matrixStack, xPos + width - remainder, yPos, this.x, this.y, remainder, this.h, this.texW, this.texH); } return width; } - public int drawScaledY(int xPos, int yPos, int height) { + public int drawScaledY(MatrixStack matrixStack, int xPos, int yPos, int height) { for (int i = 0; i < height / this.h; i++) { - this.draw(xPos, yPos + i * this.h); + this.draw(matrixStack, xPos, yPos + i * this.h); } // remainder that doesn't fit total width int remainder = height % this.h; if (remainder > 0) { - Screen.blit(xPos, yPos + height - remainder, this.x, this.y, this.w, remainder, this.texW, this.texH); + Screen.func_238463_a_(matrixStack, xPos, yPos + height - remainder, this.x, this.y, this.w, remainder, this.texW, this.texH); } return this.w; } - public int drawScaled(int xPos, int yPos, int width, int height) { + public int drawScaled(MatrixStack matrixStack, int xPos, int yPos, int width, int height) { // we draw full height row-wise int full = height / this.h; for (int i = 0; i < full; i++) { - this.drawScaledX(xPos, yPos + i * this.h, width); + this.drawScaledX(matrixStack, xPos, yPos + i * this.h, width); } yPos += full * this.h; @@ -54,12 +55,14 @@ public class ScalableElementScreen extends ElementScreen { int yRest = height % this.h; // the same as drawScaledX but with the remaining height for (int i = 0; i < width / this.w; i++) { - this.drawScaledY(xPos + i * this.w, yPos, yRest); + this.drawScaledY(matrixStack, xPos + i * this.w, yPos, yRest); } + // remainder that doesn't fit total width int remainder = width % this.w; + if (remainder > 0) { - Screen.blit(xPos + width - remainder, yPos, this.x, this.y, remainder, yRest, this.texW, this.texH); + Screen.func_238463_a_(matrixStack, xPos + width - remainder, yPos, this.x, this.y, remainder, yRest, this.texW, this.texH); } return width; diff --git a/src/main/java/slimeknights/mantle/client/screen/SliderWidget.java b/src/main/java/slimeknights/mantle/client/screen/SliderWidget.java index 03d1534..33cb89f 100644 --- a/src/main/java/slimeknights/mantle/client/screen/SliderWidget.java +++ b/src/main/java/slimeknights/mantle/client/screen/SliderWidget.java @@ -1,5 +1,6 @@ package slimeknights.mantle.client.screen; +import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.util.math.MathHelper; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -118,15 +119,15 @@ public class SliderWidget extends Widget { } @Override - public void draw() { + public void draw(MatrixStack matrixStack) { if (this.hidden) { return; } // slide bar background - this.slideBarTop.draw(this.xPos, this.yPos); - this.slideBar.drawScaledY(this.xPos, this.yPos + this.slideBarTop.h, this.getUsableSlidebarHeight()); - this.slideBarBottom.draw(this.xPos, this.yPos + this.height - this.slideBarBottom.h); + this.slideBarTop.draw(matrixStack, this.xPos, this.yPos); + this.slideBar.drawScaledY(matrixStack, this.xPos, this.yPos + this.slideBarTop.h, this.getUsableSlidebarHeight()); + this.slideBarBottom.draw(matrixStack, this.xPos, this.yPos + this.height - this.slideBarBottom.h); int x = this.xPos + this.sliderOffset; int y = this.yPos + this.getSliderTop(); @@ -134,14 +135,14 @@ public class SliderWidget extends Widget { // the slider depending on state if (this.enabled) { if (this.isScrolling) { - this.sliderDisabled.draw(x, y); + this.sliderDisabled.draw(matrixStack, x, y); } else if (this.isHighlighted) { - this.sliderHighlighted.draw(x, y); + this.sliderHighlighted.draw(matrixStack, x, y); } else { - this.slider.draw(x, y); + this.slider.draw(matrixStack, x, y); } } else { - this.sliderDisabled.draw(x, y); + this.sliderDisabled.draw(matrixStack, x, y); } } diff --git a/src/main/java/slimeknights/mantle/client/screen/TabsWidget.java b/src/main/java/slimeknights/mantle/client/screen/TabsWidget.java index af8dfeb..af738c6 100644 --- a/src/main/java/slimeknights/mantle/client/screen/TabsWidget.java +++ b/src/main/java/slimeknights/mantle/client/screen/TabsWidget.java @@ -1,6 +1,7 @@ package slimeknights.mantle.client.screen; import com.google.common.collect.Lists; +import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; @@ -117,7 +118,7 @@ public class TabsWidget extends Widget { } @Override - public void draw() { + public void draw(MatrixStack matrixStack) { int y = this.yPos + this.yOffset; for (int i = 0; i < this.icons.size(); i++) { int x = this.xPos + i * this.tab[0].w; @@ -136,7 +137,7 @@ public class TabsWidget extends Widget { ElementScreen actualTab; if (i == 0 && x == this.parent.cornerX) { actualTab = toDraw[0]; - } else if (x == this.parent.cornerX + this.parent.width) { + } else if (x == this.parent.cornerX + this.parent.field_230708_k_) { actualTab = toDraw[2]; } else { actualTab = toDraw[1]; @@ -146,7 +147,7 @@ public class TabsWidget extends Widget { // rebind texture from drawing an itemstack Minecraft.getInstance().getTextureManager().bindTexture(this.tabsResource); - actualTab.draw(x, y); + actualTab.draw(matrixStack,x, y); ItemStack icon = this.icons.get(i); if (icon != null) { diff --git a/src/main/java/slimeknights/mantle/client/screen/Widget.java b/src/main/java/slimeknights/mantle/client/screen/Widget.java index 3d4e1f7..f85ab5b 100644 --- a/src/main/java/slimeknights/mantle/client/screen/Widget.java +++ b/src/main/java/slimeknights/mantle/client/screen/Widget.java @@ -1,5 +1,6 @@ package slimeknights.mantle.client.screen; +import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -11,7 +12,7 @@ public abstract class Widget { public int height; public int width; - public abstract void draw(); + public abstract void draw(MatrixStack matrixStack); /** * Where the part will be drawn. Upper left corner. diff --git a/src/main/java/slimeknights/mantle/client/screen/book/ArrowButton.java b/src/main/java/slimeknights/mantle/client/screen/book/ArrowButton.java index e464170..06c2a55 100644 --- a/src/main/java/slimeknights/mantle/client/screen/book/ArrowButton.java +++ b/src/main/java/slimeknights/mantle/client/screen/book/ArrowButton.java @@ -1,8 +1,10 @@ package slimeknights.mantle.client.screen.book; +import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.widget.button.Button; +import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -20,7 +22,7 @@ public class ArrowButton extends Button { public int hoverColor; public ArrowButton(int x, int y, ArrowType arrowType, int color, int hoverColor, IPressable iPressable) { - super(x, y, arrowType.w, arrowType.h, "", iPressable); + super(x, y, arrowType.w, arrowType.h, StringTextComponent.field_240750_d_, iPressable); this.arrowType = arrowType; this.color = color; @@ -28,21 +30,21 @@ public class ArrowButton extends Button { } @Override - public void renderButton(int mouseX, int mouseY, float partialTicks) { + public void func_230431_b_(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { Minecraft minecraft = Minecraft.getInstance(); minecraft.getTextureManager().bindTexture(TEX_BOOK); - this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height; + this.field_230692_n_ = mouseX >= this.field_230690_l_ && mouseY >= this.field_230691_m_ && mouseX < this.field_230690_l_ + this.field_230688_j_ && mouseY < this.field_230691_m_ + this.field_230689_k_; - int color = this.isHovered ? this.hoverColor : this.color; + int color = this.field_230692_n_ ? this.hoverColor : this.color; float r = ((color >> 16) & 0xff) / 255.F; float g = ((color >> 8) & 0xff) / 255.F; float b = (color & 0xff) / 255.F; RenderSystem.color3f(r, g, b); - blit(this.x, this.y, this.width, this.height, this.arrowType.x, this.arrowType.y, this.width, this.height, 512, 512); - this.renderBg(minecraft, mouseX, mouseY); + func_238466_a_(matrixStack, this.field_230690_l_, this.field_230691_m_, this.field_230688_j_, this.field_230689_k_, this.arrowType.x, this.arrowType.y, this.field_230688_j_, this.field_230689_k_, 512, 512); + this.func_230441_a_(matrixStack, minecraft, mouseX, mouseY); } public enum ArrowType { diff --git a/src/main/java/slimeknights/mantle/client/screen/book/BookScreen.java b/src/main/java/slimeknights/mantle/client/screen/book/BookScreen.java index 1abd9c3..98e2afa 100644 --- a/src/main/java/slimeknights/mantle/client/screen/book/BookScreen.java +++ b/src/main/java/slimeknights/mantle/client/screen/book/BookScreen.java @@ -1,6 +1,7 @@ package slimeknights.mantle.client.screen.book; import com.google.common.collect.ImmutableList; +import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.advancements.Advancement; import net.minecraft.advancements.AdvancementProgress; @@ -81,61 +82,35 @@ public class BookScreen extends Screen { this.book = book; this.item = item; - this.minecraft = Minecraft.getInstance(); - this.font = this.minecraft.fontRenderer; + this.field_230706_i_ = Minecraft.getInstance(); + this.field_230712_o_ = this.field_230706_i_.fontRenderer; initWidthsAndHeights(); this.advancementCache = new AdvancementCache(); - this.minecraft.player.connection.getAdvancementManager().setListener(this.advancementCache); + this.field_230706_i_.player.connection.getAdvancementManager().setListener(this.advancementCache); this.openPage(book.findPageNumber(BookHelper.getSavedPage(item), this.advancementCache)); } @Override @SuppressWarnings("ForLoopReplaceableByForEach") - public void render(int mouseX, int mouseY, float partialTicks) { + public void func_230430_a_(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { initWidthsAndHeights(); FontRenderer fontRenderer = this.book.fontRenderer; if (fontRenderer == null) { - fontRenderer = this.minecraft.fontRenderer; + fontRenderer = this.field_230706_i_.fontRenderer; } if (debug) { - fill(0, 0, fontRenderer.getStringWidth("DEBUG") + 4, fontRenderer.FONT_HEIGHT + 4, 0x55000000); - fontRenderer.drawString("DEBUG", 2, 2, 0xFFFFFFFF); + func_238467_a_(matrixStack, 0, 0, fontRenderer.getStringWidth("DEBUG") + 4, fontRenderer.FONT_HEIGHT + 4, 0x55000000); + fontRenderer.func_238421_b_(matrixStack, "DEBUG", 2, 2, 0xFFFFFFFF); } RenderSystem.enableAlphaTest(); RenderSystem.enableBlend(); // The books are unreadable at Gui Scale set to small, so we'll double the scale - /* - if(mc.gameSettings.guiScale == 1) { - float f = 1.5f; - RenderSystem.scale(f, f, 1); - - float ox = this.width/6; - float oy = this.height/6; - - mouseX = (int)((float)mouseX / f); - mouseY = (int)((float)mouseY / f); - - RenderSystem.translate(ox, oy, 0); - } - else if(mc.gameSettings.guiScale == 2) { - float f = 3f/2f; - RenderSystem.scale(f, f, 1); - - float ox = -this.width/6; - float oy = -this.height/6; - - mouseX = (int)(((float)mouseX - ox)/f); - mouseY = (int)(((float)mouseY - oy)/f); - - RenderSystem.translate(ox, oy, 0); - } -*/ RenderSystem.pushMatrix(); RenderSystem.color3f(1F, 1F, 1F); @@ -143,32 +118,32 @@ public class BookScreen extends Screen { float coverG = ((this.book.appearance.coverColor >> 8) & 0xff) / 255.F; float coverB = (this.book.appearance.coverColor & 0xff) / 255.F; - TextureManager render = this.minecraft.textureManager; + TextureManager render = this.field_230706_i_.textureManager; if (this.page == -1) { render.bindTexture(TEX_BOOKFRONT); RenderHelper.disableStandardItemLighting(); RenderSystem.color3f(coverR, coverG, coverB); - blit(this.width / 2 - PAGE_WIDTH_UNSCALED / 2, this.height / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, 0, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE); + func_238463_a_(matrixStack, this.field_230708_k_ / 2 - PAGE_WIDTH_UNSCALED / 2, this.field_230709_l_ / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, 0, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE); RenderSystem.color3f(1F, 1F, 1F); if (!this.book.appearance.title.isEmpty()) { - blit(this.width / 2 - PAGE_WIDTH_UNSCALED / 2, this.height / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, PAGE_HEIGHT_UNSCALED, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE); + func_238463_a_(matrixStack, this.field_230708_k_ / 2 - PAGE_WIDTH_UNSCALED / 2, this.field_230709_l_ / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, PAGE_HEIGHT_UNSCALED, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE); RenderSystem.pushMatrix(); float scale = fontRenderer.getStringWidth(this.book.appearance.title) <= 67 ? 2.5F : 2F; RenderSystem.scalef(scale, scale, 1F); - fontRenderer.drawStringWithShadow(this.book.appearance.title, (this.width / 2) / scale + 3 - fontRenderer.getStringWidth(this.book.appearance.title) / 2, (this.height / 2 - fontRenderer.FONT_HEIGHT / 2) / scale - 4, 0xAE8000); + fontRenderer.func_238405_a_(matrixStack, this.book.appearance.title, (this.field_230708_k_ / 2) / scale + 3 - fontRenderer.getStringWidth(this.book.appearance.title) / 2, (this.field_230709_l_ / 2 - fontRenderer.FONT_HEIGHT / 2) / scale - 4, 0xAE8000); RenderSystem.popMatrix(); } if (!this.book.appearance.subtitle.isEmpty()) { RenderSystem.pushMatrix(); RenderSystem.scalef(1.5F, 1.5F, 1F); - fontRenderer.drawStringWithShadow(this.book.appearance.subtitle, (this.width / 2) / 1.5F + 7 - fontRenderer.getStringWidth(this.book.appearance.subtitle) / 2, (this.height / 2 + 100 - fontRenderer.FONT_HEIGHT * 2) / 1.5F, 0xAE8000); + fontRenderer.func_238405_a_(matrixStack, this.book.appearance.subtitle, (this.field_230708_k_ / 2) / 1.5F + 7 - fontRenderer.getStringWidth(this.book.appearance.subtitle) / 2, (this.field_230709_l_ / 2 + 100 - fontRenderer.FONT_HEIGHT * 2) / 1.5F, 0xAE8000); RenderSystem.popMatrix(); } } @@ -177,12 +152,12 @@ public class BookScreen extends Screen { RenderHelper.disableStandardItemLighting(); RenderSystem.color3f(coverR, coverG, coverB); - blit(this.width / 2 - PAGE_WIDTH_UNSCALED, this.height / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, 0, PAGE_WIDTH_UNSCALED * 2, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE); + func_238463_a_(matrixStack, this.field_230708_k_ / 2 - PAGE_WIDTH_UNSCALED, this.field_230709_l_ / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, 0, PAGE_WIDTH_UNSCALED * 2, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE); RenderSystem.color3f(1F, 1F, 1F); if (this.page != 0) { - blit(this.width / 2 - PAGE_WIDTH_UNSCALED, this.height / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, PAGE_HEIGHT_UNSCALED, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE); + func_238463_a_(matrixStack, this.field_230708_k_ / 2 - PAGE_WIDTH_UNSCALED, this.field_230709_l_ / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, PAGE_HEIGHT_UNSCALED, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE); RenderSystem.pushMatrix(); this.drawerTransform(false); @@ -191,7 +166,7 @@ public class BookScreen extends Screen { if (this.book.appearance.drawPageNumbers) { String pNum = (this.page - 1) * 2 + 2 + ""; - fontRenderer.drawString(pNum, PAGE_WIDTH / 2 - fontRenderer.getStringWidth(pNum) / 2, PAGE_HEIGHT - 10, 0xFFAAAAAA); + fontRenderer.func_238421_b_(matrixStack, pNum, PAGE_WIDTH / 2 - fontRenderer.getStringWidth(pNum) / 2, PAGE_HEIGHT - 10, 0xFFAAAAAA); } int mX = this.getMouseX(false); @@ -202,7 +177,7 @@ public class BookScreen extends Screen { BookElement element = this.leftElements.get(i); RenderSystem.color4f(1F, 1F, 1F, 1F); - element.draw(mX, mY, partialTicks, fontRenderer); + element.draw(matrixStack, mX, mY, partialTicks, fontRenderer); } // Not foreach to prevent conmodification crashes @@ -210,7 +185,7 @@ public class BookScreen extends Screen { BookElement element = this.leftElements.get(i); RenderSystem.color4f(1F, 1F, 1F, 1F); - element.drawOverlay(mX, mY, partialTicks, fontRenderer); + element.drawOverlay(matrixStack, mX, mY, partialTicks, fontRenderer); } RenderSystem.popMatrix(); @@ -224,7 +199,7 @@ public class BookScreen extends Screen { int fullPageCount = this.book.getFullPageCount(this.advancementCache); if (this.page < fullPageCount - 1 || this.book.getPageCount(this.advancementCache) % 2 != 0) { - blit(this.width / 2, this.height / 2 - PAGE_HEIGHT_UNSCALED / 2, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE); + func_238463_a_(matrixStack, this.field_230708_k_ / 2, this.field_230709_l_ / 2 - PAGE_HEIGHT_UNSCALED / 2, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE); RenderSystem.pushMatrix(); this.drawerTransform(true); @@ -233,7 +208,7 @@ public class BookScreen extends Screen { if (this.book.appearance.drawPageNumbers) { String pNum = (this.page - 1) * 2 + 3 + ""; - fontRenderer.drawString(pNum, PAGE_WIDTH / 2 - fontRenderer.getStringWidth(pNum) / 2, PAGE_HEIGHT - 10, 0xFFAAAAAA); + fontRenderer.func_238421_b_(matrixStack, pNum, PAGE_WIDTH / 2 - fontRenderer.getStringWidth(pNum) / 2, PAGE_HEIGHT - 10, 0xFFAAAAAA); } int mX = this.getMouseX(true); @@ -244,7 +219,7 @@ public class BookScreen extends Screen { BookElement element = this.rightElements.get(i); RenderSystem.color4f(1F, 1F, 1F, 1F); - element.draw(mX, mY, partialTicks, fontRenderer); + element.draw(matrixStack, mX, mY, partialTicks, fontRenderer); } // Not foreach to prevent conmodification crashes @@ -252,21 +227,21 @@ public class BookScreen extends Screen { BookElement element = this.rightElements.get(i); RenderSystem.color4f(1F, 1F, 1F, 1F); - element.drawOverlay(mX, mY, partialTicks, fontRenderer); + element.drawOverlay(matrixStack, mX, mY, partialTicks, fontRenderer); } RenderSystem.popMatrix(); } } - super.render(mouseX, mouseY, partialTicks); + super.func_230430_a_(matrixStack, mouseX, mouseY, partialTicks); RenderSystem.popMatrix(); } @Override - protected void init() { - super.init(); + protected void func_231160_c_() { + super.func_231160_c_(); // The books are unreadable at Gui Scale set to small, so we'll double the scale, and of course half the size so that all our code still works as it should /* @@ -275,10 +250,10 @@ public class BookScreen extends Screen { height /= 2F; }*/ - this.buttons.clear(); - this.children.clear(); + this.field_230710_m_.clear(); + this.field_230705_e_.clear(); - this.previousArrow = this.addButton(new ArrowButton(-50, -50, ArrowButton.ArrowType.PREV, this.book.appearance.arrowColor, this.book.appearance.arrowColorHover, (p_212998_1_) -> { + this.previousArrow = this.func_230480_a_(new ArrowButton(-50, -50, ArrowButton.ArrowType.PREV, this.book.appearance.arrowColor, this.book.appearance.arrowColorHover, (p_212998_1_) -> { this.page--; if (this.page < -1) { @@ -289,7 +264,7 @@ public class BookScreen extends Screen { this.buildPages(); })); - this.nextArrow = this.addButton(new ArrowButton(-50, -50, ArrowButton.ArrowType.NEXT, this.book.appearance.arrowColor, this.book.appearance.arrowColorHover, (p_212998_1_) -> { + this.nextArrow = this.func_230480_a_(new ArrowButton(-50, -50, ArrowButton.ArrowType.NEXT, this.book.appearance.arrowColor, this.book.appearance.arrowColorHover, (p_212998_1_) -> { this.page++; int fullPageCount = this.book.getFullPageCount(this.advancementCache); @@ -302,7 +277,7 @@ public class BookScreen extends Screen { this.buildPages(); })); - this.backArrow = this.addButton(new ArrowButton(this.width / 2 - ArrowButton.WIDTH / 2, this.height / 2 + ArrowButton.HEIGHT / 2 + PAGE_HEIGHT / 2, ArrowButton.ArrowType.LEFT, this.book.appearance.arrowColor, this.book.appearance.arrowColorHover, (p_212998_1_) -> { + this.backArrow = this.func_230480_a_(new ArrowButton(this.field_230708_k_ / 2 - ArrowButton.WIDTH / 2, this.field_230709_l_ / 2 + ArrowButton.HEIGHT / 2 + PAGE_HEIGHT / 2, ArrowButton.ArrowType.LEFT, this.book.appearance.arrowColor, this.book.appearance.arrowColorHover, (p_212998_1_) -> { if (this.oldPage >= -1) { this.page = this.oldPage; } @@ -311,7 +286,7 @@ public class BookScreen extends Screen { this.buildPages(); })); - this.indexArrow = this.addButton(new ArrowButton(this.width / 2 - PAGE_WIDTH_UNSCALED - ArrowButton.WIDTH / 2, this.height / 2 - PAGE_HEIGHT_UNSCALED / 2, ArrowButton.ArrowType.BACK_UP, this.book.appearance.arrowColor, this.book.appearance.arrowColorHover, (p_212998_1_) -> { + this.indexArrow = this.func_230480_a_(new ArrowButton(this.field_230708_k_ / 2 - PAGE_WIDTH_UNSCALED - ArrowButton.WIDTH / 2, this.field_230709_l_ / 2 - PAGE_HEIGHT_UNSCALED / 2, ArrowButton.ArrowType.BACK_UP, this.book.appearance.arrowColor, this.book.appearance.arrowColorHover, (p_212998_1_) -> { this.openPage(this.book.findPageNumber("index.page1")); this.oldPage = -2; @@ -322,26 +297,26 @@ public class BookScreen extends Screen { } @Override - public void tick() { - super.tick(); + public void func_231023_e_() { + super.func_231023_e_(); - this.previousArrow.visible = this.page != -1; - this.nextArrow.visible = this.page + 1 < this.book.getFullPageCount(this.advancementCache); - this.backArrow.visible = this.oldPage >= -1; + this.previousArrow.field_230694_p_ = this.page != -1; + this.nextArrow.field_230694_p_ = this.page + 1 < this.book.getFullPageCount(this.advancementCache); + this.backArrow.field_230694_p_ = this.oldPage >= -1; if (this.page == -1) { - this.nextArrow.x = this.width / 2 + 80; - this.indexArrow.visible = false; + this.nextArrow.field_230690_l_ = this.field_230708_k_ / 2 + 80; + this.indexArrow.field_230694_p_ = false; } else { - this.previousArrow.x = this.width / 2 - 184; - this.nextArrow.x = this.width / 2 + 165; + this.previousArrow.field_230690_l_ = this.field_230708_k_ / 2 - 184; + this.nextArrow.field_230690_l_ = this.field_230708_k_ / 2 + 165; - this.indexArrow.visible = this.book.findSection("index") != null && (this.page - 1) * 2 + 2 > this.book.findSection("index").getPageCount(); + this.indexArrow.field_230694_p_ = this.book.findSection("index") != null && (this.page - 1) * 2 + 2 > this.book.findSection("index").getPageCount(); } - this.previousArrow.y = this.height / 2 + 75; - this.nextArrow.y = this.height / 2 + 75; + this.previousArrow.field_230691_m_ = this.field_230709_l_ / 2 + 75; + this.nextArrow.field_230691_m_ = this.field_230709_l_ / 2 + 75; } /*@Override @@ -355,8 +330,8 @@ public class BookScreen extends Screen { }*/ @Override - public boolean keyPressed(int keyCode, int scanCode, int modifiers) { - super.keyPressed(keyCode, scanCode, modifiers); + public boolean func_231046_a_(int keyCode, int scanCode, int modifiers) { + super.func_231046_a_(keyCode, scanCode, modifiers); switch (keyCode) { case GLFW.GLFW_KEY_LEFT: @@ -384,11 +359,11 @@ public class BookScreen extends Screen { return true; } - return super.keyPressed(keyCode, scanCode, modifiers); + return super.func_231046_a_(keyCode, scanCode, modifiers); } @Override - public boolean mouseScrolled(double unKnown1, double unKnown2, double scrollDelta) { + public boolean func_231043_a_(double unKnown1, double unKnown2, double scrollDelta) { if (scrollDelta < 0.0D) { this.page++; @@ -413,11 +388,11 @@ public class BookScreen extends Screen { return true; } - return super.mouseScrolled(scrollDelta, unKnown1, unKnown2); + return super.func_231043_a_(scrollDelta, unKnown1, unKnown2); } @Override - public boolean mouseClicked(double originalMouseX, double originalMouseY, int mouseButton) { + public boolean func_231044_a_(double originalMouseX, double originalMouseY, int mouseButton) { boolean right = false; double mouseX = this.getMouseX(false); @@ -439,11 +414,11 @@ public class BookScreen extends Screen { } } - return super.mouseClicked(originalMouseX, originalMouseY, mouseButton); + return super.func_231044_a_(originalMouseX, originalMouseY, mouseButton); } @Override - public boolean mouseReleased(double originalMouseX, double originalMouseY, int mouseButton) { + public boolean func_231048_c_(double originalMouseX, double originalMouseY, int mouseButton) { boolean right = false; double mouseX = this.getMouseX(false); double mouseY = this.getMouseY(); @@ -458,11 +433,11 @@ public class BookScreen extends Screen { BookElement element = right ? this.rightElements.get(i) : this.leftElements.get(i); element.mouseReleased(mouseX, mouseY, mouseButton); } - return super.mouseReleased(originalMouseX, originalMouseY, mouseButton); + return super.func_231048_c_(originalMouseX, originalMouseY, mouseButton); } @Override - public boolean mouseDragged(double mouseX, double mouseY, int clickedMouseButton, double timeSinceLaslick, double unknown) { + public boolean func_231045_a_(double mouseX, double mouseY, int clickedMouseButton, double timeSinceLaslick, double unknown) { boolean right = false; mouseX = this.getMouseX(false); mouseY = this.getMouseY(); @@ -482,8 +457,8 @@ public class BookScreen extends Screen { } @Override - public void removed() { - if (this.minecraft.player == null) { + public void func_231164_f_() { + if (this.field_230706_i_.player == null) { return; } @@ -494,24 +469,24 @@ public class BookScreen extends Screen { } if (this.page == -1) { - BookLoader.updateSavedPage(this.minecraft.player, this.item, ""); + BookLoader.updateSavedPage(this.field_230706_i_.player, this.item, ""); } else if (page != null && page.parent != null) { - BookLoader.updateSavedPage(this.minecraft.player, this.item, page.parent.name + "." + page.name); + BookLoader.updateSavedPage(this.field_230706_i_.player, this.item, page.parent.name + "." + page.name); } } @Override - public boolean isPauseScreen() { + public boolean func_231177_au__() { return false; } public void drawerTransform(boolean rightSide) { if (rightSide) { - RenderSystem.translatef(this.width / 2 + PAGE_PADDING_RIGHT + PAGE_MARGIN, this.height / 2 - PAGE_HEIGHT_UNSCALED / 2 + PAGE_PADDING_TOP + PAGE_MARGIN, 0); + RenderSystem.translatef(this.field_230708_k_ / 2 + PAGE_PADDING_RIGHT + PAGE_MARGIN, this.field_230709_l_ / 2 - PAGE_HEIGHT_UNSCALED / 2 + PAGE_PADDING_TOP + PAGE_MARGIN, 0); } else { - RenderSystem.translatef(this.width / 2 - PAGE_WIDTH_UNSCALED + PAGE_PADDING_LEFT + PAGE_MARGIN, this.height / 2 - PAGE_HEIGHT_UNSCALED / 2 + PAGE_PADDING_TOP + PAGE_MARGIN, 0); + RenderSystem.translatef(this.field_230708_k_ / 2 - PAGE_WIDTH_UNSCALED + PAGE_PADDING_LEFT + PAGE_MARGIN, this.field_230709_l_ / 2 - PAGE_HEIGHT_UNSCALED / 2 + PAGE_PADDING_TOP + PAGE_MARGIN, 0); } } @@ -519,24 +494,24 @@ public class BookScreen extends Screen { protected float leftOffset(boolean rightSide) { if (rightSide) { // from center: go padding + margin to the right - return this.width / 2 + PAGE_PADDING_RIGHT + PAGE_MARGIN; + return this.field_230708_k_ / 2 + PAGE_PADDING_RIGHT + PAGE_MARGIN; } else { // from center: go page width left, then right with padding and margin - return this.width / 2 - PAGE_WIDTH_UNSCALED + PAGE_PADDING_LEFT + PAGE_MARGIN; + return this.field_230708_k_ / 2 - PAGE_WIDTH_UNSCALED + PAGE_PADDING_LEFT + PAGE_MARGIN; } } protected float topOffset() { - return this.height / 2 - PAGE_HEIGHT_UNSCALED / 2 + PAGE_PADDING_TOP + PAGE_MARGIN; + return this.field_230709_l_ / 2 - PAGE_HEIGHT_UNSCALED / 2 + PAGE_PADDING_TOP + PAGE_MARGIN; } protected int getMouseX(boolean rightSide) { - return (int) ((Minecraft.getInstance().mouseHelper.getMouseX() * this.width / this.minecraft.getMainWindow().getFramebufferWidth() - this.leftOffset(rightSide)) / PAGE_SCALE); + return (int) ((Minecraft.getInstance().mouseHelper.getMouseX() * this.field_230708_k_ / this.field_230706_i_.getMainWindow().getFramebufferWidth() - this.leftOffset(rightSide)) / PAGE_SCALE); } protected int getMouseY() { - return (int) ((Minecraft.getInstance().mouseHelper.getMouseY() * this.height / this.minecraft.getMainWindow().getFramebufferHeight() - 1 - this.topOffset()) / PAGE_SCALE); + return (int) ((Minecraft.getInstance().mouseHelper.getMouseY() * this.field_230709_l_ / this.field_230706_i_.getMainWindow().getFramebufferHeight() - 1 - this.topOffset()) / PAGE_SCALE); } public int openPage(int page) { diff --git a/src/main/java/slimeknights/mantle/client/screen/book/BookmarkButton.java b/src/main/java/slimeknights/mantle/client/screen/book/BookmarkButton.java index 7b24b3a..833abab 100644 --- a/src/main/java/slimeknights/mantle/client/screen/book/BookmarkButton.java +++ b/src/main/java/slimeknights/mantle/client/screen/book/BookmarkButton.java @@ -1,9 +1,11 @@ package slimeknights.mantle.client.screen.book; +import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.widget.button.Button; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import slimeknights.mantle.client.book.data.BookmarkData; @@ -25,13 +27,13 @@ public class BookmarkButton extends Button { public final BookmarkData data; public BookmarkButton(BookmarkData data, IPressable iPressable) { - super(-500, -500, WIDTH, HEIGHT, "", iPressable); + super(-500, -500, WIDTH, HEIGHT, StringTextComponent.field_240750_d_, iPressable); this.data = data; } @Override - public void renderButton(int mouseX, int mouseY, float partialTicks) { + public void func_230431_b_(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { Minecraft minecraft = Minecraft.getInstance(); int tex_y = TEX_Y + HEIGHT * this.type; @@ -42,16 +44,16 @@ public class BookmarkButton extends Button { float b = (this.data.color & 0xff) / 255.F; RenderSystem.color3f(r, g, b); - blit(this.x, this.y, this.width, this.height, TEX_X, tex_y, WIDTH, HEIGHT, 512, 512); + func_238466_a_(matrixStack, this.field_230690_l_, this.field_230691_m_, this.field_230688_j_, this.field_230691_m_, TEX_X, tex_y, WIDTH, HEIGHT, 512, 512); if (this.data.text != null && !this.data.text.isEmpty()) { - TextDataRenderer.drawScaledString(minecraft.fontRenderer, this.data.text, this.x + 1, this.y + this.height / 2 - minecraft.fontRenderer.FONT_HEIGHT * TEXT_SCALE / 2 + 1, 0xFFFFFFFF, true, TEXT_SCALE); + TextDataRenderer.drawScaledString(matrixStack, minecraft.fontRenderer, this.data.text, this.field_230690_l_ + 1, this.field_230691_m_ + this.field_230691_m_ / 2 - minecraft.fontRenderer.FONT_HEIGHT * TEXT_SCALE / 2 + 1, 0xFFFFFFFF, true, TEXT_SCALE); } RenderSystem.color3f(1F, 1F, 1F); if (this.data.page.equals("ADD")) { - blit(this.x + this.width / 2 - ADD_W / 2, this.y + this.height / 2 - ADD_H / 2, ADD_X, ADD_Y, ADD_W, ADD_H, 512, 512); + func_238463_a_(matrixStack, this.field_230690_l_ + this.field_230688_j_ / 2 - ADD_W / 2, this.field_230691_m_ + this.field_230691_m_ / 2 - ADD_H / 2, ADD_X, ADD_Y, ADD_W, ADD_H, 512, 512); } } } diff --git a/src/main/java/slimeknights/mantle/client/screen/book/TextDataRenderer.java b/src/main/java/slimeknights/mantle/client/screen/book/TextDataRenderer.java index 95613cc..ef996a5 100644 --- a/src/main/java/slimeknights/mantle/client/screen/book/TextDataRenderer.java +++ b/src/main/java/slimeknights/mantle/client/screen/book/TextDataRenderer.java @@ -1,5 +1,6 @@ package slimeknights.mantle.client.screen.book; +import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.BufferBuilder; @@ -7,6 +8,8 @@ import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.resources.I18n; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -26,18 +29,18 @@ public class TextDataRenderer { /** * @deprecated Call drawText with tooltip param and then call drawTooltip separately on the tooltip layer to prevent overlap */ - public static String drawText(int x, int y, int boxWidth, int boxHeight, TextData[] data, int mouseX, int mouseY, FontRenderer fr) { - List tooltip = new ArrayList(); - String action = drawText(x, y, boxWidth, boxHeight, data, mouseX, mouseY, fr, tooltip); + public static String drawText(MatrixStack matrixStack, int x, int y, int boxWidth, int boxHeight, TextData[] data, int mouseX, int mouseY, FontRenderer fr) { + List tooltip = new ArrayList(); + String action = drawText(matrixStack, x, y, boxWidth, boxHeight, data, mouseX, mouseY, fr, tooltip); if (tooltip.size() > 0) { - drawTooltip(tooltip, mouseX, mouseY, fr); + drawTooltip(matrixStack, tooltip, mouseX, mouseY, fr); } return action; } - public static String drawText(int x, int y, int boxWidth, int boxHeight, TextData[] data, int mouseX, int mouseY, FontRenderer fr, @Nonnull List tooltip) { + public static String drawText(MatrixStack matrixStack, int x, int y, int boxWidth, int boxHeight, TextData[] data, int mouseX, int mouseY, FontRenderer fr, @Nonnull List tooltip) { String action = ""; int atX = x; @@ -102,7 +105,7 @@ public class TextDataRenderer { } String s = split[i]; - drawScaledString(fr, modifiers + s, atX, atY, 0, item.dropshadow, item.scale); + drawScaledString(matrixStack, fr, modifiers + s, atX, atY, 0, item.dropshadow, item.scale); if (i < split.length - 1) { atY += fr.FONT_HEIGHT; @@ -152,10 +155,10 @@ public class TextDataRenderer { if (atY >= y + boxHeight) { if (item.dropshadow) { - fr.drawStringWithShadow("...", atX, atY, 0); + fr.func_238405_a_(matrixStack, "...", atX, atY, 0); } else { - fr.drawString("...", atX, atY, 0); + fr.func_238421_b_(matrixStack, "...", atX, atY, 0); } break; } @@ -163,8 +166,8 @@ public class TextDataRenderer { } if (BookScreen.debug && action != null && !action.isEmpty()) { - tooltip.add(""); - tooltip.add(TextFormatting.GRAY + "Action: " + action); + tooltip.add(StringTextComponent.field_240750_d_); + tooltip.add(new StringTextComponent("Action: " + action).func_240699_a_(TextFormatting.GRAY)); } return action; @@ -221,20 +224,20 @@ public class TextDataRenderer { } //BEGIN METHODS FROM GUI - public static void drawTooltip(List textLines, int mouseX, int mouseY, FontRenderer font) { - GuiUtils.drawHoveringText(textLines, mouseX, mouseY, BookScreen.PAGE_WIDTH, BookScreen.PAGE_HEIGHT, BookScreen.PAGE_WIDTH, font); + public static void drawTooltip(MatrixStack matrixStack, List textLines, int mouseX, int mouseY, FontRenderer font) { + GuiUtils.drawHoveringText(matrixStack, textLines, mouseX, mouseY, BookScreen.PAGE_WIDTH, BookScreen.PAGE_HEIGHT, BookScreen.PAGE_WIDTH, font); RenderHelper.disableStandardItemLighting(); } - public static void drawScaledString(FontRenderer font, String text, float x, float y, int color, boolean dropShadow, float scale) { + public static void drawScaledString(MatrixStack matrixStack, FontRenderer font, String text, float x, float y, int color, boolean dropShadow, float scale) { RenderSystem.pushMatrix(); RenderSystem.translatef(x, y, 0); RenderSystem.scalef(scale, scale, 1F); if (dropShadow) { - font.drawStringWithShadow(text, 0, 0, color); + font.func_238405_a_(matrixStack, text, 0, 0, color); } else { - font.drawString(text, 0, 0, color); + font.func_238421_b_(matrixStack, text, 0, 0, color); } RenderSystem.popMatrix(); } diff --git a/src/main/java/slimeknights/mantle/client/screen/book/element/AnimationToggleElement.java b/src/main/java/slimeknights/mantle/client/screen/book/element/AnimationToggleElement.java index 68fc406..33ea859 100644 --- a/src/main/java/slimeknights/mantle/client/screen/book/element/AnimationToggleElement.java +++ b/src/main/java/slimeknights/mantle/client/screen/book/element/AnimationToggleElement.java @@ -20,7 +20,7 @@ public class AnimationToggleElement extends ArrowElement { @Override public void mouseClicked(double mouseX, double mouseY, int mouseButton) { if (this.button != null && this.isHovered(mouseX, mouseY)) { - this.button.onPress(); + this.button.func_230930_b_(); this.toggled = !this.toggled; this.updateColor(); } diff --git a/src/main/java/slimeknights/mantle/client/screen/book/element/ArrowElement.java b/src/main/java/slimeknights/mantle/client/screen/book/element/ArrowElement.java index cf6970d..0798ca1 100644 --- a/src/main/java/slimeknights/mantle/client/screen/book/element/ArrowElement.java +++ b/src/main/java/slimeknights/mantle/client/screen/book/element/ArrowElement.java @@ -1,5 +1,6 @@ package slimeknights.mantle.client.screen.book.element; +import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.widget.button.Button.IPressable; import slimeknights.mantle.client.screen.book.ArrowButton; @@ -15,14 +16,14 @@ public class ArrowElement extends ButtonElement { } @Override - public void draw(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { - this.button.render(mouseX, mouseY, partialTicks); + public void draw(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { + this.button.func_230431_b_(matrixStack, mouseX, mouseY, partialTicks); } @Override public void mouseClicked(double mouseX, double mouseY, int mouseButton) { if (this.button != null && this.isHovered(mouseX, mouseY)) { - this.button.onPress(); + this.button.func_230930_b_(); } } diff --git a/src/main/java/slimeknights/mantle/client/screen/book/element/BookElement.java b/src/main/java/slimeknights/mantle/client/screen/book/element/BookElement.java index c4dc8de..bfabf11 100644 --- a/src/main/java/slimeknights/mantle/client/screen/book/element/BookElement.java +++ b/src/main/java/slimeknights/mantle/client/screen/book/element/BookElement.java @@ -1,5 +1,6 @@ package slimeknights.mantle.client.screen.book.element; +import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.AbstractGui; import net.minecraft.client.gui.FontRenderer; @@ -31,9 +32,9 @@ public abstract class BookElement extends AbstractGui { this.y = y; } - public abstract void draw(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer); + public abstract void draw(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer); - public void drawOverlay(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { + public void drawOverlay(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { } public void mouseClicked(double mouseX, double mouseY, int mouseButton) { @@ -52,22 +53,22 @@ public abstract class BookElement extends AbstractGui { } - public void renderToolTip(FontRenderer fontRenderer, ItemStack stack, int x, int y) { + public void renderToolTip(MatrixStack matrixStack, FontRenderer fontRenderer, ItemStack stack, int x, int y) { if (stack != null) { List list = stack.getTooltip(this.mc.player, this.mc.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL); - List list1 = list.stream().map(ITextComponent::getFormattedText).collect(Collectors.toList()); FontRenderer font = stack.getItem().getFontRenderer(stack); if (font == null) { font = fontRenderer; } - this.drawHoveringText(list1, x, y, font); + + this.drawHoveringText(matrixStack, list, x, y, font); RenderHelper.disableStandardItemLighting(); } } - public void drawHoveringText(List textLines, int x, int y, FontRenderer font) { - GuiUtils.drawHoveringText(textLines, x, y, this.parent.width, this.parent.height, -1, font); + public void drawHoveringText(MatrixStack matrixStack, List textLines, int x, int y, FontRenderer font) { + GuiUtils.drawHoveringText(matrixStack, textLines, x, y, this.parent.field_230708_k_, this.parent.field_230709_l_, -1, font); RenderHelper.disableStandardItemLighting(); } } diff --git a/src/main/java/slimeknights/mantle/client/screen/book/element/ImageElement.java b/src/main/java/slimeknights/mantle/client/screen/book/element/ImageElement.java index c3fd63e..ffd302e 100644 --- a/src/main/java/slimeknights/mantle/client/screen/book/element/ImageElement.java +++ b/src/main/java/slimeknights/mantle/client/screen/book/element/ImageElement.java @@ -1,5 +1,6 @@ package slimeknights.mantle.client.screen.book.element; +import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.RenderHelper; @@ -60,7 +61,7 @@ public class ImageElement extends SizedBookElement { } @Override - public void draw(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { + public void draw(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { float r = ((this.colorMultiplier >> 16) & 0xff) / 255.F; float g = ((this.colorMultiplier >> 8) & 0xff) / 255.F; float b = (this.colorMultiplier & 0xff) / 255.F; @@ -70,19 +71,19 @@ public class ImageElement extends SizedBookElement { if (this.image.item == null) { this.renderEngine.bindTexture(this.image.location); - blitRaw(this.x, this.y, this.width, this.height, this.image.u, this.image.u + this.image.uw, this.image.v, this.image.v + this.image.vh, this.image.texWidth, this.image.texHeight); + blitRaw(matrixStack, this.x, this.y, this.width, this.height, this.image.u, this.image.u + this.image.uw, this.image.v, this.image.v + this.image.vh, this.image.texWidth, this.image.texHeight); } else { RenderSystem.pushMatrix(); RenderSystem.translatef(this.x, this.y, 0F); RenderSystem.scalef(this.width / 16F, this.height / 16F, 1F); - this.itemElement.draw(mouseX, mouseY, partialTicks, fontRenderer); + this.itemElement.draw(matrixStack, mouseX, mouseY, partialTicks, fontRenderer); RenderHelper.disableStandardItemLighting(); RenderSystem.popMatrix(); } } - public static void blitRaw(int x, int y, int w, int h, int minU, int maxU, int minV, int maxV, float tw, float th) { - innerBlit(x, x + w, y, y + h, 0, minU / tw, maxU / tw, minV / th, maxV / th); + public static void blitRaw(MatrixStack matrixStack, int x, int y, int w, int h, int minU, int maxU, int minV, int maxV, float tw, float th) { + func_238461_a_(matrixStack.getLast().getMatrix(), x, x + w, y, y + h, 0, minU / tw, maxU / tw, minV / th, maxV / th); } } diff --git a/src/main/java/slimeknights/mantle/client/screen/book/element/ItemElement.java b/src/main/java/slimeknights/mantle/client/screen/book/element/ItemElement.java index 09f25c1..a237c74 100644 --- a/src/main/java/slimeknights/mantle/client/screen/book/element/ItemElement.java +++ b/src/main/java/slimeknights/mantle/client/screen/book/element/ItemElement.java @@ -1,5 +1,6 @@ package slimeknights.mantle.client.screen.book.element; +import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.block.Block; import net.minecraft.client.gui.FontRenderer; @@ -8,6 +9,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.text.ITextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import slimeknights.mantle.client.book.action.StringActionProcessor; @@ -24,7 +26,7 @@ public class ItemElement extends SizedBookElement { public NonNullList itemCycle; public float scale; public String action; - public List tooltip; + public List tooltip; public int renderTick = 0; public int currentItem = 0; @@ -69,7 +71,7 @@ public class ItemElement extends SizedBookElement { } @Override - public void draw(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { + public void draw(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { this.renderTick++; if (this.renderTick > ITEM_SWITCH_TICKS) { @@ -94,13 +96,13 @@ public class ItemElement extends SizedBookElement { } @Override - public void drawOverlay(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { + public void drawOverlay(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { if (this.isHovered(mouseX, mouseY) && this.currentItem < this.itemCycle.size()) { if (this.tooltip != null) { - this.drawHoveringText(this.tooltip, mouseX, mouseY, fontRenderer); + this.drawHoveringText(matrixStack, this.tooltip, mouseX, mouseY, fontRenderer); } else { - this.renderToolTip(fontRenderer, this.itemCycle.get(this.currentItem), mouseX, mouseY); + this.renderToolTip(matrixStack, fontRenderer, this.itemCycle.get(this.currentItem), mouseX, mouseY); } } } diff --git a/src/main/java/slimeknights/mantle/client/screen/book/element/SelectionElement.java b/src/main/java/slimeknights/mantle/client/screen/book/element/SelectionElement.java index f92f9b0..c0c6cc1 100644 --- a/src/main/java/slimeknights/mantle/client/screen/book/element/SelectionElement.java +++ b/src/main/java/slimeknights/mantle/client/screen/book/element/SelectionElement.java @@ -1,7 +1,10 @@ package slimeknights.mantle.client.screen.book.element; +import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.gui.FontRenderer; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TextFormatting; import slimeknights.mantle.client.book.data.SectionData; @@ -32,12 +35,12 @@ public class SelectionElement extends SizedBookElement { } @Override - public void draw(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { + public void draw(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { boolean unlocked = this.section.isUnlocked(this.parent.advancementCache); boolean hover = this.isHovered(mouseX, mouseY); if (hover) { - fill(this.iconX, this.iconY, this.iconX + IMG_SIZE, this.iconY + IMG_SIZE, this.parent.book.appearance.hoverColor); + func_238467_a_(matrixStack, this.iconX, this.iconY, this.iconX + IMG_SIZE, this.iconY + IMG_SIZE, this.parent.book.appearance.hoverColor); } if (unlocked) { RenderSystem.color4f(1F, 1F, 1F, hover ? 1F : 0.5F); @@ -49,31 +52,36 @@ public class SelectionElement extends SizedBookElement { RenderSystem.color4f(r, g, b, 0.75F); } - this.iconRenderer.draw(mouseX, mouseY, partialTicks, fontRenderer); + this.iconRenderer.draw(matrixStack, mouseX, mouseY, partialTicks, fontRenderer); if (this.section.parent.appearance.drawSectionListText) { int textW = fontRenderer.getStringWidth(this.section.getTitle()); int textX = this.x + WIDTH / 2 - textW / 2; int textY = this.y + HEIGHT - fontRenderer.FONT_HEIGHT / 2; - fontRenderer.drawString(this.section.getTitle(), - textX, - textY, - hover ? 0xFF000000 : 0x7F000000); + fontRenderer.func_238421_b_(matrixStack, this.section.getTitle(), + textX, + textY, + hover ? 0xFF000000 : 0x7F000000); } } @Override - public void drawOverlay(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { + public void drawOverlay(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { if (this.section != null && this.isHovered(mouseX, mouseY)) { - List text = new ArrayList<>(); - text.add(this.section.getTitle()); - if (!this.section.isUnlocked(this.parent.advancementCache)) { - text.add(TextFormatting.RED + "Locked"); - text.add("Requirements:"); + List text = new ArrayList<>(); - text.addAll(this.section.requirements); + text.add(new StringTextComponent(this.section.getTitle())); + + if (!this.section.isUnlocked(this.parent.advancementCache)) { + text.add(new StringTextComponent("Locked").func_240701_a_(TextFormatting.RED)); + text.add(new StringTextComponent("Requirements:")); + + for (String requirement : this.section.requirements) { + text.add(new StringTextComponent(requirement)); + } } - this.drawHoveringText(text, mouseX, mouseY, fontRenderer); + + this.drawHoveringText(matrixStack, text, mouseX, mouseY, fontRenderer); } } diff --git a/src/main/java/slimeknights/mantle/client/screen/book/element/StructureElement.java b/src/main/java/slimeknights/mantle/client/screen/book/element/StructureElement.java index da0ebc8..fc8ce4a 100644 --- a/src/main/java/slimeknights/mantle/client/screen/book/element/StructureElement.java +++ b/src/main/java/slimeknights/mantle/client/screen/book/element/StructureElement.java @@ -143,7 +143,7 @@ public class StructureElement extends SizedBookElement { private int fullStructureSteps = 5; @Override - public void draw(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { + public void draw(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { if (this.lastClick != null) { if (Minecraft.getInstance().mouseHelper.isLeftDown() || Minecraft.getInstance().mouseHelper.isRightDown()) { int dx = mouseX - this.lastClick[0]; diff --git a/src/main/java/slimeknights/mantle/client/screen/book/element/TextElement.java b/src/main/java/slimeknights/mantle/client/screen/book/element/TextElement.java index 1fcce5c..0535905 100644 --- a/src/main/java/slimeknights/mantle/client/screen/book/element/TextElement.java +++ b/src/main/java/slimeknights/mantle/client/screen/book/element/TextElement.java @@ -1,6 +1,8 @@ package slimeknights.mantle.client.screen.book.element; +import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.gui.FontRenderer; +import net.minecraft.util.text.ITextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import slimeknights.mantle.client.book.action.StringActionProcessor; @@ -15,7 +17,7 @@ import java.util.List; public class TextElement extends SizedBookElement { public TextData[] text; - private List tooltip = new ArrayList(); + private final List tooltip = new ArrayList(); private boolean doAction = false; @@ -34,8 +36,8 @@ public class TextElement extends SizedBookElement { } @Override - public void draw(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { - String action = TextDataRenderer.drawText(this.x, this.y, this.width, this.height, this.text, mouseX, mouseY, fontRenderer, this.tooltip); + public void draw(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { + String action = TextDataRenderer.drawText(matrixStack, this.x, this.y, this.width, this.height, this.text, mouseX, mouseY, fontRenderer, this.tooltip); if (this.doAction) { this.doAction = false; @@ -44,9 +46,9 @@ public class TextElement extends SizedBookElement { } @Override - public void drawOverlay(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { + public void drawOverlay(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { if (this.tooltip.size() > 0) { - TextDataRenderer.drawTooltip(this.tooltip, mouseX, mouseY, fontRenderer); + TextDataRenderer.drawTooltip(matrixStack, this.tooltip, mouseX, mouseY, fontRenderer); this.tooltip.clear(); } } diff --git a/src/main/java/slimeknights/mantle/client/screen/book/element/TooltipElement.java b/src/main/java/slimeknights/mantle/client/screen/book/element/TooltipElement.java index 85533c6..e0601dd 100644 --- a/src/main/java/slimeknights/mantle/client/screen/book/element/TooltipElement.java +++ b/src/main/java/slimeknights/mantle/client/screen/book/element/TooltipElement.java @@ -1,26 +1,29 @@ package slimeknights.mantle.client.screen.book.element; +import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.gui.FontRenderer; +import net.minecraft.util.text.ITextComponent; import java.util.List; public class TooltipElement extends SizedBookElement { - private List tooltip; - public TooltipElement(List tooltip, int x, int y, int width, int height) { + private final List tooltips; + + public TooltipElement(List tooltip, int x, int y, int width, int height) { super(x, y, width, height); - this.tooltip = tooltip; + this.tooltips = tooltip; } @Override - public void draw(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { + public void draw(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { } @Override - public void drawOverlay(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { + public void drawOverlay(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { if (this.isHovered(mouseX, mouseY)) { - this.drawHoveringText(this.tooltip, mouseX, mouseY, fontRenderer); + this.drawHoveringText(matrixStack, this.tooltips, mouseX, mouseY, fontRenderer); } } } diff --git a/src/main/java/slimeknights/mantle/common/IRegisterUtil.java b/src/main/java/slimeknights/mantle/common/IRegisterUtil.java deleted file mode 100644 index 701f9c1..0000000 --- a/src/main/java/slimeknights/mantle/common/IRegisterUtil.java +++ /dev/null @@ -1,181 +0,0 @@ -package slimeknights.mantle.common; - -import net.minecraft.block.Block; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.IStringSerializable; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.registries.IForgeRegistry; -import net.minecraftforge.registries.IForgeRegistryEntry; -import slimeknights.mantle.item.BlockTooltipItem; - -import java.util.Arrays; -import java.util.List; -import java.util.function.Function; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -public interface IRegisterUtil { - /* General methods */ - - /** - * Gets the mod ID to use for registrations - * - * @return String mod ID - */ - String getModId(); - - /** - * Gets a resource location for this mod - * - * @param name Resource name - * @return Resource location in this mod - */ - default ResourceLocation getResource(String name) { - return new ResourceLocation(this.getModId(), name); - } - - /** - * Registers a thing to a Forge registry - * - * @param registry Registry to use - * @param thing Thing to register - * @param name Name to register under - * @param Instance type - * @param Registry type - * @return Thing that was registered - */ - default > I register(IForgeRegistry registry, I thing, String name) { - return this.register(registry, thing, this.getResource(name)); - } - - /** - * Registers a thing to a Forge registry - * - * @param registry Registry to use - * @param thing Thing to register - * @param location Registration location - * @param Instance type - * @param Registry type - * @return Thing that was registered - */ - default > I register(IForgeRegistry registry, I thing, ResourceLocation location) { - thing.setRegistryName(location); - registry.register(thing); - return thing; - } - - - /* Special case methods */ - - /** - * Registers a generic item block for a block - * - * @param registry Item registry - * @param block Block to get item block - * @return Registered item block - */ - default BlockItem registerBlockItem(IForgeRegistry registry, Block block) { - BlockItem itemBlock = new BlockTooltipItem(block, new Item.Properties()); - return this.register(registry, itemBlock, block.getRegistryName()); - } - - /** - * Registers a generic item block for a block - * - * @param registry Item registry - * @param block Block to get item block - * @param group Group for the item block - * @return Registered item block - */ - default BlockItem registerBlockItem(IForgeRegistry registry, Block block, ItemGroup group) { - BlockItem itemBlock = new BlockTooltipItem(block, new Item.Properties().group(group)); - return this.register(registry, itemBlock, block.getRegistryName()); - } - - /** - * Registers an item block, using the block as the registry name - * - * @param registry Item registry - * @param itemBlock Item block instance to register - * @return Registered item block - */ - default T registerBlockItem(IForgeRegistry registry, T itemBlock) { - return this.register(registry, itemBlock, itemBlock.getBlock().getRegistryName()); - } - - /** - * Registers a tile entity class to the game - * - * @param registry Tile entity registry - * @param constructor Tile entity constructor instance - * @param name Registry name to use - */ - default TileEntityType registerTE(IForgeRegistry> registry, Supplier constructor, String name, Block... validBlocks) { - TileEntityType type = TileEntityType.Builder.create(constructor, validBlocks).build(null); - return this.register(registry, type, name); - } - - /* List methods */ - - /** - * Registers a list of blocks from a list of variants. Commonly used with Enum.values() - * - * @param registry Block registry instance - * @param constructor Block constructor - * @param props Block properties for registration - * @param variants Array of variants - * @param baseName Base name for registration - * @param Block type - * @return List of blocks registered - */ - default List registerBlocks(IForgeRegistry registry, Function constructor, IStringSerializable[] variants, Block.Properties props, String baseName) { - return Arrays.stream(variants).map((s) -> { - return this.register(registry, constructor.apply(props), baseName + "_" + s.getName()); - }).collect(Collectors.toList()); - } - - /** - * Registers a generic item block for each block in a list - * - * @param registry Item registry - * @param blocks Blocks needing item blocks - * @return Registered item blocks - */ - default List registerBlockItems(IForgeRegistry registry, List blocks) { - return blocks.stream().map((block) -> { - return this.registerBlockItem(registry, block); - }).collect(Collectors.toList()); - } - - /** - * Registers a generic item block for each block in a list - * - * @param registry Item registry - * @param blocks Blocks needing item blocks - * @param group Group for the item blocks - * @return Registered item blocks - */ - default List registerBlockItems(IForgeRegistry registry, List blocks, ItemGroup group) { - return blocks.stream().map((block) -> { - return this.registerBlockItem(registry, block, group); - }).collect(Collectors.toList()); - } - - /** - * Registers a specific item block for each block in a list - * - * @param registry Item registry - * @param blocks Blocks to create item blocks for - * @param constructor ItemBlock constructor - * @return Registered item block - */ - default List registerBlockItems(IForgeRegistry registry, List blocks, Function constructor) { - return blocks.stream().map((block) -> { - return this.registerBlockItem(registry, constructor.apply(block)); - }).collect(Collectors.toList()); - } -} diff --git a/src/main/java/slimeknights/mantle/config/ExampleSync.java b/src/main/java/slimeknights/mantle/config/ExampleSync.java index aa96a40..6afcc9c 100644 --- a/src/main/java/slimeknights/mantle/config/ExampleSync.java +++ b/src/main/java/slimeknights/mantle/config/ExampleSync.java @@ -4,6 +4,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.network.PacketBuffer; +import net.minecraft.util.Util; import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -47,10 +48,10 @@ class ExampleSync { public void playerJoinedWorld(TickEvent.ClientTickEvent event) { ClientPlayerEntity player = Minecraft.getInstance().player; if (needsRestart) { - player.sendMessage(new StringTextComponent("Configs synced with server. Configs require a restart")); + player.sendMessage(new StringTextComponent("Configs synced with server. Configs require a restart"), Util.field_240973_b_); } else { - player.sendMessage(new StringTextComponent("Configs synced with server.")); + player.sendMessage(new StringTextComponent("Configs synced with server."), Util.field_240973_b_); } MinecraftForge.EVENT_BUS.unregister(this); } diff --git a/src/main/java/slimeknights/mantle/item/EdibleItem.java b/src/main/java/slimeknights/mantle/item/EdibleItem.java index a515b2c..bed7148 100644 --- a/src/main/java/slimeknights/mantle/item/EdibleItem.java +++ b/src/main/java/slimeknights/mantle/item/EdibleItem.java @@ -1,5 +1,6 @@ package slimeknights.mantle.item; +import com.mojang.datafixers.util.Pair; import net.minecraft.client.resources.I18n; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.item.Food; @@ -13,7 +14,6 @@ import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import org.apache.commons.lang3.tuple.Pair; import javax.annotation.Nullable; import java.util.List; @@ -38,8 +38,8 @@ public class EdibleItem extends Item { if (this.displayEffectsTooltip) { for (Pair pair : stack.getItem().getFood().getEffects()) { - if (pair.getLeft() != null) { - tooltip.add(new StringTextComponent(I18n.format(pair.getLeft().getEffectName()).trim()).applyTextStyle(TextFormatting.GRAY)); + if (pair.getFirst() != null) { + tooltip.add(new StringTextComponent(I18n.format(pair.getFirst().getEffectName()).trim()).func_240699_a_(TextFormatting.GRAY)); } } } diff --git a/src/main/java/slimeknights/mantle/item/TooltipItem.java b/src/main/java/slimeknights/mantle/item/TooltipItem.java index 56ab646..1a05f49 100644 --- a/src/main/java/slimeknights/mantle/item/TooltipItem.java +++ b/src/main/java/slimeknights/mantle/item/TooltipItem.java @@ -35,17 +35,17 @@ public class TooltipItem extends Item { if (!ForgeI18n.getPattern(translationKey).equals(translationKey)) { String translate = ForgeI18n.getPattern(translationKey); if (!ForgeI18n.getPattern(translate).equals(translate)) { - String[] strings = new TranslationTextComponent(translate).getFormattedText().split("\n"); + String[] strings = new TranslationTextComponent(translate).getString().split("\n"); for (String string : strings) { - tooltip.add(new StringTextComponent(string).applyTextStyle(TextFormatting.GRAY)); + tooltip.add(new StringTextComponent(string).func_240699_a_(TextFormatting.GRAY)); } } else { - String[] strings = new TranslationTextComponent(translationKey).getFormattedText().split("\n"); + String[] strings = new TranslationTextComponent(translationKey).getString().split("\n"); for (String string : strings) { - tooltip.add(new StringTextComponent(string).applyTextStyle(TextFormatting.GRAY)); + tooltip.add(new StringTextComponent(string).func_240699_a_(TextFormatting.GRAY)); } } } diff --git a/src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java b/src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java index c4668f0..2714621 100644 --- a/src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java +++ b/src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java @@ -77,7 +77,7 @@ public class MultiServantLogic extends MantleTileEntity implements IServantLogic @Deprecated public boolean verifyMaster(IMasterLogic logic, BlockPos pos) { 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 @@ -129,8 +129,8 @@ public class MultiServantLogic extends MantleTileEntity implements IServantLogic } @Override - public void read(CompoundNBT tags) { - super.read(tags); + public void func_230337_a_(BlockState blockState, CompoundNBT tags) { + super.func_230337_a_(blockState, tags); this.readCustomNBT(tags); } diff --git a/src/main/java/slimeknights/mantle/pulsar/config/IConfiguration.java b/src/main/java/slimeknights/mantle/pulsar/config/IConfiguration.java deleted file mode 100644 index 0eb3304..0000000 --- a/src/main/java/slimeknights/mantle/pulsar/config/IConfiguration.java +++ /dev/null @@ -1,45 +0,0 @@ -package slimeknights.mantle.pulsar.config; - -import slimeknights.mantle.pulsar.pulse.PulseMeta; - -import javax.annotation.ParametersAreNonnullByDefault; - -/** - * Interface for config handlers. - * - * @author Arkan - */ -@ParametersAreNonnullByDefault -public interface IConfiguration { - - /** - * Perform any configuration loading required. - */ - void load(); - - /** - * Perform anything after all pulses have been registered. - */ - void postLoad(); - - /** - * Gets whether the given module is enabled in the config. - * - * @param meta The pulse metadata. - * @return Whether the module is enabled. - */ - boolean isModuleEnabled(PulseMeta meta); - - /** - * Perform any action whenever a new pulse get's registered. - * - * @param meta The pulse metadata. - * @return Whether the module is enabled. - */ - void addPulse(PulseMeta meta); - - /** - * Flush configuration to disk/database/whatever. - */ - void flush(); -} diff --git a/src/main/java/slimeknights/mantle/pulsar/config/PulsarConfig.java b/src/main/java/slimeknights/mantle/pulsar/config/PulsarConfig.java deleted file mode 100644 index f143c2a..0000000 --- a/src/main/java/slimeknights/mantle/pulsar/config/PulsarConfig.java +++ /dev/null @@ -1,108 +0,0 @@ -package slimeknights.mantle.pulsar.config; - -import com.electronwill.nightconfig.core.file.CommentedFileConfig; -import com.electronwill.nightconfig.core.io.WritingMode; -import net.minecraftforge.common.ForgeConfigSpec; -import net.minecraftforge.fml.loading.FMLPaths; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import slimeknights.mantle.pulsar.control.PulseManager; -import slimeknights.mantle.pulsar.pulse.PulseMeta; - -import javax.annotation.Nonnull; -import java.nio.file.Path; -import java.util.LinkedHashMap; -import java.util.Locale; -import java.util.Map; - -public class PulsarConfig implements IConfiguration { - - private static final Logger LOGGER = LogManager.getLogger(); - - private final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder(); - private ForgeConfigSpec SPEC = this.BUILDER.build(); - - private final CommentedFileConfig config; - - private final String description; - - private boolean configBuilt; - private final Map modules = new LinkedHashMap<>(); - - /** - * Creates the config to be used later. - * - * Do NOT make this the same as the overall mod configuration; it will clobber it! - * - * @param confName The config file name (without path or .toml suffix) - * @param description The description for the group that the config entries will be placed in. - */ - public PulsarConfig(String confName, String description) { - this.config = this.createConfig(FMLPaths.CONFIGDIR.get(), confName); - this.description = description.toLowerCase(Locale.US); - this.configBuilt = false; - this.BUILDER.push(this.description); - } - - @Override - public void load() { - } - - @Override - public void postLoad() { - if (!this.configBuilt) { - this.BUILDER.pop(); - this.SPEC = this.BUILDER.build(); - this.SPEC.setConfig(this.config); - } - - this.configBuilt = true; - } - - @Override - public boolean isModuleEnabled(@Nonnull PulseMeta meta) { - ForgeConfigSpec.BooleanValue entry = this.modules.get(meta.getId()); - - if (entry == null) { - this.modules.put(meta.getId(), this.BUILDER.comment(meta.getDescription()).worldRestart().define(meta.getId(), meta.isDefaultEnabled())); - return meta.isEnabled(); - } - else { - return entry.get(); - } - } - - @Override - public void addPulse(@Nonnull PulseMeta meta) { - ForgeConfigSpec.BooleanValue entry = this.modules.get(meta.getId()); - if (entry == null) { - this.modules.put(meta.getId(), this.BUILDER.comment(meta.getDescription()).worldRestart().define(meta.getId(), meta.isDefaultEnabled())); - } - } - - /*@Override - public boolean isModuleEnabled(ForgeConfigSpec.BooleanValue configValue) { - return configValue.get(); - } - - @Override - public ForgeConfigSpec.BooleanValue getConfigEntry(PulseMeta meta) { - ForgeConfigSpec.BooleanValue value = BUILDER.comment(meta.getDescription()).worldRestart().define(meta.getId(), meta.isDefaultEnabled()); - - return value; - }*/ - - @Override - public void flush() { - this.config.save(); - } - - public CommentedFileConfig createConfig(Path configBasePath, String configName) { - final Path configPath = configBasePath.resolve(String.format("%s.toml", configName)); - final CommentedFileConfig configData = CommentedFileConfig.builder(configPath).sync().autosave().writingMode(WritingMode.REPLACE).build(); - LOGGER.debug(PulseManager.PULSAR, "Built TOML config for {}", configPath.toString()); - configData.load(); - LOGGER.debug(PulseManager.PULSAR, "Loaded TOML config file {}", configPath.toString()); - return configData; - } -} diff --git a/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java b/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java deleted file mode 100644 index 347df80..0000000 --- a/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java +++ /dev/null @@ -1,334 +0,0 @@ -package slimeknights.mantle.pulsar.control; - -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.eventbus.EventBus; -import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.CrashReportExtender; -import net.minecraftforge.fml.ModContainer; -import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -import net.minecraftforge.fml.javafmlmod.FMLModContainer; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.Marker; -import org.apache.logging.log4j.MarkerManager; -import slimeknights.mantle.pulsar.config.IConfiguration; -import slimeknights.mantle.pulsar.flightpath.Flightpath; -import slimeknights.mantle.pulsar.flightpath.IExceptionHandler; -import slimeknights.mantle.pulsar.flightpath.lib.AnnotationLocator; -import slimeknights.mantle.pulsar.internal.BusExceptionHandler; -import slimeknights.mantle.pulsar.internal.Configuration; -import slimeknights.mantle.pulsar.internal.CrashHandler; -import slimeknights.mantle.pulsar.pulse.Pulse; -import slimeknights.mantle.pulsar.pulse.PulseMeta; - -import javax.annotation.ParametersAreNonnullByDefault; -import java.lang.reflect.Field; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * Manager class for a given mods Pulses. - * - * This MUST be constructed by a mod BEFORE preinit as it registers on to the mod event bus - a static block would serve - * for this. No more Pulses can be registered after preinit has been caught, so assume preinit is too late to register - * new Pulses. - * - * Each Pulsar-enabled mod should create one and only one of these to manage its Pulses. - * - * @author Arkan - */ -@SuppressWarnings("unused") -@ParametersAreNonnullByDefault -public class PulseManager { - - private Logger log; - private final boolean useConfig; - - private static final Map> ALL_PULSES = new HashMap<>(); - private final Map pulses = new LinkedHashMap<>(); - private final Map allPulses = new LinkedHashMap<>(); - // Use the Google @Subscribe to avoid confusion/breaking changes. - private final Flightpath flightpath = new Flightpath(new AnnotationLocator(SubscribeEvent.class)); - - private boolean blockNewRegistrations = false; - private boolean configLoaded = false; - private IConfiguration conf; - private String id; - - public static final Marker PULSAR = MarkerManager.getMarker("PULSAR"); - - /** - * Configuration-using constructor. - * - * This form creates a PulseManager that supports configuration of Pulses by file. - * - * @param configName The config file name. - */ - public PulseManager(String configName) { - this.init(); - this.useConfig = true; - this.conf = new Configuration(configName, this.log); - } - - /** - * Custom configuration-using constructor. - * - * Don't like JSON? Heathen. Lets you handle configuration, to whatever media you like - File, database, death star. - * Whatever really. See {@link slimeknights.mantle.pulsar.config.IConfiguration}. - * - * @param config Configuration handler. - */ - public PulseManager(IConfiguration config) { - this.init(); - this.useConfig = true; - this.conf = config; - } - - /** - * Shared initialiser code between all the constructors. - */ - private void init() { - String modId = ModLoadingContext.get().getActiveContainer().getNamespace(); - this.id = modId; - this.log = LogManager.getLogger("Pulsar-" + modId); - this.flightpath.setExceptionHandler(new BusExceptionHandler(modId)); - CrashReportExtender.registerCrashCallable(new CrashHandler(modId, this)); - // regsister our pulse loader so it can be found by the static method - ALL_PULSES.put(modId, this.pulses); - // Attach us to the mods FML bus - this.attachToContainerEventBus(this); - } - - /** - * Overrides Pulsars default behaviour when a pulse emits an exception. See Flightpath's documentation. - * - * @param handler The Flightpath-compatible exception handler to use. - */ - public void setPulseExceptionHandler(IExceptionHandler handler) { - this.flightpath.setExceptionHandler(handler); - } - - /** - * Register a new Pulse with the manager. - * - * This CANNOT be done after preinit has been invoked. - * - * @param pulse The Pulse to register. - */ - public void registerPulse(Object pulse) { - if (this.blockNewRegistrations) { - throw new RuntimeException("A mod tried to register a plugin after preinit! Pulse: " - + pulse); - } - if (!this.configLoaded) { - this.conf.load(); - - this.configLoaded = true; - } - - String id, description, deps, pulseDeps; - boolean forced, enabled, defaultEnabled, missingDeps = false; - - try { - Pulse p = pulse.getClass().getAnnotation(Pulse.class); - id = p.id(); - description = p.description(); - deps = p.modsRequired(); - pulseDeps = p.pulsesRequired(); - forced = p.forced(); - enabled = p.defaultEnable(); - defaultEnabled = p.defaultEnable(); - } - catch (NullPointerException ex) { - throw new RuntimeException("Could not parse @Pulse annotation for Pulse: " + pulse); - } - - // Work around Java not allowing default-null fields. - if (description.equals("")) { - description = null; - } - - if (!deps.equals("")) { - String[] parsedDeps = deps.split(";"); - for (String s : parsedDeps) { - if (!ModList.get().isLoaded(s)) { - this.log.info(PULSAR, "Skipping Pulse " + id + "; missing dependency: " + s); - missingDeps = true; - enabled = false; - break; - } - } - } - - PulseMeta meta = new PulseMeta(id, description, forced, enabled, defaultEnabled); - meta.setMissingDeps(missingDeps || !this.hasRequiredPulses(meta, pulseDeps)); - - if (meta.isForced() || !this.useConfig) { - this.allPulses.put(pulse, meta); - } - else { - this.conf.addPulse(meta); - this.allPulses.put(pulse, meta); - } - } - - /** - * Helper to attach a given object to the mod container event bus. - * - * @param obj Object to register. - */ - private void attachToContainerEventBus(Object obj) { - ModContainer cnt = ModLoadingContext.get().getActiveContainer(); - this.log.debug(PULSAR, "Attaching [" + obj + "] to event bus for container [" + cnt + "]"); - try { - FMLModContainer mc = (FMLModContainer) cnt; - Field ebf = mc.getClass().getDeclaredField("eventBus"); - - boolean access = ebf.isAccessible(); - ebf.setAccessible(true); - EventBus eb = (EventBus) ebf.get(mc); - ebf.setAccessible(access); - - eb.register(obj); - } - catch (NoSuchFieldException nsfe) { - throw new RuntimeException("Pulsar >> Incompatible FML mod container (missing eventBus field) - wrong Forge version?"); - } - catch (IllegalAccessException iae) { - throw new RuntimeException("Pulsar >> Security Manager blocked access to eventBus on mod container. Cannot continue."); - } - catch (ClassCastException cce) { - throw new RuntimeException("Pulsar >> Something in the mod container had the wrong type? " + cce.getMessage()); - } - } - - /** - * Internal (but public for EventBus use) handler for events. - * - * DO NOT CALL THIS DIRECTLY! Let EventBus handle it. - * - * @param evt An event object. - */ - @SubscribeEvent - public void propagateEvent(Event evt) { - if (evt instanceof FMLCommonSetupEvent) { - this.preInit((FMLCommonSetupEvent) evt); - } - // We use individual buses due to the EventBus class using a Set rather than a List, thus losing the ordering. - // This trick is shamelessly borrowed from FML. - this.flightpath.post(evt); - } - - private boolean getEnabledFromConfig(PulseMeta meta) { - if (meta.isForced() || !this.useConfig) { - return true; // Forced or no config set. - } - - return this.conf.isModuleEnabled(meta); - } - - private void preInit(FMLCommonSetupEvent evt) { - if (!this.blockNewRegistrations) { - this.conf.flush(); // First init call, so flush config - } - this.blockNewRegistrations = true; - } - - private boolean hasRequiredPulses(PulseMeta meta, String deps) { - if (!deps.equals("")) { - String[] parsedDeps = deps.split(";"); - for (String s : parsedDeps) { - if (!this.isPulseLoaded(s)) { - this.log.info(PULSAR, "Skipping Pulse " + meta.getId() + "; missing pulse: " + s); - return false; - } - } - } - return true; - } - - /** - * Check if a given Pulse ID is loaded in this manager. - * - * @param pulseId The ID to check. If it contains : treats the ID as a resource location and checks the global list - * @return Whether the ID was present. - */ - public boolean isPulseLoaded(String pulseId) { - // if it has a colon, assume its a namespaced ID - if (pulseId.contains(":")) { - return isPulseLoadedGlobal(pulseId); - } - return isPulseLoaded(this.pulses, pulseId); - } - - /** - * Check if a given Pulse ID is loaded in any manager. - * - * @param pulseId Resource location string to check. Domain is the mod ID, path is the pulse ID - * @return Whether the ID was present. - */ - public static boolean isPulseLoadedGlobal(String pulseId) { - ResourceLocation loc = new ResourceLocation(pulseId); - Map pulses = ALL_PULSES.get(loc.getNamespace()); - if (pulses != null) { - return isPulseLoaded(pulses, loc.getPath()); - } - return false; - } - - /** - * Checks whether a pulse is loaded in the given pulse manager - * - * @param pulseId The ID to check. - * @return Whether the ID was present. - */ - private static boolean isPulseLoaded(Map pulses, String pulseId) { - for (Map.Entry entry : pulses.entrySet()) { - if (entry.getValue().getId().equalsIgnoreCase(pulseId)) { - return true; - } - } - return false; - } - - public Collection getAllPulseMetadata() { - return this.pulses.values(); - } - - @Override - public String toString() { - return "PulseManager[" + this.id + "]"; - } - - /** - * Enable or Disable all Pulses registered - * - * This MUST be called after you register all your pulses using registerPulse and must be called BEFORE preinit - */ - public void enablePulses() { - if (this.blockNewRegistrations) { - throw new RuntimeException("A mod tried to enable their plugins after preinit!"); - } - - if (this.configLoaded) { - this.conf.postLoad(); - } - - for (Map.Entry entry : this.allPulses.entrySet()) { - PulseMeta meta = entry.getValue(); - Object pulse = entry.getKey(); - - meta.setEnabled(this.getEnabledFromConfig(meta)); - - if (meta.isEnabled()) { - this.pulses.put(pulse, meta); - this.flightpath.register(pulse); - } - } - } -} diff --git a/src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java b/src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java deleted file mode 100644 index b9fec72..0000000 --- a/src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java +++ /dev/null @@ -1,32 +0,0 @@ -package slimeknights.mantle.pulsar.debug; - -import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import slimeknights.mantle.pulsar.pulse.Pulse; - -/** - * Debug Pulse to 'eavesdrop' on the PulseManager event bus traffic. - * - * @author Arkan - */ -@SuppressWarnings("unused") -@Pulse(id = "EventSpy", description = "we iz in ur buses, monitorin ur eventz", forced = true) -public class EventSpy { - - private final Logger log = LogManager.getLogger("EventSpy/" + ModLoadingContext.get().getActiveContainer().getNamespace()); - - @SubscribeEvent - public void receive(Event evt) { - this.log.info("Received event: " + evt); - } - - @SubscribeEvent - public void preInit(final FMLCommonSetupEvent evt) { - this.log.info("Example preInit hit"); - } - -} diff --git a/src/main/java/slimeknights/mantle/pulsar/flightpath/Airdrop.java b/src/main/java/slimeknights/mantle/pulsar/flightpath/Airdrop.java deleted file mode 100755 index 9445755..0000000 --- a/src/main/java/slimeknights/mantle/pulsar/flightpath/Airdrop.java +++ /dev/null @@ -1,21 +0,0 @@ -package slimeknights.mantle.pulsar.flightpath; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Default annotation for Flightpath subscriptions. - * - * We don't use @Subscriber, as too many frameworks use it (which may lead to import hell) - * - * @author Arkan - */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface Airdrop { - -} diff --git a/src/main/java/slimeknights/mantle/pulsar/flightpath/Flightpath.java b/src/main/java/slimeknights/mantle/pulsar/flightpath/Flightpath.java deleted file mode 100755 index 8558c90..0000000 --- a/src/main/java/slimeknights/mantle/pulsar/flightpath/Flightpath.java +++ /dev/null @@ -1,121 +0,0 @@ -package slimeknights.mantle.pulsar.flightpath; - -import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.eventbus.api.IGenericEvent; -import slimeknights.mantle.pulsar.flightpath.lib.AnnotationLocator; -import slimeknights.mantle.pulsar.flightpath.lib.BlackholeExceptionHandler; - -import javax.annotation.ParametersAreNonnullByDefault; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Type; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * Flightpath - an ordered event bus implementation. - * - * @author Arkan - */ -@ParametersAreNonnullByDefault -@SuppressWarnings({ "unused", "unchecked" }) -public class Flightpath { - - private final ISubscriberLocator locator; - // Note we *MUST* use a linked map, otherwise order is lost. - private final LinkedHashMap, Map>> subscribers = new LinkedHashMap, Map>>(); - // Anything that manipulates state *MUST* acquire this lock. It prevents awkward issues when iterating. - private final Object lock = new Object(); - - private IExceptionHandler exceptionHandler = new BlackholeExceptionHandler(); - - /** - * Generates a plain old Flightpath, using the default @Airdrop annotation. - */ - public Flightpath() { - this.locator = new AnnotationLocator(Airdrop.class); - } - - /** - * Generates a Flightpath using a different locator implementation. - * - * Pass a custom constructed instance of AnnotationLocator to use alternative annotations. - * - * @param locator The locator to be applied to new objects. - */ - public Flightpath(ISubscriberLocator locator) { - this.locator = locator; - } - - /** - * Used to change exception handling behaviour. - * - * @param handler The handler to use. - */ - public void setExceptionHandler(IExceptionHandler handler) { - synchronized (this.lock) { - this.exceptionHandler = handler; - } - } - - /** - * Registers a given object onto the bus. - * - * @param obj Object to attach to the bus. - */ - public void register(Object obj) { - synchronized (this.lock) { - if (this.subscribers.containsKey(obj)) { - return; // Nothing to do. - } - this.subscribers.put(obj, this.locator.findSubscribers(obj)); - } - } - - /** - * Posts the given event on the bus. - * - * By default this blackholes exceptions. If you need different behaviour, see setExceptionHandler. - * - * @param evt The event to post. - */ - public void post(Event evt) { - synchronized (this.lock) { - for (Map.Entry, Map>> ent : this.subscribers.entrySet()) { - for (Map.Entry, Map> obj : ent.getValue().entrySet()) { - if (!obj.getKey().isAssignableFrom(evt.getClass())) { - continue; - } - for (Map.Entry objEnt : obj.getValue().entrySet()) { - Method m = objEnt.getKey(); - Type filter = objEnt.getValue(); - - try { - if (filter == null || filter == ((IGenericEvent) evt).getGenericType()) { - boolean access = m.isAccessible(); - m.setAccessible(true); - m.invoke(ent.getKey(), evt); - m.setAccessible(access); - } - } - catch (InvocationTargetException ex) { - // thrown when a method throws an exception, so use that exception instead of the wrapper for a better stacktrace - if (ex.getTargetException() instanceof Exception) { - this.exceptionHandler.handle((Exception) ex.getTargetException()); - } - else { - this.exceptionHandler.handle(ex); - } - } - catch (Exception ex) { - // all other exceptions, this means something when wrong with the reflection - this.exceptionHandler.handle(ex); - } - } - } - } - this.exceptionHandler.flush(); - } - } - -} diff --git a/src/main/java/slimeknights/mantle/pulsar/flightpath/IExceptionHandler.java b/src/main/java/slimeknights/mantle/pulsar/flightpath/IExceptionHandler.java deleted file mode 100755 index 41f69a9..0000000 --- a/src/main/java/slimeknights/mantle/pulsar/flightpath/IExceptionHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -package slimeknights.mantle.pulsar.flightpath; - -import javax.annotation.ParametersAreNonnullByDefault; - -/** - * General interface for an exception handler. - * - * @author Arkan - */ -@ParametersAreNonnullByDefault -public interface IExceptionHandler { - - /** - * Handle a given exception. - * - * @param ex The exception (duh) - */ - void handle(Exception ex); - - /** - * Called after all methods have been invoked for cleanup or coalescing. - */ - void flush(); - -} diff --git a/src/main/java/slimeknights/mantle/pulsar/flightpath/ISubscriberLocator.java b/src/main/java/slimeknights/mantle/pulsar/flightpath/ISubscriberLocator.java deleted file mode 100755 index b67e0d2..0000000 --- a/src/main/java/slimeknights/mantle/pulsar/flightpath/ISubscriberLocator.java +++ /dev/null @@ -1,18 +0,0 @@ -package slimeknights.mantle.pulsar.flightpath; - -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; -import java.lang.reflect.Method; -import java.lang.reflect.Type; -import java.util.Map; - -/** - * Interface for defining custom subscriber scanners. - */ -@ParametersAreNonnullByDefault -public interface ISubscriberLocator { - - @Nonnull - Map, Map> findSubscribers(Object obj); - -} diff --git a/src/main/java/slimeknights/mantle/pulsar/flightpath/lib/AnnotationLocator.java b/src/main/java/slimeknights/mantle/pulsar/flightpath/lib/AnnotationLocator.java deleted file mode 100755 index dec67e7..0000000 --- a/src/main/java/slimeknights/mantle/pulsar/flightpath/lib/AnnotationLocator.java +++ /dev/null @@ -1,61 +0,0 @@ -package slimeknights.mantle.pulsar.flightpath.lib; - -import net.minecraftforge.eventbus.api.IGenericEvent; -import slimeknights.mantle.pulsar.flightpath.ISubscriberLocator; - -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.Map; - -/** - * Default implementation of ISubscriberLocator - * - * @author Arkan - */ -@ParametersAreNonnullByDefault -public class AnnotationLocator implements ISubscriberLocator { - - private final Class annotation; - - public AnnotationLocator(Class annotation) { - this.annotation = annotation; - } - - @Override - public @Nonnull - Map, Map> findSubscribers(Object obj) { - Map, Map> methods = new HashMap, Map>(); - - for (Method m : obj.getClass().getMethods()) { - if (m.isAnnotationPresent(this.annotation) && m.getParameterTypes().length == 1) { - Class param = m.getParameterTypes()[0]; - - Type filter = null; - - if (IGenericEvent.class.isAssignableFrom(param)) { - Type type = m.getGenericParameterTypes()[0]; - - if (type instanceof ParameterizedType) { - filter = ((ParameterizedType) type).getActualTypeArguments()[0]; - - if (filter instanceof ParameterizedType) { - filter = ((ParameterizedType) filter).getRawType(); - } - } - } - - if (!methods.containsKey(param)) { - methods.put(param, new HashMap()); - } - methods.get(param).put(m, filter); - } - } - - return methods; - } -} diff --git a/src/main/java/slimeknights/mantle/pulsar/flightpath/lib/BlackholeExceptionHandler.java b/src/main/java/slimeknights/mantle/pulsar/flightpath/lib/BlackholeExceptionHandler.java deleted file mode 100755 index afc6555..0000000 --- a/src/main/java/slimeknights/mantle/pulsar/flightpath/lib/BlackholeExceptionHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -package slimeknights.mantle.pulsar.flightpath.lib; - -import slimeknights.mantle.pulsar.flightpath.IExceptionHandler; - -import javax.annotation.ParametersAreNonnullByDefault; - -/** - * Default exception handler when Flightpath has been asked to ignore errors. - * - * @author Arkan - */ -@ParametersAreNonnullByDefault -public class BlackholeExceptionHandler implements IExceptionHandler { - - @Override - public void handle(Exception ex) { - // NO-OP - } - - @Override - public void flush() { - // NO-OP - } - -} diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/BusExceptionHandler.java b/src/main/java/slimeknights/mantle/pulsar/internal/BusExceptionHandler.java deleted file mode 100644 index 6b93232..0000000 --- a/src/main/java/slimeknights/mantle/pulsar/internal/BusExceptionHandler.java +++ /dev/null @@ -1,41 +0,0 @@ -package slimeknights.mantle.pulsar.internal; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import slimeknights.mantle.pulsar.flightpath.IExceptionHandler; - -import javax.annotation.ParametersAreNonnullByDefault; - -/** - * Custom exception catcher that logs events. - */ -@ParametersAreNonnullByDefault -public final class BusExceptionHandler implements IExceptionHandler { - - private final String id; - private final Logger logger; - - /** - * @param id Mod ID to include in exception raises. - */ - public BusExceptionHandler(String id) { - this.id = id; - this.logger = LogManager.getLogger(id + "-Pulsar-Flightpath"); - } - - @Override - public void handle(Exception ex) { - this.logger.error("Exception caught from a pulse on flightpath for mod ID " + this.id + ": ", ex); - // if its a runtime exception, we can just throw it as is - if (ex instanceof RuntimeException) { - throw (RuntimeException) ex; - } - throw new Error(ex); - } - - @Override - public void flush() { - // NO-OP - } - -} diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java b/src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java deleted file mode 100644 index bcbcbad..0000000 --- a/src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java +++ /dev/null @@ -1,235 +0,0 @@ -package slimeknights.mantle.pulsar.internal; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import org.apache.logging.log4j.Logger; -import slimeknights.mantle.pulsar.config.IConfiguration; -import slimeknights.mantle.pulsar.pulse.PulseMeta; - -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.nio.file.Paths; -import java.util.HashMap; -import java.util.Map; - -/** - * Default Gson Configuration helper. - * - * @author Arkan - */ -@ParametersAreNonnullByDefault -public class Configuration implements IConfiguration { - - private static final int CONFIG_LEVEL = 1; - - private static final Gson gson = new GsonBuilder().setPrettyPrinting().create(); - private final String confPath; - private final Logger logger; - - private Map modules; - - /** - * Creates a new Configuration object. - * - * Do NOT make this the same as the overall mod configuration; it will clobber it! - * - * @param confName The config file name (without path or .json suffix) - * @param logger The logger to send debug info to. - */ - public Configuration(String confName, Logger logger) { - this.confPath = Paths.get("config", confName + ".json").toString(); - this.logger = logger; - } - - @Override - public void load() { - this.getModulesFromJson(); - } - - @Override - public void postLoad() { - } - - @Override - public boolean isModuleEnabled(@Nonnull PulseMeta meta) { - ConfigEntry entry = this.modules.get(meta.getId()); - if (entry == null) { - return meta.isEnabled(); - } - else { - return entry.getEnabled(); - } - } - - @Override - public void addPulse(@Nonnull PulseMeta meta) { - ConfigEntry entry = this.modules.get(meta.getId()); - - if (entry == null) { - this.modules.put(meta.getId(), new ConfigEntry(meta.isDefaultEnabled(), meta.getDescription())); - } - } - - @Override - public void flush() { - this.writeModulesToJson(); - } - - private void getModulesFromJson() { - // Step 1: Does the file exist? - File f = new File(this.confPath); - if (!f.exists()) { - this.logger.info("Couldn't find config file; will generate a new one later."); - this.modules = new HashMap(); - return; - } - - // Step 2: File exists. Let's make sure it's usable. - if (!(f.canRead() && f.canWrite())) { - throw new FileNotReadWritableException("Could not read/write Pulsar config: " + this.confPath); - } - - // Step 3: Good enough. Read it. - try { - try { - this.modules = this.parseV1Config(f); - } - catch (Exception ex) { - this.logger.warn("Failed to parse " + f.getName() + " using the v1 parser; trying the v0 parser."); - Map conf = this.parseV0Config(f); - this.logger.info("Found valid v0 configuration. Upgrading it."); - this.modules = conf; - this.writeModulesToJson(); - this.logger.info("Upgrade complete! Config is now in v1 format."); - } - } - catch (Exception ex) { - this.logger.warn("Invalid config file. Discarding."); - ex.printStackTrace(); - this.modules = new HashMap(); - } - } - - private Map parseV0Config(File f) throws Exception { - try { - JsonReader reader = new JsonReader(new InputStreamReader(new FileInputStream(f))); - Map m = gson.fromJson(reader, new TypeToken>() { - }.getType()); // NASTY! - if (m == null) { - throw new NullPointerException("Gson returned null."); - } - Map out = new HashMap(); - for (Map.Entry e : m.entrySet()) { - out.put(e.getKey(), new ConfigEntry(e.getValue())); - } - return out; - } - catch (FileNotFoundException fnfe) { - throw new RuntimeException("This shouldn't be possible... " + fnfe); - } - } - - private Map parseV1Config(File f) throws Exception { - try { - JsonReader reader = new JsonReader(new InputStreamReader(new FileInputStream(f))); - GsonConfig c = gson.fromJson(reader, GsonConfig.class); - if (c.getConfigVersion() > 1) { - throw new RuntimeException("Pulsar config is from a newer version! Remove it! " + f.getAbsolutePath()); - } - if (c.getModules() == null) { - throw new IllegalArgumentException("Not a valid GsonConfig. Try v0 parsing."); - } - return c.getModules(); - } - catch (FileNotFoundException fnfe) { - throw new RuntimeException("This shouldn't be possible... " + fnfe); - } - } - - private void writeModulesToJson() { - try { - JsonWriter writer = new JsonWriter(new OutputStreamWriter(new FileOutputStream(new File(this.confPath)))); - writer.setIndent(" "); - GsonConfig out = new GsonConfig(CONFIG_LEVEL, this.modules); - gson.toJson(out, GsonConfig.class, writer); - writer.close(); - } - catch (Exception ex) { - this.logger.warn("Could not write config? " + this.confPath); - } - } - - /** - * Internal exception for an unreadable/unwritable config. - */ - private static class FileNotReadWritableException extends RuntimeException { - - public FileNotReadWritableException(String message) { - super(message); - } - } - - /** - * Internal data holder, for use in the map and JSON. - */ - private static class ConfigEntry { - - private Boolean enabled; - private String description = null; - - public ConfigEntry(Boolean enabled) { - this.enabled = enabled; - } - - public ConfigEntry(Boolean enabled, String description) { - this(enabled); - this.description = description; - } - - public Boolean getEnabled() { - return this.enabled; - } - - public void setEnabled(Boolean enabled) { - this.enabled = enabled; - } - - public String getDescription() { - return this.description; - } - } - - /** - * Internal representation of a version 1+ config file. - */ - private static class GsonConfig { - - private int CONFIG_VERSION = 0; - - private Map modules; - - public GsonConfig(int version, Map modules) { - this.CONFIG_VERSION = version; - this.modules = modules; - } - - public int getConfigVersion() { - return this.CONFIG_VERSION; - } - - public Map getModules() { - return this.modules; - } - - } - -} diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/CrashHandler.java b/src/main/java/slimeknights/mantle/pulsar/internal/CrashHandler.java deleted file mode 100644 index 464449c..0000000 --- a/src/main/java/slimeknights/mantle/pulsar/internal/CrashHandler.java +++ /dev/null @@ -1,51 +0,0 @@ -package slimeknights.mantle.pulsar.internal; - -import net.minecraftforge.fml.common.ICrashCallable; -import slimeknights.mantle.pulsar.control.PulseManager; -import slimeknights.mantle.pulsar.pulse.PulseMeta; - -/** - * FML crash callable for Pulse Managers; dumps a list of loaded pulses to the error log. - * - * @author Arkan - */ -public class CrashHandler implements ICrashCallable { - - private String id; - private PulseManager manager; - - public CrashHandler(String modId, PulseManager manager) { - this.id = "Pulsar/" + modId + " loaded Pulses"; - this.manager = manager; - } - - @Override - public String getLabel() { - return this.id; - } - - @Override - public String call() throws Exception { - String out = "\n"; - for (PulseMeta meta : this.manager.getAllPulseMetadata()) { - String state = getStateFromMeta(meta); - out += "\t\t- " + meta.getId() + " (" + state + ")\n"; // Yes, yes, manual indenting, I know... - } - return out; - } - - private static String getStateFromMeta(PulseMeta meta) { - if (meta.isForced()) { - return "Enabled/Forced"; - } - else { - if (meta.isEnabled()) { - return "Enabled/Not Forced"; - } - else { - return "Disabled/Not Forced"; - } - } - } - -} diff --git a/src/main/java/slimeknights/mantle/pulsar/package-info.java b/src/main/java/slimeknights/mantle/pulsar/package-info.java deleted file mode 100644 index d3b6f3e..0000000 --- a/src/main/java/slimeknights/mantle/pulsar/package-info.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Project Pulsar - * - * This is a repackaged copy of the Pulsar project, an open source library for internal module loading. - * The upstream repository is at https://github.com/Emberwalker/Pulsar - * - * This code package is licensed under the MIT License, as below. - * - * ----- - * - * The MIT License (MIT) - * - * Copyright (c) 2014 Arkan - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * ----- - * - * @author Arkan - */ -package slimeknights.mantle.pulsar; \ No newline at end of file diff --git a/src/main/java/slimeknights/mantle/pulsar/pulse/Pulse.java b/src/main/java/slimeknights/mantle/pulsar/pulse/Pulse.java deleted file mode 100644 index 005dc81..0000000 --- a/src/main/java/slimeknights/mantle/pulsar/pulse/Pulse.java +++ /dev/null @@ -1,52 +0,0 @@ -package slimeknights.mantle.pulsar.pulse; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Metadata annotation for IPulse implementations. - * - * Pulses should use the standard Google Event Bus @Subscribe annotation to catch FML events, which are forwarded from - * the current mod container (including Pre/Init/Post events). - * - * @author Arkan - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE }) -@Documented -public @interface Pulse { - - /** - * @return This Pulses UID - Much like FML mods have mod IDs. - */ - String id(); - - /** - * @return This Pulses description, human-readable for config files. Can be blank. - */ - String description() default ""; - - /** - * @return Dependant mod IDs, seperated by ; as in FML. Skips checks when undefined. - */ - String modsRequired() default ""; - - /** - * @return Dependeant Pulse IDs, seperated by ; . Skips checks when undefined. - */ - String pulsesRequired() default ""; - - /** - * @return Whether this Pulse is mandatory or not (true -> mandatory). - */ - boolean forced() default false; - - /** - * @return Whether a configurable Pulse should be enabled by default. Ignored where forced = true. - */ - boolean defaultEnable() default true; - -} diff --git a/src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java b/src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java deleted file mode 100644 index 0cd1730..0000000 --- a/src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java +++ /dev/null @@ -1,53 +0,0 @@ -package slimeknights.mantle.pulsar.pulse; - -import javax.annotation.Nullable; -import javax.annotation.ParametersAreNonnullByDefault; - -/** - * Metadata wrapper for parsed @Pulse metadata. - * - * @author Arkan - */ -@ParametersAreNonnullByDefault -public class PulseMeta { - - private String id, description; - private boolean forced, enabled, defaultEnabled; - private boolean missingDeps = false; - - public PulseMeta(String id, @Nullable String description, boolean forced, boolean enabled, boolean defaultEnabled) { - this.id = id; - this.description = description; - this.forced = forced; - this.enabled = enabled; - this.defaultEnabled = defaultEnabled; - } - - public String getId() { - return this.id; - } - - public String getDescription() { - return this.description; - } - - public boolean isForced() { - return !this.missingDeps && this.forced; - } - - public boolean isEnabled() { - return !this.missingDeps && this.enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - public void setMissingDeps(boolean missing) { - this.missingDeps = missing; - } - - public boolean isDefaultEnabled() { - return this.defaultEnabled; - } -} diff --git a/src/main/java/slimeknights/mantle/tileentity/InventoryTileEntity.java b/src/main/java/slimeknights/mantle/tileentity/InventoryTileEntity.java index 4c4ca64..36b23ae 100644 --- a/src/main/java/slimeknights/mantle/tileentity/InventoryTileEntity.java +++ b/src/main/java/slimeknights/mantle/tileentity/InventoryTileEntity.java @@ -1,5 +1,6 @@ package slimeknights.mantle.tileentity; +import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.IInventory; @@ -210,10 +211,10 @@ public abstract class InventoryTileEntity extends MantleTileEntity implements II @Override public ITextComponent getDisplayName() { if (this.hasCustomName()) { - return new StringTextComponent(this.getName().getFormattedText()); + return new StringTextComponent(this.getName().getString()); } - return new TranslationTextComponent(this.getName().getFormattedText()); + return new TranslationTextComponent(this.getName().getString()); } /* Supporting methods */ @@ -239,14 +240,14 @@ public abstract class InventoryTileEntity extends MantleTileEntity implements II /* NBT */ @Override - public void read(CompoundNBT tags) { - super.read(tags); + public void func_230337_a_(BlockState blockState, CompoundNBT tags) { + super.func_230337_a_(blockState, tags); this.resizeInternal(tags.getInt("InventorySize")); this.readInventoryFromNBT(tags); if (tags.contains("CustomName", 8)) { - this.inventoryTitle = ITextComponent.Serializer.fromJson(tags.getString("CustomName")); + this.inventoryTitle = ITextComponent.Serializer.func_240643_a_(tags.getString("CustomName")); } } diff --git a/src/main/java/slimeknights/mantle/util/JeiPlugin.java b/src/main/java/slimeknights/mantle/util/JeiPlugin.java index ebafb4a..06424fd 100644 --- a/src/main/java/slimeknights/mantle/util/JeiPlugin.java +++ b/src/main/java/slimeknights/mantle/util/JeiPlugin.java @@ -1,6 +1,10 @@ package slimeknights.mantle.util; -import mezz.jei.api.IModPlugin; +public class JeiPlugin { + +} + +/*import mezz.jei.api.IModPlugin; import mezz.jei.api.gui.handlers.IGuiContainerHandler; import mezz.jei.api.registration.IGuiHandlerRegistration; import mezz.jei.api.registration.IModIngredientRegistration; @@ -44,4 +48,4 @@ public class JeiPlugin implements IModPlugin { public void registerIngredients(IModIngredientRegistration registry) { } -} +}*/ diff --git a/src/main/java/slimeknights/mantle/util/LocUtils.java b/src/main/java/slimeknights/mantle/util/LocUtils.java index 2af06d1..fc1949a 100644 --- a/src/main/java/slimeknights/mantle/util/LocUtils.java +++ b/src/main/java/slimeknights/mantle/util/LocUtils.java @@ -33,17 +33,17 @@ public abstract class LocUtils { if (!ForgeI18n.getPattern(text).equals(text)) { String translate = ForgeI18n.getPattern(text); if (!ForgeI18n.getPattern(translate).equals(translate)) { - String[] strings = new TranslationTextComponent(translate).getFormattedText().split("\n"); + String[] strings = new TranslationTextComponent(translate).getString().split("\n"); for (String string : strings) { - list.add(new StringTextComponent(string).applyTextStyle(TextFormatting.GRAY)); + list.add(new StringTextComponent(string).func_240699_a_(TextFormatting.GRAY)); } } else { - String[] strings = new TranslationTextComponent(text).getFormattedText().split("\n"); + String[] strings = new TranslationTextComponent(text).getString().split("\n"); for (String string : strings) { - list.add(new StringTextComponent(string).applyTextStyle(TextFormatting.GRAY)); + list.add(new StringTextComponent(string).func_240699_a_(TextFormatting.GRAY)); } } } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 0a68cd8..4251b64 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -5,12 +5,15 @@ public net.minecraft.client.gui.screen.inventory.ContainerScreen field_146999_f public net.minecraft.client.gui.screen.inventory.ContainerScreen field_147000_g # ySize public net.minecraft.client.gui.screen.inventory.ContainerScreen field_147009_r # guiTop public net.minecraft.client.gui.screen.inventory.ContainerScreen field_147003_i # guiLeft -public net.minecraft.client.gui.screen.inventory.ContainerScreen func_146977_a(Lnet/minecraft/inventory/container/Slot;)V # drawSlot +public net.minecraft.client.gui.screen.inventory.ContainerScreen func_238746_a_(Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/inventory/container/Slot;)V # drawSlot public net.minecraft.client.gui.screen.inventory.ContainerScreen func_195362_a(Lnet/minecraft/inventory/container/Slot;DD)Z # isSlotSelected +# AbstractGUI +public net.minecraft.client.gui.AbstractGui func_238461_a_(Lnet/minecraft/util/math/vector/Matrix4f;IIIIIFFFF)V # blit + # Slot public-f net.minecraft.inventory.container.Slot field_75223_e # xPos public-f net.minecraft.inventory.container.Slot field_75221_f # yPos # Screen -public net.minecraft.client.gui.screen.Screen buttons # buttons \ No newline at end of file +public net.minecraft.client.gui.screen.Screen buttons # buttons