Skip to content

Commit

Permalink
Added Infinitato, fixed a few bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
JackyyTV committed Feb 4, 2018
1 parent 164b128 commit 9820de4
Show file tree
Hide file tree
Showing 18 changed files with 542 additions and 17 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
org.gradle.jvmargs=-Xmx4G
mc_version=1.10.2
forge_version=1.10.2-12.18.3.2511
mod_version=1.0
mod_version=1.1
mappings_version=snapshot_20161111
2 changes: 1 addition & 1 deletion src/main/java/jackyy/avaritiatweaks/AvaritiaTweaks.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class AvaritiaTweaks {

public static final String MODID = "avaritiatweaks";
public static final String MODNAME = "Avaritia Tweaks";
public static final String VERSION = "1.10.2-1.0";
public static final String VERSION = "1.10.2-1.1";
public static final String MCVERSION = "[1.10,1.11)";
public static final String DEPENDS = "required-after:avaritia;required-after:CodeChickenLib;after:Botania;";
public static final String GUIFACTORY = "jackyy.avaritiatweaks.config.ConfigGuiFactory";
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/jackyy/avaritiatweaks/client/Keys.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@SideOnly(Side.CLIENT)
public class Keys {

public static final KeyBinding NOCLIP = new KeyBinding("key.infinity_armor.noclip", new IKeyConflictContext() {
public static final KeyBinding NOCLIP = new KeyBinding(ModConfig.infinityArmor.infinityArmorNoClip ? "key.infinity_armor.noclip" : "key.infinity_armor.noclip.disabled", new IKeyConflictContext() {
@Override
public boolean isActive() {
return KeyConflictContext.IN_GAME.isActive();
Expand All @@ -24,9 +24,7 @@ public boolean conflicts(IKeyConflictContext other) {
}, Keyboard.KEY_APOSTROPHE, "key.categories.avaritiatweaks");

public static void init() {
if (ModConfig.infinityArmor.infinityArmorNoClip) {
ClientRegistry.registerKeyBinding(NOCLIP);
}
ClientRegistry.registerKeyBinding(NOCLIP);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import jackyy.avaritiatweaks.AvaritiaTweaks;
import jackyy.avaritiatweaks.compat.botania.block.BlockGaia;
import jackyy.avaritiatweaks.compat.botania.block.BlockInfinitato;
import jackyy.avaritiatweaks.compat.botania.render.RenderTileInfinitato;
import jackyy.avaritiatweaks.compat.botania.subtile.SubTileAsgardandelion;
import jackyy.avaritiatweaks.compat.botania.subtile.SubTileSoarleander;
import jackyy.avaritiatweaks.compat.botania.tile.TileInfinitato;
import jackyy.avaritiatweaks.config.ModConfig;
import jackyy.avaritiatweaks.util.ModUtils;
import morph.avaritia.init.ModItems;
Expand All @@ -14,6 +17,7 @@
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
Expand All @@ -25,11 +29,10 @@
public class BotaniaCompat {

public static BlockGaia gaiaBlock = new BlockGaia();
public static BlockInfinitato infinitato = new BlockInfinitato();
public static ItemStack asgardandelion = ModUtils.getFlower("asgardandelion");
public static ItemStack soarleander = ModUtils.getFlower("soarleander");

public static RecipeRuneAltar soarleanderRecipe;

public static void preInit() {
GameRegistry.register(gaiaBlock);
GameRegistry.register(new ItemBlock(gaiaBlock), gaiaBlock.getRegistryName());
Expand All @@ -53,22 +56,41 @@ public String getUnlocalizedLoreTextForStack(ItemStack stack) {
});
BotaniaAPI.addSubTileToCreativeMenu("soarleander");
}
if (ModConfig.Compats.botania.infinitato) {
GameRegistry.register(infinitato);
GameRegistry.register(new ItemBlock(infinitato), infinitato.getRegistryName());
GameRegistry.registerTileEntity(TileInfinitato.class, "Avaritia_Infinitato");
}
}

public static void init() {
if (ModConfig.Compats.botania.asgardandelion) {
SubTileAsgardandelion.lexicon = new BotaniaLexiconEntry("asgardandelion", BotaniaAPI.categoryGenerationFlowers);
SubTileAsgardandelion.lexicon.addPage(BotaniaAPI.internalHandler.textPage("botania.lexicon.asgardandelion.0"));
SubTileAsgardandelion.lexicon.setLexiconPages(
BotaniaAPI.internalHandler.textPage("botania.lexicon.asgardandelion.0")
);
SubTileAsgardandelion.lexicon.setIcon(asgardandelion);
}
if (ModConfig.Compats.botania.soarleander) {
SubTileSoarleander.lexicon = new BotaniaLexiconEntry("soarleander", BotaniaAPI.categoryGenerationFlowers);
SubTileSoarleander.lexicon.setLexiconPages(
BotaniaAPI.internalHandler.textPage("botania.lexicon.soarleander.0"),
BotaniaAPI.internalHandler.runeRecipePage("botania.lexicon.soarleander.1", soarleanderRecipe)
BotaniaAPI.internalHandler.runeRecipePage("botania.lexicon.soarleander.1", new RecipeRuneAltar(
soarleander, 8000, ModUtils.getFlower("gourmaryllis"),
new ItemStack(Items.CHICKEN), new ItemStack(Items.CHICKEN),
new ItemStack(Items.CHICKEN), new ItemStack(Items.CHICKEN),
new ItemStack(Items.CHICKEN), new ItemStack(Items.CHICKEN),
new ItemStack(Items.CHICKEN), new ItemStack(Items.CHICKEN)
))
);
SubTileSoarleander.lexicon.setIcon(soarleander);
}
if (ModConfig.Compats.botania.infinitato) {
BlockInfinitato.lexiconEntry = new BotaniaLexiconEntry("infinitato", BotaniaAPI.categoryMisc);
BlockInfinitato.lexiconEntry.setLexiconPages(
BotaniaAPI.internalHandler.textPage("botania.lexicon.infinitato.0")
).setIcon(new ItemStack(infinitato));
}
}

@SideOnly(Side.CLIENT)
Expand All @@ -80,6 +102,10 @@ public static void initModels() {
if (ModConfig.Compats.botania.soarleander) {
BotaniaAPIClient.registerSubtileModel(SubTileSoarleander.class, new ModelResourceLocation(AvaritiaTweaks.MODID + ":soarleander"));
}
if (ModConfig.Compats.botania.infinitato) {
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(infinitato), 0, new ModelResourceLocation(infinitato.getRegistryName(), "facing=south"));
ClientRegistry.bindTileEntitySpecialRenderer(TileInfinitato.class, new RenderTileInfinitato());
}
}

public static void initRecipes() {
Expand All @@ -92,7 +118,8 @@ public static void initRecipes() {
GameRegistry.addShapelessRecipe(ModUtils.getStackFromName("botania:manaResource", 9, 14), new ItemStack(gaiaBlock));
}
if (ModConfig.Compats.botania.asgardandelion) {
ExtremeCraftingManager.getInstance().addRecipe(asgardandelion,
ExtremeCraftingManager.getInstance().addRecipe(
asgardandelion,
" III ",
" IIIII ",
" IIXII ",
Expand All @@ -109,14 +136,31 @@ public static void initRecipes() {
);
}
if (ModConfig.Compats.botania.soarleander) {
soarleanderRecipe = BotaniaAPI.registerRuneAltarRecipe(
BotaniaAPI.registerRuneAltarRecipe(
soarleander, 8000, ModUtils.getFlower("gourmaryllis"),
new ItemStack(Items.CHICKEN), new ItemStack(Items.CHICKEN),
new ItemStack(Items.CHICKEN), new ItemStack(Items.CHICKEN),
new ItemStack(Items.CHICKEN), new ItemStack(Items.CHICKEN),
new ItemStack(Items.CHICKEN), new ItemStack(Items.CHICKEN)
);
}
if (ModConfig.Compats.botania.infinitato) {
ExtremeCraftingManager.getInstance().addRecipe(
new ItemStack(infinitato),
"IIIIIIIII",
"IIIIIIIII",
"IIISISIII",
"IIIIIIIII",
"IISIXISII",
"IIISSSIII",
"IIIIIIIII",
"IIIIIIIII",
"IIIIIIIII",
'I', ModUtils.getStackFromName("botania:tinyPotato", 1, 0),
'X', new ItemStack(ModItems.resource, 1, 5),
'S', new ItemStack(Items.DIAMOND)
);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public String getSubtitle(){

@Override
public String getUnlocalizedName() {
return "avaritia.lexicon." + super.getUnlocalizedName();
return "botania.lexicon." + super.getUnlocalizedName();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
package jackyy.avaritiatweaks.compat.botania.block;

import jackyy.avaritiatweaks.AvaritiaTweaks;
import jackyy.avaritiatweaks.compat.botania.tile.TileInfinitato;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.common.core.helper.InventoryHelper;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;

public class BlockInfinitato extends BlockContainer implements ILexiconable {

private static float f = 1F / 16F * 4F;
private static final AxisAlignedBB AABB = new AxisAlignedBB(f, 0, f, 1F - f, f*3, 1F - f);
public static LexiconEntry lexiconEntry;

public BlockInfinitato() {
super(Material.CLOTH);
setRegistryName("infinitato");
setUnlocalizedName(AvaritiaTweaks.MODID + ".infinitato");
setHardness(0.25F);
setCreativeTab(AvaritiaTweaks.TAB);
}

@Override @SuppressWarnings("deprecation")
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) {
return AABB;
}

@Override
public BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BotaniaStateProps.CARDINALS);
}

@Override
public int getMetaFromState(IBlockState state) {
switch(state.getValue(BotaniaStateProps.CARDINALS)) {
case NORTH:
return 0;
case WEST:
return 3;
case EAST:
return 1;
case SOUTH:
default:
return 2;
}
}

@Override @SuppressWarnings("deprecation")
public IBlockState getStateFromMeta(int meta) {
EnumFacing side;
switch(meta) {
case 0:
side = EnumFacing.NORTH;
break;
case 1:
side = EnumFacing.EAST;
break;
case 2:
default:
side = EnumFacing.SOUTH;
break;
case 3:
side = EnumFacing.WEST;
}
return this.getDefaultState().withProperty(BotaniaStateProps.CARDINALS, side);
}

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing facing, float hitX, float hitY, float hitZ) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileInfinitato) {
((TileInfinitato) tile).interact(player, hand, stack, facing);
world.spawnParticle(EnumParticleTypes.HEART, (double)pos.getX() + AABB.minX + Math.random() * (AABB.maxX - AABB.minX), (double)pos.getY() + AABB.maxY, (double)pos.getZ() + AABB.minZ + Math.random() * (AABB.maxZ - AABB.minZ), 0.0D, 0.0D, 0.0D);
world.spawnParticle(EnumParticleTypes.HEART, (double)pos.getX() + AABB.minX + Math.random() * (AABB.maxX - AABB.minX), (double)pos.getY() + AABB.maxY, (double)pos.getZ() + AABB.minZ + Math.random() * (AABB.maxZ - AABB.minZ), 0.0D, 0.0D, 0.0D);
world.spawnParticle(EnumParticleTypes.HEART, (double)pos.getX() + AABB.minX + Math.random() * (AABB.maxX - AABB.minX), (double)pos.getY() + AABB.maxY, (double)pos.getZ() + AABB.minZ + Math.random() * (AABB.maxZ - AABB.minZ), 0.0D, 0.0D, 0.0D);
}
return true;
}

@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entity, ItemStack stack) {
world.setBlockState(pos, state.withProperty(BotaniaStateProps.CARDINALS, entity.getHorizontalFacing().getOpposite()));
if (stack.hasDisplayName()) {
TileEntity tile = world.getTileEntity(pos);
if (tile != null) {
((TileInfinitato)tile).name = stack.getDisplayName();
}
}
}

@Override
public boolean removedByPlayer(@Nonnull IBlockState state, World world, @Nonnull BlockPos pos, @Nonnull EntityPlayer player, boolean willHarvest) {
if (willHarvest) {
onBlockHarvested(world, pos, state, player);
return true;
} else {
return super.removedByPlayer(state, world, pos, player, willHarvest);
}
}

@Override
public void harvestBlock(@Nonnull World world, EntityPlayer player, @Nonnull BlockPos pos, @Nonnull IBlockState state, TileEntity te, ItemStack stack) {
super.harvestBlock(world, player, pos, state, te, stack);
world.setBlockToAir(pos);
}

@Override
public void breakBlock(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state) {
TileInfinitato inv = (TileInfinitato)world.getTileEntity(pos);
InventoryHelper.dropInventory(inv, world, state, pos);
super.breakBlock(world, pos, state);
}

@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, @Nonnull IBlockState state, int fortune) {
ArrayList<ItemStack> list = new ArrayList<>();
TileEntity tile = world.getTileEntity(pos);
if (tile != null) {
ItemStack stack = new ItemStack(this);
String name = ((TileInfinitato)tile).name;
if (!name.isEmpty()) {
stack.setStackDisplayName(name);
}
list.add(stack);
}
return list;
}

@Override @SuppressWarnings("deprecation")
public boolean isOpaqueCube(IBlockState state) {
return false;
}

@Override @SuppressWarnings("deprecation")
public boolean isFullCube(IBlockState state) {
return false;
}

@Override @SuppressWarnings("deprecation")
public boolean isNormalCube(IBlockState state) {
return false;
}

@Override
public EnumBlockRenderType getRenderType(IBlockState state) {
return EnumBlockRenderType.ENTITYBLOCK_ANIMATED;
}

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

@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileInfinitato();
}

@Override
public LexiconEntry getEntry(World world, BlockPos blockPos, EntityPlayer entityPlayer, ItemStack itemStack) {
return lexiconEntry;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package jackyy.avaritiatweaks.compat.botania.render;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;

public class ModelInfinitato extends ModelBase {

private ModelRenderer potato;

public ModelInfinitato() {
textureWidth = 64;
textureHeight = 32;
potato = new ModelRenderer(this, 0, 0);
potato.addBox(0F, 0F, 0F, 8, 12, 8);
potato.setRotationPoint(-4F, 12F, -4F);
potato.setTextureSize(64, 32);
}

public void render() {
potato.render(1F / 16F);
}

}
Loading

0 comments on commit 9820de4

Please sign in to comment.