diff options
| author | Jason Mitchell <mitchej@gmail.com> | 2023-01-28 19:03:53 -0800 |
|---|---|---|
| committer | Jason Mitchell <mitchej@gmail.com> | 2023-01-28 19:03:53 -0800 |
| commit | f51616bda220887fdd45c4bc951ff59e3398213a (patch) | |
| tree | 35fdbb15b4c7ea0282773a388eff517a1d09d941 /src/main/java/kubatech/loaders/block | |
| parent | 11216d666cbc30fc1e1dfc84e1e0c2f4252b1fc2 (diff) | |
| download | GT5-Unofficial-f51616bda220887fdd45c4bc951ff59e3398213a.tar.gz GT5-Unofficial-f51616bda220887fdd45c4bc951ff59e3398213a.tar.bz2 GT5-Unofficial-f51616bda220887fdd45c4bc951ff59e3398213a.zip | |
[ci skip] spotlessApply with the new settings
Diffstat (limited to 'src/main/java/kubatech/loaders/block')
5 files changed, 79 insertions, 125 deletions
diff --git a/src/main/java/kubatech/loaders/block/BlockProxy.java b/src/main/java/kubatech/loaders/block/BlockProxy.java index a12acc4de7..4ce6aa820d 100644 --- a/src/main/java/kubatech/loaders/block/BlockProxy.java +++ b/src/main/java/kubatech/loaders/block/BlockProxy.java @@ -1,29 +1,21 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders.block; import static kubatech.loaders.block.KubaBlock.defaultTileEntityUI; -import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; import java.util.List; + import kubatech.Tags; + import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; @@ -34,6 +26,8 @@ import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; + public class BlockProxy { private final String unlocalizedName; diff --git a/src/main/java/kubatech/loaders/block/IProxyTileEntityProvider.java b/src/main/java/kubatech/loaders/block/IProxyTileEntityProvider.java index b2a94c09b7..f39887a9ef 100644 --- a/src/main/java/kubatech/loaders/block/IProxyTileEntityProvider.java +++ b/src/main/java/kubatech/loaders/block/IProxyTileEntityProvider.java @@ -4,5 +4,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public interface IProxyTileEntityProvider { + TileEntity createTileEntity(World world); } diff --git a/src/main/java/kubatech/loaders/block/KubaBlock.java b/src/main/java/kubatech/loaders/block/KubaBlock.java index abf1e91dd7..831757f332 100644 --- a/src/main/java/kubatech/loaders/block/KubaBlock.java +++ b/src/main/java/kubatech/loaders/block/KubaBlock.java @@ -1,39 +1,24 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders.block; import static kubatech.kubatech.KT; -import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; -import com.gtnewhorizons.modularui.api.screen.ModularUIContext; -import com.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.api.screen.UIBuildContext; -import com.gtnewhorizons.modularui.common.builder.UIBuilder; -import com.gtnewhorizons.modularui.common.builder.UIInfo; -import com.gtnewhorizons.modularui.common.internal.wrapper.ModularGui; -import com.gtnewhorizons.modularui.common.internal.wrapper.ModularUIContainer; import java.lang.ref.WeakReference; import java.util.HashMap; import java.util.List; import java.util.function.Function; + import kubatech.loaders.BlockLoader; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -47,32 +32,38 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; +import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; +import com.gtnewhorizons.modularui.api.screen.ModularUIContext; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.builder.UIBuilder; +import com.gtnewhorizons.modularui.common.builder.UIInfo; +import com.gtnewhorizons.modularui.common.internal.wrapper.ModularGui; +import com.gtnewhorizons.modularui.common.internal.wrapper.ModularUIContainer; + public class KubaBlock extends Block { - public static final Function<IModularUIContainerCreator, UIInfo<?, ?>> TileEntityUIFactory = - containerConstructor -> UIBuilder.of() - .container((player, world, x, y, z) -> { - TileEntity te = world.getTileEntity(x, y, z); - if (te instanceof ITileWithModularUI) { - UIBuildContext buildContext = new UIBuildContext(player); - ModularWindow window = ((ITileWithModularUI) te).createWindow(buildContext); - return containerConstructor.createUIContainer( - new ModularUIContext(buildContext, te::markDirty), window); - } - return null; - }) - .gui(((player, world, x, y, z) -> { - if (!world.isRemote) return null; - TileEntity te = world.getTileEntity(x, y, z); - if (te instanceof ITileWithModularUI) { - UIBuildContext buildContext = new UIBuildContext(player); - ModularWindow window = ((ITileWithModularUI) te).createWindow(buildContext); - return new ModularGui(containerConstructor.createUIContainer( - new ModularUIContext(buildContext, null), window)); - } - return null; - })) - .build(); + public static final Function<IModularUIContainerCreator, UIInfo<?, ?>> TileEntityUIFactory = containerConstructor -> UIBuilder + .of().container((player, world, x, y, z) -> { + TileEntity te = world.getTileEntity(x, y, z); + if (te instanceof ITileWithModularUI) { + UIBuildContext buildContext = new UIBuildContext(player); + ModularWindow window = ((ITileWithModularUI) te).createWindow(buildContext); + return containerConstructor + .createUIContainer(new ModularUIContext(buildContext, te::markDirty), window); + } + return null; + }).gui(((player, world, x, y, z) -> { + if (!world.isRemote) return null; + TileEntity te = world.getTileEntity(x, y, z); + if (te instanceof ITileWithModularUI) { + UIBuildContext buildContext = new UIBuildContext(player); + ModularWindow window = ((ITileWithModularUI) te).createWindow(buildContext); + return new ModularGui( + containerConstructor.createUIContainer(new ModularUIContext(buildContext, null), window)); + } + return null; + })).build(); public static final UIInfo<?, ?> defaultTileEntityUI = TileEntityUIFactory.apply(ModularUIContainer::new); @@ -137,36 +128,22 @@ public class KubaBlock extends Block { } @Override - public boolean onBlockActivated( - World p_149727_1_, - int p_149727_2_, - int p_149727_3_, - int p_149727_4_, - EntityPlayer p_149727_5_, - int p_149727_6_, - float p_149727_7_, - float p_149727_8_, - float p_149727_9_) { + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, + EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { return getBlock(p_149727_1_.getBlockMetadata(p_149727_2_, p_149727_3_, p_149727_4_)) .onActivated(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_, p_149727_5_); } @Override - public void onBlockPlacedBy( - World p_149689_1_, - int p_149689_2_, - int p_149689_3_, - int p_149689_4_, - EntityLivingBase p_149689_5_, - ItemStack p_149689_6_) { + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, + EntityLivingBase p_149689_5_, ItemStack p_149689_6_) { getBlock(p_149689_6_.getItemDamage()) .onBlockPlaced(p_149689_1_, p_149689_2_, p_149689_3_, p_149689_4_, p_149689_5_, p_149689_6_); } @Override public float getBlockHardness(World p_149712_1_, int p_149712_2_, int p_149712_3_, int p_149712_4_) { - return getBlock(p_149712_1_.getBlockMetadata(p_149712_2_, p_149712_3_, p_149712_4_)) - .getHardness(); + return getBlock(p_149712_1_.getBlockMetadata(p_149712_2_, p_149712_3_, p_149712_4_)).getHardness(); } @Override @@ -182,25 +159,20 @@ public class KubaBlock extends Block { } @Override - public float getExplosionResistance( - Entity par1Entity, - World world, - int x, - int y, - int z, - double explosionX, - double explosionY, - double explosionZ) { + public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, + double explosionY, double explosionZ) { return getBlock(world.getBlockMetadata(x, y, z)).getResistance(); } @FunctionalInterface public interface IModularUIContainerCreator { + ModularUIContainer createUIContainer(ModularUIContext context, ModularWindow mainWindow); } @FunctionalInterface public interface IModularUIProvider { + UIInfo<?, ?> getUI(); } } diff --git a/src/main/java/kubatech/loaders/block/KubaItemBlock.java b/src/main/java/kubatech/loaders/block/KubaItemBlock.java index 1a9d057cd9..64f3124314 100644 --- a/src/main/java/kubatech/loaders/block/KubaItemBlock.java +++ b/src/main/java/kubatech/loaders/block/KubaItemBlock.java @@ -1,26 +1,19 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders.block; import java.util.List; + import kubatech.kubatech; + import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -28,6 +21,7 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; public class KubaItemBlock extends ItemBlock { + public KubaItemBlock(Block p_i45328_1_) { super(p_i45328_1_); setHasSubtypes(true); diff --git a/src/main/java/kubatech/loaders/block/blocks/TeaAcceptor.java b/src/main/java/kubatech/loaders/block/blocks/TeaAcceptor.java index 21d1e452f7..2f4f36db53 100644 --- a/src/main/java/kubatech/loaders/block/blocks/TeaAcceptor.java +++ b/src/main/java/kubatech/loaders/block/blocks/TeaAcceptor.java @@ -1,28 +1,21 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders.block.blocks; import java.util.List; + import kubatech.loaders.block.BlockProxy; import kubatech.loaders.block.IProxyTileEntityProvider; import kubatech.tileentity.TeaAcceptorTile; + import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; |
