Skip to content

Commit

Permalink
Merge pull request #193 from CannoliCatfish/dev
Browse files Browse the repository at this point in the history
Dev1.3
  • Loading branch information
CannoliCatfish authored May 21, 2021
2 parents 395a3b1 + 4a4c6b7 commit 18a9de1
Show file tree
Hide file tree
Showing 198 changed files with 3,245 additions and 179 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

version = '1.16.5-1.2.2'
version = '1.16.5-1.3'
group = 'com.cannolicatfish' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'rankine'

Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/cannolicatfish/rankine/ProjectRankine.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.cannolicatfish.rankine;

import com.cannolicatfish.rankine.blocks.alloys.AlloyBlockTile;
import com.cannolicatfish.rankine.blocks.crucible.CrucibleContainer;
import com.cannolicatfish.rankine.blocks.crucible.CrucibleTile;
import com.cannolicatfish.rankine.blocks.evaporationtower.EvaporationTowerContainer;
Expand Down Expand Up @@ -133,6 +134,7 @@ private void LoadComplete(FMLLoadCompleteEvent event) {

@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public static class RegistryEvents {

@SubscribeEvent
@OnlyIn(Dist.CLIENT)
public static void onItemColorRegistry(final ColorHandlerEvent.Item event) {
Expand Down Expand Up @@ -219,6 +221,7 @@ public static void onRecipeSerializersRegistry(final RegistryEvent.Register<IRec
event.getRegistry().register(AlloyingRecipe.SERIALIZER.setRegistryName(ProjectRankine.MODID,"alloying"));
event.getRegistry().register(BeehiveOvenRecipe.SERIALIZER.setRegistryName(ProjectRankine.MODID,"beehive_oven"));
event.getRegistry().register(SluicingRecipe.SERIALIZER.setRegistryName(ProjectRankine.MODID,"sluicing"));
event.getRegistry().register(ElementRecipe.SERIALIZER.setRegistryName(ProjectRankine.MODID,"element"));

}

Expand All @@ -232,6 +235,7 @@ public static void onTileEntityRegistry(final RegistryEvent.Register<TileEntityT
event.getRegistry().register(TileEntityType.Builder.create(EvaporationTowerTile::new, RankineBlocks.EVAPORATION_TOWER.get()).build(null).setRegistryName(ProjectRankine.MODID,"evaporation_tower"));
event.getRegistry().register(TileEntityType.Builder.create(RankineBoxTile::new, RankineBlocks.RANKINE_BOX.get()).build(null).setRegistryName(ProjectRankine.MODID,"rankine_box"));
event.getRegistry().register(TileEntityType.Builder.create(LaserQuarryTile::new, RankineBlocks.LASER_QUARRY.get()).build(null).setRegistryName(ProjectRankine.MODID,"laser_quarry"));
event.getRegistry().register(TileEntityType.Builder.create(AlloyBlockTile::new, RankineBlocks.BRONZE_BLOCK.get()).build(null).setRegistryName(ProjectRankine.MODID,"bronze_alloy_block"));

}

Expand Down Expand Up @@ -410,6 +414,8 @@ public static void registerFluids(final RegistryEvent.Register<Fluid> event) {

@SubscribeEvent
public static void registerEnchantments(final RegistryEvent.Register<Enchantment> event) {
final EquipmentSlotType[] ARMOR_SLOTS = new EquipmentSlotType[]{EquipmentSlotType.HEAD, EquipmentSlotType.CHEST, EquipmentSlotType.LEGS, EquipmentSlotType.FEET};

event.getRegistry().register(new PunctureEnchantment(Enchantment.Rarity.COMMON, EquipmentSlotType.MAINHAND).setRegistryName(ProjectRankine.MODID,"puncture"));
event.getRegistry().register(new SwingEnchantment(Enchantment.Rarity.COMMON, EquipmentSlotType.MAINHAND).setRegistryName(ProjectRankine.MODID,"swing"));
event.getRegistry().register(new DazeEnchantment(Enchantment.Rarity.COMMON, EquipmentSlotType.MAINHAND).setRegistryName(ProjectRankine.MODID,"daze"));
Expand All @@ -419,6 +425,7 @@ public static void registerEnchantments(final RegistryEvent.Register<Enchantment
event.getRegistry().register(new QuakeEnchantment(Enchantment.Rarity.UNCOMMON, EquipmentSlotType.MAINHAND).setRegistryName(ProjectRankine.MODID,"quake"));
event.getRegistry().register(new ForagingEnchantment(Enchantment.Rarity.RARE, EquipmentSlotType.MAINHAND).setRegistryName(ProjectRankine.MODID,"foraging"));
event.getRegistry().register(new LightningAspectEnchantment(Enchantment.Rarity.VERY_RARE, EquipmentSlotType.MAINHAND).setRegistryName(ProjectRankine.MODID,"lightning_aspect"));
event.getRegistry().register(new PryingEnchantment(Enchantment.Rarity.RARE, EquipmentSlotType.MAINHAND).setRegistryName(ProjectRankine.MODID,"prying"));
event.getRegistry().register(new DuneWalkerEnchantment(Enchantment.Rarity.VERY_RARE, EquipmentSlotType.FEET).setRegistryName(ProjectRankine.MODID,"dune_walker"));
event.getRegistry().register(new SnowDrifterEnchantment(Enchantment.Rarity.VERY_RARE, EquipmentSlotType.FEET).setRegistryName(ProjectRankine.MODID,"snow_drifter"));
event.getRegistry().register(new SpeedSkaterEnchantment(Enchantment.Rarity.VERY_RARE, EquipmentSlotType.FEET).setRegistryName(ProjectRankine.MODID,"speed_skater"));
Expand All @@ -429,6 +436,7 @@ public static void registerEnchantments(final RegistryEvent.Register<Enchantment
event.getRegistry().register(new GhastRegenerationEnchantment(Enchantment.Rarity.VERY_RARE, EquipmentSlotType.MAINHAND).setRegistryName(ProjectRankine.MODID,"ghast_regeneration"));
event.getRegistry().register(new WitheringCurseEnchantment(Enchantment.Rarity.VERY_RARE, EquipmentSlotType.MAINHAND).setRegistryName(ProjectRankine.MODID,"withering_curse"));

event.getRegistry().register(new GuardEnchantment(Enchantment.Rarity.UNCOMMON, ARMOR_SLOTS).setRegistryName(ProjectRankine.MODID,"guard"));
}
/*
@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.pathfinding.PathNodeType;
import net.minecraft.state.IntegerProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
Expand All @@ -21,6 +23,7 @@
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import org.jetbrains.annotations.Nullable;

import java.util.Random;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.cannolicatfish.rankine.blocks.alloys;

import com.cannolicatfish.rankine.blocks.alloyfurnace.AlloyFurnaceTile;
import com.cannolicatfish.rankine.items.alloys.AlloyData;
import com.cannolicatfish.rankine.items.alloys.AlloyItem;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.tileentity.ShulkerBoxTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;

import javax.annotation.Nullable;

public class AlloyBlock extends Block {
public AlloyBlock(Properties properties) {
super(properties);
}

@Override
public boolean hasTileEntity(BlockState state) {
return true;
}

@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new AlloyBlockTile();
}

public boolean eventReceived(BlockState state, World worldIn, BlockPos pos, int id, int param) {
super.eventReceived(state, worldIn, pos, id, param);
TileEntity tileentity = worldIn.getTileEntity(pos);
return tileentity != null && tileentity.receiveClientEvent(id, param);
}

@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, @org.jetbrains.annotations.Nullable LivingEntity placer, ItemStack stack) {
if (AlloyItem.getComposition(stack).size() > 0) {
TileEntity tileentity = worldIn.getTileEntity(pos);
INBT nbt = AlloyItem.getComposition(stack).getCompound(0).get("comp");
if (tileentity instanceof AlloyBlockTile && nbt != null) {
((AlloyBlockTile)tileentity).setComp(nbt.getString());
}
}
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
}
/*
public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) {
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof AlloyBlockTile) {
AlloyBlockTile alloyBlockTile = (AlloyBlockTile)tileentity;
if (!worldIn.isRemote && !player.isCreative() && canHarvestBlock(state,worldIn,pos,player)) {
//ItemStack itemstack = getColoredItemStack(this.getColor());
ItemStack itemstack = new ItemStack(this);
String composition = alloyBlockTile.getComp();
System.out.println(composition);
if (!composition.isEmpty()) {
AlloyItem.addAlloy(itemstack,new AlloyData(composition));
}
ItemEntity itementity = new ItemEntity(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, itemstack);
itementity.setDefaultPickupDelay();
worldIn.addEntity(itementity);
}
}
super.onBlockHarvested(worldIn, pos, state, player);
}*/
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.cannolicatfish.rankine.blocks.alloys;

import net.minecraft.block.BlockState;
import net.minecraft.inventory.ItemStackHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.NonNullList;
import net.minecraftforge.common.ForgeHooks;

import static com.cannolicatfish.rankine.init.RankineBlocks.ALLOY_BLOCK_TILE;

public class AlloyBlockTile extends TileEntity {
public String comp = "";
public AlloyBlockTile() {
super(ALLOY_BLOCK_TILE);
}

@Override
public void read(BlockState state, CompoundNBT nbt) {
super.read(state, nbt);
this.comp = nbt.getString("comp");
}

@Override
public CompoundNBT write(CompoundNBT compound) {
super.write(compound);
compound.putString("comp", this.comp);
return compound;
}

public String getComp() {
return comp;
}

public void setComp(String s) {
this.comp = s;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void registerRecipes(@Nonnull IRecipeRegistration registry) {
registry.addRecipes(RankineRecipes.getEvaporationRecipes(), EvaporationRecipeCategory.UID);
registry.addRecipes(rankineJEIRecipes.getCrushingRecipes(), CrushingRecipeCategory.UID);
registry.addRecipes(rankineJEIRecipes.getAlloyingRecipes(), AlloyingRecipeCategory.UID);
registry.addRecipes(rankineJEIRecipes.getElementRecipes(), ElementRecipeCategory.UID);
registry.addIngredientInfo(new ItemStack(RankineItems.COKE.get()), VanillaTypes.ITEM, "Coke can be obtained by cooking Bituminous Coal Blocks in a beehive oven.",
"See Beehive Oven Pit for more details.");
registry.addIngredientInfo(new ItemStack(RankineItems.QUICKLIME.get()), VanillaTypes.ITEM, "Quicklime can be obtained by cooking Limestone in a beehive oven.",
Expand Down Expand Up @@ -83,6 +84,7 @@ public void registerCategories(IRecipeCategoryRegistration registry) {
registry.addRecipeCategories(new CrushingRecipeCategory(guiHelper));
registry.addRecipeCategories(new AlloyingRecipeCategory(guiHelper));
registry.addRecipeCategories(new SluicingRecipeCategory(guiHelper));
registry.addRecipeCategories(new ElementRecipeCategory(guiHelper));
registry.addRecipeCategories(new EvaporationRecipeCategory(guiHelper));
}

Expand All @@ -96,6 +98,7 @@ public void registerRecipeCatalysts(IRecipeCatalystRegistration registry) {
registry.addRecipeCatalyst(new ItemStack(RankineBlocks.PISTON_CRUSHER.get()), CrushingRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(RankineBlocks.GYRATORY_CRUSHER.get()), CrushingRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(RankineItems.STEEL_GOLD_PAN.get()), SluicingRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(RankineItems.ELEMENT_INDEXER.get()), ElementRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(RankineBlocks.EVAPORATION_TOWER.get()), EvaporationRecipeCategory.UID);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.cannolicatfish.rankine.client.integration.jei;

import com.cannolicatfish.rankine.init.RankineRecipeTypes;
import com.cannolicatfish.rankine.recipe.AlloyingRecipe;
import com.cannolicatfish.rankine.recipe.BeehiveOvenRecipe;
import com.cannolicatfish.rankine.recipe.CrushingRecipe;
import com.cannolicatfish.rankine.recipe.SluicingRecipe;
import com.cannolicatfish.rankine.recipe.*;
import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.client.Minecraft;
import net.minecraft.client.world.ClientWorld;
Expand Down Expand Up @@ -41,6 +38,10 @@ public List<SluicingRecipe> getSluicingRecipes() {
return recipeManager.getRecipesForType(RankineRecipeTypes.SLUICING);
}

public List<ElementRecipe> getElementRecipes() {
return recipeManager.getRecipesForType(RankineRecipeTypes.ELEMENT);
}

public static <T> void checkNotNull(@Nullable T object, String name) {
if (object == null) {
throw new NullPointerException(name + " must not be null.");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
package com.cannolicatfish.rankine.client.integration.jei.categories;

import com.cannolicatfish.rankine.ProjectRankine;
import com.cannolicatfish.rankine.init.RankineBlocks;
import com.cannolicatfish.rankine.init.RankineItems;
import com.cannolicatfish.rankine.recipe.ElementRecipe;
import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Util;
import net.minecraft.util.text.StringTextComponent;
import org.lwjgl.opengl.GL11;

import java.awt.*;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;

public class ElementRecipeCategory implements IRecipeCategory<ElementRecipe> {

public static ResourceLocation UID = new ResourceLocation(ProjectRankine.MODID, "element");
private final IDrawable background;
private final String localizedName;
private final IDrawable overlay;
private final IDrawable icon;

public ElementRecipeCategory(IGuiHelper guiHelper) {
background = guiHelper.createBlankDrawable(145, 125);
localizedName = I18n.format("rankine.jei.element");
overlay = guiHelper.createDrawable(new ResourceLocation(ProjectRankine.MODID, "textures/gui/element_jei.png"),
0, 15, 140, 120);
icon = guiHelper.createDrawableIngredient(new ItemStack(RankineItems.ELEMENT_INDEXER.get()));
}

@Override
public ResourceLocation getUid() {
return UID;
}

@Override
public Class<? extends ElementRecipe> getRecipeClass() {
return ElementRecipe.class;
}

@Override
public String getTitle() {
return localizedName;
}

@Override
public IDrawable getBackground() {
return background;
}

@Override
public IDrawable getIcon() {
return icon;
}

@Override
public void draw(ElementRecipe recipe, MatrixStack ms, double mouseX, double mouseY) {
FontRenderer font = Minecraft.getInstance().fontRenderer;
RenderSystem.enableAlphaTest();
RenderSystem.enableBlend();
overlay.draw(ms, 0, 4);
RenderSystem.disableBlend();
RenderSystem.disableAlphaTest();

String name = recipe.getName().toUpperCase(Locale.ROOT);
DecimalFormat df = Util.make(new DecimalFormat("##.##"), (p_234699_0_) -> {
p_234699_0_.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ROOT));
});
float p = recipe.getElectrodePotential();
String e = "Electrode Potential: " + (p > 0 ? "+" : "") + df.format(recipe.getElectrodePotential())+"V";

font.drawString(ms,String.valueOf(recipe.getAtomicNumber()),60, 10,0x000000);
font.drawString(ms,String.valueOf(recipe.getSymbol()),60, 20,0x000000);
font.drawString(ms,name,(float)(70 - font.getStringWidth(name) / 2),40,0x000000);
font.drawString(ms,e,(float)(70 - font.getStringWidth(e) / 2),50,0x000000);
font.drawString(ms,"Items:",(float)(70 - font.getStringWidth("Items:") / 2),70,0x000000);
}


@Override
public void setIngredients(ElementRecipe recipe, IIngredients iIngredients) {
ImmutableList.Builder<List<ItemStack>> builder = ImmutableList.builder();
for (Ingredient i : recipe.getIngredients()) {
builder.add(Arrays.asList(i.getMatchingStacks()));
}
iIngredients.setInputLists(VanillaTypes.ITEM, builder.build());
iIngredients.setOutputs(VanillaTypes.ITEM, Collections.singletonList(recipe.getRecipeOutput()));
}

@Override
public void setRecipe(IRecipeLayout recipeLayout, ElementRecipe recipe, IIngredients ingredients) {
int index = 0, posX = 23;

for (int i = 0; i < ingredients.getInputs(VanillaTypes.ITEM).size(); i++) {
int floor = Math.floorDiv(i,7);
recipeLayout.getItemStacks().init(index + i, true, (index + i - (6*floor)) * 18 + 13, 80 + (16*floor));
recipeLayout.getItemStacks().set(index + i, ingredients.getInputs(VanillaTypes.ITEM).get(i));
}
recipeLayout.getItemStacks().addTooltipCallback((i, b, stack, list) -> {
DecimalFormat df = Util.make(new DecimalFormat("##.##"), (p_234699_0_) -> {
p_234699_0_.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ROOT));
});
list.add(new StringTextComponent("Material count: " + df.format(recipe.getMaterialCount(stack.getItem()))));
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.cannolicatfish.rankine.enchantment;

import com.cannolicatfish.rankine.init.RankineEnchantmentTypes;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentType;
import net.minecraft.inventory.EquipmentSlotType;

public class GuardEnchantment extends Enchantment {

public GuardEnchantment(Enchantment.Rarity p_i46721_1_, EquipmentSlotType... p_i46721_2_) {
super(p_i46721_1_, EnchantmentType.ARMOR, p_i46721_2_);
}

public int getMinEnchantability(int enchantmentLevel) {
return 10 * enchantmentLevel;
}

public int getMaxEnchantability(int enchantmentLevel) {
return this.getMinEnchantability(enchantmentLevel) + 30;
}
}
Loading

0 comments on commit 18a9de1

Please sign in to comment.