Code cleanup

This commit is contained in:
Shadowfacts 2017-07-01 19:27:50 -04:00
parent b97e44f816
commit 6f551660c7
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
11 changed files with 18 additions and 35 deletions

View File

@ -8,8 +8,6 @@ import net.minecraft.item.ItemStack
*/ */
object EHCreativeTab: CreativeTabs(MOD_ID) { object EHCreativeTab: CreativeTabs(MOD_ID) {
override fun getTabIconItem(): ItemStack { override fun getTabIconItem() = ItemStack(ExtraHoppers.blocks.woodenHopper)
return ItemStack(ExtraHoppers.blocks.woodenHopper)
}
} }

View File

@ -3,7 +3,6 @@ package net.shadowfacts.extrahoppers
import net.minecraft.block.Block import net.minecraft.block.Block
import net.minecraft.item.Item import net.minecraft.item.Item
import net.minecraftforge.client.event.ModelRegistryEvent import net.minecraftforge.client.event.ModelRegistryEvent
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.event.RegistryEvent import net.minecraftforge.event.RegistryEvent
import net.minecraftforge.fml.client.registry.ClientRegistry import net.minecraftforge.fml.client.registry.ClientRegistry
import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.Mod
@ -20,7 +19,6 @@ import net.shadowfacts.extrahoppers.block.fluid.TileEntityFluidHopper
import net.shadowfacts.extrahoppers.block.inverted.TileEntityInvertedHopper import net.shadowfacts.extrahoppers.block.inverted.TileEntityInvertedHopper
import net.shadowfacts.extrahoppers.block.wooden.TileEntityWoodenHopper import net.shadowfacts.extrahoppers.block.wooden.TileEntityWoodenHopper
import net.shadowfacts.extrahoppers.block.wooden_fluid.TileEntityWoodenFluidHopper import net.shadowfacts.extrahoppers.block.wooden_fluid.TileEntityWoodenFluidHopper
import net.shadowfacts.extrahoppers.event.ClientEventHandler
import net.shadowfacts.extrahoppers.gui.GUIHandler import net.shadowfacts.extrahoppers.gui.GUIHandler
/** /**
@ -45,8 +43,6 @@ object ExtraHoppers {
fun preInitClient(event: FMLPreInitializationEvent) { fun preInitClient(event: FMLPreInitializationEvent) {
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFluidHopper::class.java, TESRFluidHopper) ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFluidHopper::class.java, TESRFluidHopper)
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityWoodenFluidHopper::class.java, TESRFluidHopper) ClientRegistry.bindTileEntitySpecialRenderer(TileEntityWoodenFluidHopper::class.java, TESRFluidHopper)
MinecraftForge.EVENT_BUS.register(ClientEventHandler)
} }
@Mod.EventBusSubscriber @Mod.EventBusSubscriber

View File

@ -5,4 +5,4 @@ package net.shadowfacts.extrahoppers
*/ */
const val MOD_ID = "extrahoppers" const val MOD_ID = "extrahoppers"
const val NAME = "Extra Hoppers" const val NAME = "Extra Hoppers"
const val VERSION = "@VERSION@" const val VERSION = "2.0.0-a1"

View File

@ -21,9 +21,7 @@ abstract class BlockTE<out TE: BaseTileEntity>(name: String, material: Material
abstract override fun createTileEntity(world: World, state: IBlockState): TE abstract override fun createTileEntity(world: World, state: IBlockState): TE
override fun hasTileEntity(state: IBlockState): Boolean { override fun hasTileEntity(state: IBlockState) = true
return true
}
fun getTileEntity(world: IBlockAccess, pos: BlockPos): TE { fun getTileEntity(world: IBlockAccess, pos: BlockPos): TE {
return world.getTileEntity(pos) as TE return world.getTileEntity(pos) as TE

View File

@ -24,9 +24,7 @@ class BlockAdvancedHopper(inverted: Boolean): BlockHopperBase<TileEntityAdvanced
} }
@Deprecated("") @Deprecated("")
override fun hasComparatorInputOverride(state: IBlockState?): Boolean { override fun hasComparatorInputOverride(state: IBlockState) = true
return true
}
@Deprecated("") @Deprecated("")
override fun getComparatorInputOverride(state: IBlockState, world: World, pos: BlockPos): Int { override fun getComparatorInputOverride(state: IBlockState, world: World, pos: BlockPos): Int {

View File

@ -79,9 +79,10 @@ abstract class BlockHopperBase<out TE: BaseTileEntity>(val inverted: Boolean, va
} }
@Deprecated("") @Deprecated("")
override fun isOpaqueCube(state: IBlockState?): Boolean { override fun isOpaqueCube(state: IBlockState) = false
return false
} @Deprecated("")
override fun isFullCube(state: IBlockState?) = false
} }

View File

@ -25,9 +25,7 @@ class BlockInvertedHopper: BlockHopperBase<TileEntityInvertedHopper>(true, false
} }
@Deprecated("") @Deprecated("")
override fun hasComparatorInputOverride(state: IBlockState): Boolean { override fun hasComparatorInputOverride(state: IBlockState) = true
return true
}
@Deprecated("") @Deprecated("")
override fun getComparatorInputOverride(state: IBlockState, world: World, pos: BlockPos): Int { override fun getComparatorInputOverride(state: IBlockState, world: World, pos: BlockPos): Int {

View File

@ -4,15 +4,19 @@ import net.minecraft.client.resources.I18n
import net.minecraft.util.text.TextFormatting import net.minecraft.util.text.TextFormatting
import net.minecraftforge.event.entity.player.ItemTooltipEvent import net.minecraftforge.event.entity.player.ItemTooltipEvent
import net.minecraftforge.fluids.capability.CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY import net.minecraftforge.fluids.capability.CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY
import net.minecraftforge.fml.common.Mod
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.shadowfacts.extrahoppers.EHConfig import net.shadowfacts.extrahoppers.EHConfig
import net.shadowfacts.extrahoppers.MOD_ID
import net.shadowfacts.extrahoppers.gui.GUIHandler import net.shadowfacts.extrahoppers.gui.GUIHandler
/** /**
* @author shadowfacts * @author shadowfacts
*/ */
@Mod.EventBusSubscriber(modid = MOD_ID)
object ClientEventHandler { object ClientEventHandler {
@JvmStatic
@SubscribeEvent @SubscribeEvent
fun itemTooltip(event: ItemTooltipEvent) { fun itemTooltip(event: ItemTooltipEvent) {
if (GUIHandler.woodenFluidHopperOpen) { if (GUIHandler.woodenFluidHopperOpen) {

View File

@ -12,13 +12,9 @@ import net.shadowfacts.shadowmc.util.MouseButton
//TODO: move me to ShadowMC //TODO: move me to ShadowMC
class UIFilterButton(val callback: (UIFilterButton) -> Unit, id: String, vararg classes: String): UIButtonBase("", id, *classes) { class UIFilterButton(val callback: (UIFilterButton) -> Unit, id: String, vararg classes: String): UIButtonBase("", id, *classes) {
override fun getMinDimensions(): UIDimensions { override fun getMinDimensions() = preferredDimensions
return preferredDimensions
}
override fun getPreferredDimensions(): UIDimensions { override fun getPreferredDimensions() = UIDimensions(20, 20)
return UIDimensions(20, 20)
}
override fun handlePress(mouseX: Int, mouseY: Int, button: MouseButton?): Boolean { override fun handlePress(mouseX: Int, mouseY: Int, button: MouseButton?): Boolean {
callback(this) callback(this)

View File

@ -9,8 +9,6 @@ import net.shadowfacts.shadowmc.ui.element.UIFluidIndicator
*/ */
class UIFluidIndicator(tank: IFluidTank, id: String, vararg classes: String): UIFluidIndicator(tank, id, *classes) { class UIFluidIndicator(tank: IFluidTank, id: String, vararg classes: String): UIFluidIndicator(tank, id, *classes) {
override fun getPreferredDimensions(): UIDimensions { override fun getPreferredDimensions() = UIDimensions(20, 73)
return UIDimensions(20, 73)
}
} }

View File

@ -11,13 +11,9 @@ object NoOpFilter: Filter<Any>() {
override fun setFromStack(i: Int, stack: ItemStack) { override fun setFromStack(i: Int, stack: ItemStack) {
} }
override fun accepts(stack: Any): Boolean { override fun accepts(stack: Any) = true
return true
}
override fun writeToNBT(tag: NBTTagCompound): NBTTagCompound { override fun writeToNBT(tag: NBTTagCompound) = tag
return tag
}
override fun readFromNBT(tag: NBTTagCompound) { override fun readFromNBT(tag: NBTTagCompound) {
} }