Skip to content

Commit

Permalink
Merged LS repo after review ignoring assets, hopefully
Browse files Browse the repository at this point in the history
  • Loading branch information
DisasterMoo committed Jun 13, 2019
1 parent 0feffbe commit 8ff1e33
Show file tree
Hide file tree
Showing 52 changed files with 1,526 additions and 320 deletions.
40 changes: 40 additions & 0 deletions src/main/java/net/dries007/tfc/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@

package net.dries007.tfc;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;

import net.dries007.tfc.util.json.LowercaseEnumTypeAdapterFactory;
import net.dries007.tfc.util.json.ResourceLocationJson;
import net.dries007.tfc.util.json.VeinTypeJson;
import net.dries007.tfc.world.classic.worldgen.vein.VeinType;

import static net.minecraft.util.EnumFacing.*;
import static net.minecraft.util.EnumFacing.WEST;

public final class Constants
{
public static final Gson GSON = new GsonBuilder().disableHtmlEscaping()
Expand All @@ -27,4 +33,38 @@ public final class Constants

public static final Random RNG = new Random();

/**
* Used by horizontal rotatable blocks to search for a valid rotation in a given space,
* starting from a preferred rotation(like the direction a player is looking upon placing it)
* usage: facingPriorityLists.get(preferredFacing.getHorizontalIndex())
*/
public static final List<List<EnumFacing>> facingPriorityLists = new ArrayList<>(4);

static
{
List<EnumFacing> list = new ArrayList<>(4);
list.add(SOUTH);
list.add(WEST);
list.add(EAST);
list.add(NORTH);
facingPriorityLists.add(list);
list = new ArrayList<>(4);
list.add(WEST);
list.add(NORTH);
list.add(SOUTH);
list.add(EAST);
facingPriorityLists.add(list);
list = new ArrayList<>(4);
list.add(NORTH);
list.add(EAST);
list.add(WEST);
list.add(SOUTH);
facingPriorityLists.add(list);
list = new ArrayList<>(4);
list.add(EAST);
list.add(SOUTH);
list.add(NORTH);
list.add(WEST);
facingPriorityLists.add(list);
}
}
6 changes: 5 additions & 1 deletion src/main/java/net/dries007/tfc/api/types/Metal.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public class Metal extends IForgeRegistryEntry.Impl<Metal>
{
@GameRegistry.ObjectHolder(MOD_ID + ":unknown")
public static final Metal UNKNOWN = Helpers.getNull();
@GameRegistry.ObjectHolder("tfc:wrought_iron")
public static final Metal WROUGHT_IRON = Helpers.getNull();
@GameRegistry.ObjectHolder("tfc:pig_iron")
public static final Metal PIG_IRON = Helpers.getNull();

private final Tier tier;
private final float specificHeat;
Expand Down Expand Up @@ -296,4 +300,4 @@ public String[] getPattern()
return pattern;
}
}
}
}
11 changes: 11 additions & 0 deletions src/main/java/net/dries007/tfc/api/types/Ore.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraftforge.registries.IForgeRegistryEntry;

import net.dries007.tfc.api.registries.TFCRegistries;
import net.dries007.tfc.util.functionalinterfaces.OreBlockQuantity;

/**
* todo: document API
Expand All @@ -21,11 +22,13 @@ public class Ore extends IForgeRegistryEntry.Impl<Ore>
{
private final boolean graded;
private final Metal metal;
public final OreBlockQuantity quantity;

public Ore(ResourceLocation name, @Nullable Metal metal)
{
this.graded = (metal != null);
this.metal = metal;
quantity = null;
setRegistryName(name);
}

Expand All @@ -39,6 +42,14 @@ public Ore(ResourceLocation name)
this(name, (Metal) null);
}

public Ore(ResourceLocation name, OreBlockQuantity quantity)
{
this.graded = false;
this.metal = null;
this.quantity = quantity;
setRegistryName(name);
}

public boolean isGraded()
{
return graded;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/dries007/tfc/api/util/IMetalObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import net.dries007.tfc.util.Helpers;

/*
* Must be on Item or Block (with ItemBlock, i.e. do not implement on blocks that have a seperate item block)
* Must be on Item or Block (with ItemBlock, i.e. do not implement on blocks that have a separate item block)
*/
public interface IMetalObject
{
Expand All @@ -43,7 +43,7 @@ default void addMetalInfo(ItemStack stack, List<String> text)
}

/**
* @param stack the item stack
* @param stack the item stack. This can assume that it is of the right item type and do casts without checking
* @return the metal of the stack
*/
@Nullable
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/net/dries007/tfc/client/TFCGuiHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public Container getServerGuiElement(int ID, EntityPlayer player, World world, i
case SKILLS:
case NUTRITION:
return new ContainerSimple(player.inventory);
case BLAST_FURNACE:
return new ContainerBlastFurnace(player.inventory, Helpers.getTE(world, pos, TEBlastFurnace.class));
default:
return null;
}
Expand Down Expand Up @@ -145,6 +147,8 @@ public Object getClientGuiElement(int ID, EntityPlayer player, World world, int
return new GuiNutrition(container, player.inventory);
case SKILLS:
return new GuiSkills(container, player.inventory);
case BLAST_FURNACE:
return new GuiBlastFurnace(container, player.inventory, Helpers.getTE(world, pos, TEBlastFurnace.class));
default:
return null;
}
Expand All @@ -170,6 +174,7 @@ public enum Type
NUTRITION,
SKILLS,
INVENTORY, // This is special, it is used by GuiButtonPlayerInventoryTab to signal to open the vanilla inventory
BLAST_FURNACE,
NULL; // This is special, it is a non-null null.

private static Type[] values = values();
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/net/dries007/tfc/client/gui/GuiBlastFurnace.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package net.dries007.tfc.client.gui;

import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import net.dries007.tfc.objects.te.TEBlastFurnace;

import static net.dries007.tfc.api.util.TFCConstants.MOD_ID;

@SideOnly(Side.CLIENT)
public class GuiBlastFurnace extends GuiContainerTE<TEBlastFurnace>
{
private static final ResourceLocation BLAST_FURNACE_BACKGROUND = new ResourceLocation(MOD_ID, "textures/gui/blast_furnace.png");

public GuiBlastFurnace(Container container, InventoryPlayer playerInv, TEBlastFurnace tile)
{
super(container, playerInv, tile, BLAST_FURNACE_BACKGROUND);
}

@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
{
drawSimpleBackground();

// todo: ore + charcoal indicators
// todo: temperature indicator
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
@SideOnly(Side.CLIENT)
public class TESRIngotPile extends TileEntitySpecialRenderer<TEIngotPile>
{
private ModelIngotPile model = new ModelIngotPile();

public TESRIngotPile()
{
}
private final ModelIngotPile model = new ModelIngotPile();

@Override
public void render(TEIngotPile te, double x, double y, double z, float partialTicks, int destroyStage, float alpha)
Expand All @@ -35,7 +31,8 @@ public void render(TEIngotPile te, double x, double y, double z, float partialTi

Metal metal = te.getMetal();
int count = te.getCount();
this.bindTexture(new ResourceLocation(MOD_ID, "textures/blocks/metal/" + metal.getRegistryName().getPath() + ".png"));
//noinspection ConstantConditions
bindTexture(new ResourceLocation(MOD_ID, "textures/blocks/metal/" + metal.getRegistryName().getPath() + ".png"));
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@
import net.dries007.tfc.objects.items.ItemsTFC;
import net.dries007.tfc.objects.te.TECharcoalForge;
import net.dries007.tfc.util.Helpers;

import static net.dries007.tfc.objects.blocks.devices.BlockCharcoalForge.LIT;
import net.dries007.tfc.util.ILightableBlock;

@ParametersAreNonnullByDefault
public class BlockCharcoalPile extends Block
public class BlockCharcoalPile extends Block implements ILightableBlock
{
public static final PropertyInteger LAYERS = PropertyInteger.create("type", 1, 8);
private static final AxisAlignedBB[] PILE_AABB = new AxisAlignedBB[] {
Expand Down Expand Up @@ -171,13 +170,13 @@ public int damageDropped(IBlockState state)
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (!world.isRemote)
{
ItemStack stack = player.getHeldItem(hand);
ItemStack stack = player.getHeldItem(hand);

if (stack.getItem() == ItemsTFC.FIRESTARTER || stack.getItem() == Items.FLINT_AND_STEEL)
if (stack.getItem() == ItemsTFC.FIRESTARTER || stack.getItem() == Items.FLINT_AND_STEEL)
{
if (state.getValue(LAYERS) == 7)
{
if (state.getValue(LAYERS) == 7)
if (!world.isRemote)
{
world.setBlockState(pos, BlocksTFC.CHARCOAL_FORGE.getDefaultState().withProperty(LIT, true));
TECharcoalForge te = Helpers.getTE(world, pos, TECharcoalForge.class);
Expand All @@ -186,10 +185,10 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En
te.onCreate();
}
}
return true;
}
return false;
}
return true;
return false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import net.dries007.tfc.objects.fluids.FluidsTFC;

/**
* todo: The behaviour of this needs to be adjusted/debugged so it actually fills up blocks and doesn't live 1 level high residue.
* todo: The behaviour of this needs to be adjusted/debugged so it actually fills up blocks and doesn't live 1 level high residue. Also fix debug world crashing!
*/
public class BlockFluidFiniteTFC extends BlockFluidFinite
{
Expand Down
Loading

0 comments on commit 8ff1e33

Please sign in to comment.