-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #193 from CannoliCatfish/dev
Dev1.3
- Loading branch information
Showing
198 changed files
with
3,245 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/main/java/com/cannolicatfish/rankine/blocks/alloys/AlloyBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}*/ | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/com/cannolicatfish/rankine/blocks/alloys/AlloyBlockTile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
...a/com/cannolicatfish/rankine/client/integration/jei/categories/ElementRecipeCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())))); | ||
}); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/cannolicatfish/rankine/enchantment/GuardEnchantment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.