Skip to content

Commit

Permalink
More code cleanup. And lots of Intellij auto-formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
alcatrazEscapee committed Mar 6, 2019
1 parent f69e4c0 commit 5efc6c0
Show file tree
Hide file tree
Showing 57 changed files with 860 additions and 897 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/dries007/tfc/CommonEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public static void onBlockHarvestDrops(BlockEvent.HarvestDropsEvent event)
* Notes:
* 1) `onBlockActivate` doesn't get called when the player is sneaking, unless doesSneakBypassUse returns true.
* 2) This event handler is fired first with the main hand as event.getStack()
* If nothing happens (as per vanilla behavior, even if this event causes something to happen),
* The event will fire AGAIN with the offhand and offhand stack.
* If nothing happens (as per vanilla behavior, even if this event causes something to happen),
* The event will fire AGAIN with the offhand and offhand stack.
*/
@SubscribeEvent
public static void onRightClickBlock(PlayerInteractEvent.RightClickBlock event)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ public interface ISmallVesselHandler extends IItemHandler, IFluidHandler, INBTSe
{

/**
* This sets the fluid mode. When fluid is empty, it defaults to item mode
* This gets the fluid mode, including liquid temperature status
*
* @param fluidMode true = fluids, false = items
* @return INVENTORY = items, LIQUID = fluids molten or solid based on temperature
*/
void setFluidMode(boolean fluidMode);
Mode getFluidMode();

/**
* This gets the fluid mode, including liquid temperature status
* This sets the fluid mode. When fluid is empty, it defaults to item mode
*
* @return INVENTORY = items, LIQUID = fluids molten or solid based on temperature
* @param fluidMode true = fluids, false = items
*/
Mode getFluidMode();
void setFluidMode(boolean fluidMode);

enum Mode
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ public void reset()
work = 0;
}

@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing)
{
return capability == CapabilityForgeable.FORGEABLE_CAPABILITY || super.hasCapability(capability, facing);
}

@SuppressWarnings("unchecked")
@Nullable
@Override
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing)
{
return hasCapability(capability, facing) ? (T) this : null;
}

@Override
@Nonnull
public NBTTagCompound serializeNBT()
Expand Down Expand Up @@ -113,18 +127,4 @@ public void deserializeNBT(@Nullable NBTTagCompound nbt)
}
super.deserializeNBT(nbt);
}

@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing)
{
return capability == CapabilityForgeable.FORGEABLE_CAPABILITY || super.hasCapability(capability, facing);
}

@SuppressWarnings("unchecked")
@Nullable
@Override
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing)
{
return hasCapability(capability, facing) ? (T) this : null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ default void setRecipe(@Nullable AnvilRecipe recipe)

/**
* Adds a step to the object, shuffling the last three steps down
*
* @param step The step to add. In general this should not be null, although it is perfectly valid for it to be
*/
void addStep(@Nullable ForgeStep step);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ public interface IItemHeat extends INBTSerializable<NBTTagCompound>
float getTemperature();

/**
* Gets the Heat capacity. (A measure of how fast this items heats up or cools down)
* Implementation is left up to the heating object. (See TEFirePit for example)
* Sets the temperature. Used for anything that modifies the temperature.
*
* @return the heat capacity. Typically 0 - 1, can be outside this range, must be non-negative
* @param temperature the temperature to set.
*/
float getHeatCapacity();
void setTemperature(float temperature);

/**
* Sets the temperature. Used for anything that modifies the temperature.
* Gets the Heat capacity. (A measure of how fast this items heats up or cools down)
* Implementation is left up to the heating object. (See TEFirePit for example)
*
* @param temperature the temperature to set.
* @return the heat capacity. Typically 0 - 1, can be outside this range, must be non-negative
*/
void setTemperature(float temperature);
float getHeatCapacity();

/**
* Gets the melting point of the item.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class ItemHeatHandler implements ICapabilitySerializable<NBTTagCompound>,
*
* @param nbt The NBT of the itemstack. (Provided in Item#initCapabilities())
* @param heatCapacity The heat capacity
* @param meltTemp The melting point
* @param meltTemp The melting point
*/
public ItemHeatHandler(@Nullable NBTTagCompound nbt, float heatCapacity, float meltTemp)
{
Expand All @@ -62,6 +62,7 @@ public float getTemperature()

/**
* Update the temperature, and save the timestamp of when it was updated
*
* @param temperature the temperature to set. Between 0 - 1600
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@

public final class CapabilityItemSize
{
private static final ResourceLocation ID = new ResourceLocation(TFCConstants.MOD_ID, "item_size");

@CapabilityInject(IItemSize.class)
public static final Capability<IItemSize> ITEM_SIZE_CAPABILITY = Helpers.getNull();
private static final ResourceLocation ID = new ResourceLocation(TFCConstants.MOD_ID, "item_size");

public static void preInit()
{
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/net/dries007/tfc/api/recipes/AnvilRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@
@ParametersAreNonnullByDefault
public class AnvilRecipe extends IForgeRegistryEntry.Impl<AnvilRecipe>
{
private static long SEED = 0;

private static final Random RNG = new Random();
private static long SEED = 0;

@Nonnull
public static List<AnvilRecipe> getAllFor(ItemStack stack)
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/net/dries007/tfc/api/types/Plant.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/*
*
* * Work under Copyright. Licensed under the EUPL.
* * See the project README.md and LICENSE.txt for more information.
*
* Work under Copyright. Licensed under the EUPL.
* See the project README.md and LICENSE.txt for more information.
*/

package net.dries007.tfc.api.types;
Expand Down Expand Up @@ -105,7 +103,7 @@ public boolean isValidFloatingWaterDepth(World world, BlockPos pos, IBlockState
{
depthCounter++;
}
return (maxDepth > 0) ? depthCounter <= maxDepth + 1 : false;
return (maxDepth > 0) && depthCounter <= maxDepth + 1;
}

public int getMinWaterDepth()
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/net/dries007/tfc/client/gui/GuiAnvilPlan.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@ protected void renderHoveredToolTip(int mouseX, int mouseY)
super.renderHoveredToolTip(mouseX, mouseY);
}

@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
{
GlStateManager.color(1, 1, 1, 1);
mc.getTextureManager().bindTexture(background);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
}

@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
Expand All @@ -100,6 +92,14 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}

@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
{
GlStateManager.color(1, 1, 1, 1);
mc.getTextureManager().bindTexture(background);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
}

@Override
protected void actionPerformed(GuiButton button) throws IOException
{
Expand Down
108 changes: 54 additions & 54 deletions src/main/java/net/dries007/tfc/client/gui/GuiCustomizeWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,51 +75,17 @@ protected void keyTyped(char typedChar, int keyCode)
}

@Override
public void setEntryValue(int id, boolean value)
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
switch (id)
{
case ID_FLAT_BEDROCK:
settings.flatBedrock = value;
break;
}
update();
super.mouseClicked(mouseX, mouseY, mouseButton);
list.mouseClicked(mouseX, mouseY, mouseButton);
}

@Override
public void setEntryValue(int id, float value)
protected void mouseReleased(int mouseX, int mouseY, int state)
{
switch (id)
{
case ID_SPAWN_FUZZ:
settings.spawnFuzz = Math.round(value);
break;

case ID_RAVINE_RARITY:
settings.ravineRarity = Math.round(value);
break;
case ID_RAVINE_HEIGHT:
settings.ravineHeight = Math.round(value);
break;
case ID_RAVINE_VARIABILITY:
settings.ravineVariability = Math.round(value);
break;

case ID_SURFACE_RAVINE_RARITY:
settings.surfaceRavineRarity = Math.round(value);
break;
case ID_SURFACE_RAVINE_HEIGHT:
settings.surfaceRavineHeight = Math.round(value);
break;
case ID_SURFACE_RAVINE_VARIABILITY:
settings.surfaceRavineVariability = Math.round(value);
break;

case ID_RIVER_RAVINE_RARITY:
settings.riverRavineRarity = Math.round(value);
break;
}
update();
super.mouseReleased(mouseX, mouseY, state);
list.mouseReleased(mouseX, mouseY, state);
}

@Override
Expand All @@ -146,20 +112,6 @@ protected void actionPerformed(GuiButton button) throws IOException
update();
}

@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
super.mouseClicked(mouseX, mouseY, mouseButton);
list.mouseClicked(mouseX, mouseY, mouseButton);
}

@Override
protected void mouseReleased(int mouseX, int mouseY, int state)
{
super.mouseReleased(mouseX, mouseY, state);
list.mouseReleased(mouseX, mouseY, state);
}

@Override
public void initGui()
{
Expand Down Expand Up @@ -199,6 +151,54 @@ public void handleMouseInput() throws IOException
this.list.handleMouseInput();
}

@Override
public void setEntryValue(int id, boolean value)
{
switch (id)
{
case ID_FLAT_BEDROCK:
settings.flatBedrock = value;
break;
}
update();
}

@Override
public void setEntryValue(int id, float value)
{
switch (id)
{
case ID_SPAWN_FUZZ:
settings.spawnFuzz = Math.round(value);
break;

case ID_RAVINE_RARITY:
settings.ravineRarity = Math.round(value);
break;
case ID_RAVINE_HEIGHT:
settings.ravineHeight = Math.round(value);
break;
case ID_RAVINE_VARIABILITY:
settings.ravineVariability = Math.round(value);
break;

case ID_SURFACE_RAVINE_RARITY:
settings.surfaceRavineRarity = Math.round(value);
break;
case ID_SURFACE_RAVINE_HEIGHT:
settings.surfaceRavineHeight = Math.round(value);
break;
case ID_SURFACE_RAVINE_VARIABILITY:
settings.surfaceRavineVariability = Math.round(value);
break;

case ID_RIVER_RAVINE_RARITY:
settings.riverRavineRarity = Math.round(value);
break;
}
update();
}

@Override
public void setEntryValue(int id, String value)
{
Expand Down
50 changes: 25 additions & 25 deletions src/main/java/net/dries007/tfc/client/gui/GuiKnapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,31 @@ public void initGui()
}
}

@Override
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick)
{
if (clickedMouseButton == 0)
{
for (GuiButton button : this.buttonList)
{
if (button instanceof GuiButtonKnapping && button.mousePressed(mc, mouseX, mouseY))
{
GuiScreenEvent.ActionPerformedEvent.Pre event = new GuiScreenEvent.ActionPerformedEvent.Pre(this, button, buttonList);
if (MinecraftForge.EVENT_BUS.post(event))
break;
else if (selectedButton == event.getButton())
continue;

selectedButton = event.getButton();
event.getButton().mousePressed(mc, mouseX, mouseY);
actionPerformed(event.getButton());

MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.ActionPerformedEvent.Post(this, event.getButton(), buttonList));
}
}
}
}

@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
{
Expand Down Expand Up @@ -73,29 +98,4 @@ protected void actionPerformed(GuiButton button)
button.playPressSound(mc.getSoundHandler());
}
}

@Override
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick)
{
if (clickedMouseButton == 0)
{
for (GuiButton button : this.buttonList)
{
if (button instanceof GuiButtonKnapping && button.mousePressed(mc, mouseX, mouseY))
{
GuiScreenEvent.ActionPerformedEvent.Pre event = new GuiScreenEvent.ActionPerformedEvent.Pre(this, button, buttonList);
if (MinecraftForge.EVENT_BUS.post(event))
break;
else if (selectedButton == event.getButton())
continue;

selectedButton = event.getButton();
event.getButton().mousePressed(mc, mouseX, mouseY);
actionPerformed(event.getButton());

MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.ActionPerformedEvent.Post(this, event.getButton(), buttonList));
}
}
}
}
}
Loading

0 comments on commit 5efc6c0

Please sign in to comment.