From 335e121ff252625d49b93d58bc77ac1a8d7d4e7e Mon Sep 17 00:00:00 2001 From: canitzp Date: Mon, 7 Sep 2020 04:32:10 +0200 Subject: [PATCH] Optimize and updated Dependencies and fully added Tiny torch (#1343) * Dependency updates * Tiny torch implementation Co-authored-by: canitzp --- .gitignore | 12 +- build.gradle | 39 +++-- gradle/wrapper/gradle-wrapper.properties | 2 +- .../actuallyadditions/mod/block/AABlocks.java | 7 +- .../mod/block/TinyTorchBlock.java | 159 ++++++++++++++++++ src/main/resources/META-INF/mods.toml | 2 +- .../blockstates/tiny_torch.json | 9 + .../assets/actuallyadditions/lang/en_us.json | 3 +- .../models/block/tiny_torch_block.json} | 4 +- .../models/block/tiny_torch_wall_block.json} | 4 +- .../models/item/standard_item.json | 0 .../models/item/tiny_torch.json} | 2 +- .../textures/block/tiny_torch_block.png} | Bin .../loot_tables/blocks/tiny_torch.json | 19 +++ .../blockstates/block_tiny_torch.json | 9 - 15 files changed, 222 insertions(+), 49 deletions(-) create mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/block/TinyTorchBlock.java create mode 100644 src/main/resources/assets/actuallyadditions/blockstates/tiny_torch.json rename src/main/resources/{oldassets/actuallyadditions/models/block/block_tiny_torch.json => assets/actuallyadditions/models/block/tiny_torch_block.json} (88%) rename src/main/resources/{oldassets/actuallyadditions/models/block/block_tiny_torch_wall.json => assets/actuallyadditions/models/block/tiny_torch_wall_block.json} (90%) rename src/main/resources/{oldassets => assets}/actuallyadditions/models/item/standard_item.json (100%) rename src/main/resources/{oldassets/actuallyadditions/models/item/block_tiny_torch.json => assets/actuallyadditions/models/item/tiny_torch.json} (56%) rename src/main/resources/{oldassets/actuallyadditions/textures/blocks/block_tiny_torch.png => assets/actuallyadditions/textures/block/tiny_torch_block.png} (100%) create mode 100644 src/main/resources/data/actuallyadditions/loot_tables/blocks/tiny_torch.json delete mode 100644 src/main/resources/oldassets/actuallyadditions/blockstates/block_tiny_torch.json diff --git a/.gitignore b/.gitignore index 315181ae1..0cb358301 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,6 @@ /lib /classes /bin/ -/run/ *.classpath *.project @@ -19,12 +18,5 @@ *.launch .settings/org.eclipse.jdt.core.prefs *.prefs -/run/ -.DS_Store -src/.DS_Store -src/main/.DS_Store -src/main/java/.DS_Store -src/main/java/de/.DS_Store -src/main/java/de/ellpeck/.DS_Store -src/main/java/de/ellpeck/actuallyadditions/.DS_Store -src/main/java/de/ellpeck/actuallyadditions/mod/.DS_Store +/run/* +*.DS_Store \ No newline at end of file diff --git a/build.gradle b/build.gradle index 8df4d2b80..a6e2db02c 100644 --- a/build.gradle +++ b/build.gradle @@ -22,18 +22,18 @@ archivesBaseName = "ActuallyAdditions-1.14.4" sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' minecraft { - mappings channel: "snapshot", version: "20191107-1.14.3" - runs { + mappings channel: "stable", version: "58-1.14.4" + runs { client = { properties 'forge.logging.markers': '' properties 'forge.logging.console.level': 'debug' - workingDirectory project.file('run').canonicalPath + workingDirectory project.file('run/client') source sourceSets.main } server = { properties 'forge.logging.markers': '' properties 'forge.logging.console.level': 'debug' - workingDirectory project.file('run/server').canonicalPath + workingDirectory project.file('run/server') source sourceSets.main } data = { @@ -42,8 +42,8 @@ minecraft { mods { actuallyadditions { source sourceSets.main - } - } + } + } } } } @@ -52,27 +52,26 @@ repositories { maven { url "https://dvs1.progwml6.com/files/maven" } - maven { - url "https://tehnut.info/maven" - } + //maven { + // url "https://tehnut.info/maven" + //} } dependencies { - minecraft 'net.minecraftforge:forge:1.14.4-28.1.86' - compile fg.deobf('mezz.jei:jei-1.14.4:6.0.0.24') - compile fg.deobf('mcp.mobius.waila:Hwyla:1.10.6-B67_1.14.4') - compile fileTree(dir: 'libs', include: '*.jar') + minecraft 'net.minecraftforge:forge:1.14.4-28.2.0' + compile fg.deobf('mezz.jei:jei-1.14.4:6.0.1.30') + //compile fg.deobf('mcp.mobius.waila:Hwyla:1.10.6-B67_1.14.4') + //compile fileTree(dir: 'libs', include: '*.jar') } - jar { manifest { - attributes(["Specification-Title": "actuallyadditions", - "Specification-Vendor": "Ellpeck", - "Specification-Version": "24.0", - "Implementation-Title": project.name, - "Implementation-Version": "${version}", - "Implementation-Vendor" :"Ellpeck", + attributes(["Specification-Title" : "actuallyadditions", + "Specification-Vendor" : "Ellpeck", + "Specification-Version" : "24.0", + "Implementation-Title" : project.name, + "Implementation-Version" : "${version}", + "Implementation-Vendor" : "Ellpeck", "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")],) } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 949819d28..bd24854fe 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/block/AABlocks.java b/src/main/java/de/ellpeck/actuallyadditions/mod/block/AABlocks.java index aa8a5eb51..069b1f1c6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/block/AABlocks.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/block/AABlocks.java @@ -40,6 +40,7 @@ public class AABlocks { public static final ColoredLampBlock GREEN_LAMP = null; public static final ColoredLampBlock RED_LAMP = null; public static final ColoredLampBlock BLACK_LAMP = null; + public static final TinyTorchBlock TINY_TORCH = null; @SubscribeEvent public static void register(Register e) { @@ -65,7 +66,8 @@ public class AABlocks { new ColoredLampBlock(LampColor.BROWN).setRegistryName("brown_lamp"), new ColoredLampBlock(LampColor.GREEN).setRegistryName("green_lamp"), new ColoredLampBlock(LampColor.RED).setRegistryName("red_lamp"), - new ColoredLampBlock(LampColor.BLACK).setRegistryName("black_lamp") + new ColoredLampBlock(LampColor.BLACK).setRegistryName("black_lamp"), + new TinyTorchBlock() ); //Formatter::on } @@ -78,7 +80,8 @@ public class AABlocks { new BlockItem(BLACK_QUARTZ_BLOCK, new Item.Properties().group(ActuallyAdditions.GROUP)).setRegistryName(BLACK_QUARTZ_BLOCK.getRegistryName()), new BlockItem(CHISELED_BLACK_QUARTZ_BLOCK, new Item.Properties().group(ActuallyAdditions.GROUP)).setRegistryName(CHISELED_BLACK_QUARTZ_BLOCK.getRegistryName()), new BlockItem(BLACK_QUARTZ_PILLAR, new Item.Properties().group(ActuallyAdditions.GROUP)).setRegistryName(BLACK_QUARTZ_PILLAR.getRegistryName()), - new BlockItem(BLACK_QUARTZ_SLAB, new Item.Properties().group(ActuallyAdditions.GROUP)).setRegistryName(BLACK_QUARTZ_SLAB.getRegistryName()) + new BlockItem(BLACK_QUARTZ_SLAB, new Item.Properties().group(ActuallyAdditions.GROUP)).setRegistryName(BLACK_QUARTZ_SLAB.getRegistryName()), + new BlockItem(TINY_TORCH, new Item.Properties().group(ActuallyAdditions.GROUP)).setRegistryName(TINY_TORCH.getRegistryName()) ); //Formatter::on for (Block b : ColoredLampBlock.LAMPS.values()) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/block/TinyTorchBlock.java b/src/main/java/de/ellpeck/actuallyadditions/mod/block/TinyTorchBlock.java new file mode 100644 index 000000000..be309d731 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/block/TinyTorchBlock.java @@ -0,0 +1,159 @@ +package de.ellpeck.actuallyadditions.mod.block; + +import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.SoundType; +import net.minecraft.block.material.Material; +import net.minecraft.entity.item.ItemEntity; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.item.ItemStack; +import net.minecraft.particles.ParticleTypes; +import net.minecraft.state.DirectionProperty; +import net.minecraft.state.StateContainer; +import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.Direction; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.math.shapes.VoxelShapes; +import net.minecraft.world.IBlockReader; +import net.minecraft.world.IWorldReader; +import net.minecraft.world.World; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.Random; + +public class TinyTorchBlock extends Block { + + public static final DirectionProperty FACING_EXCEPT_DOWN = DirectionProperty.create("facing", direction -> direction != Direction.DOWN); + + private static final Properties PROPERTIES = Properties.create(Material.MISCELLANEOUS).hardnessAndResistance(0).lightValue(11).sound(SoundType.WOOD).tickRandomly(); + private static final VoxelShape STANDING_SHAPE = VoxelShapes.create(0.4375D, 0.0D, 0.4375D, 0.5625D, 0.3125D, 0.5625D); + private static final VoxelShape TORCH_NORTH_SHAPE = VoxelShapes.create(0.4375D, 0.25D, 0.8125D, 0.5625D, 0.5625D, 1.0D); + private static final VoxelShape TORCH_SOUTH_SHAPE = VoxelShapes.create(0.4375D, 0.25D, 0.0D, 0.5625D, 0.5625D, 0.1875D); + private static final VoxelShape TORCH_WEST_SHAPE = VoxelShapes.create(0.8125D, 0.25D, 0.4375D, 1.0D, 0.5625D, 0.5625D); + private static final VoxelShape TORCH_EAST_SHAPE = VoxelShapes.create(0.0D, 0.25D, 0.4375D, 0.1875D, 0.5625D, 0.5625D); + + public TinyTorchBlock(){ + super(PROPERTIES); + + this.setRegistryName(ActuallyAdditions.MODID, "tiny_torch"); + this.setDefaultState(this.getStateContainer().getBaseState().with(FACING_EXCEPT_DOWN, Direction.UP)); + } + + @Nonnull + @Override + public VoxelShape getShape(@Nonnull BlockState state, @Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nonnull ISelectionContext context){ + switch(state.get(FACING_EXCEPT_DOWN)){ + case EAST: + return TORCH_EAST_SHAPE; + case WEST: + return TORCH_WEST_SHAPE; + case SOUTH: + return TORCH_SOUTH_SHAPE; + case NORTH: + return TORCH_NORTH_SHAPE; + default: + return STANDING_SHAPE; + } + } + + @Nonnull + @Override + public VoxelShape getCollisionShape(@Nonnull BlockState state, @Nonnull IBlockReader worldIn, @Nonnull BlockPos pos, @Nonnull ISelectionContext context){ + return VoxelShapes.empty(); + } + + @Nonnull + @Override + public BlockRenderLayer getRenderLayer(){ + return BlockRenderLayer.CUTOUT; + } + + private boolean canPlaceAt(@Nonnull IWorldReader world, @Nonnull BlockPos pos, @Nonnull Direction direction){ + BlockPos blockpos = pos.offset(direction.getOpposite()); + return (direction.getAxis().isHorizontal() && hasSolidSide(world.getBlockState(blockpos), world, blockpos, direction)) || (direction.equals(Direction.UP) && hasSolidSideOnTop(world, blockpos)); + } + + @Override + public boolean isValidPosition(@Nonnull BlockState state, @Nonnull IWorldReader world, @Nonnull BlockPos pos){ + for(Direction direction : FACING_EXCEPT_DOWN.getAllowedValues()){ + if(this.canPlaceAt(world, pos, direction)){ + return true; + } + } + return false; + } + + @Nullable + @Override + public BlockState getStateForPlacement(@Nonnull BlockItemUseContext context){ + World world = context.getWorld(); + BlockPos pos = context.getPos(); + Direction placementDirection = context.getFace(); + if(this.canPlaceAt(world, pos, placementDirection)){ + return this.getDefaultState().with(FACING_EXCEPT_DOWN, placementDirection); + } else{ + for(Direction direction : Direction.Plane.HORIZONTAL){ + if(hasSolidSide(world.getBlockState(pos), world, pos.offset(direction.getOpposite()), direction)){ + return this.getDefaultState().with(FACING_EXCEPT_DOWN, direction); + } + } + } + return super.getStateForPlacement(context); + } + + @Override + public void neighborChanged(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Block block, @Nonnull BlockPos fromPos, boolean isMoving){ + Direction direction = state.get(FACING_EXCEPT_DOWN); + if(!this.canPlaceAt(world, pos, direction)){ + world.addEntity(new ItemEntity(world, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, new ItemStack(this))); + world.setBlockState(pos, Blocks.AIR.getDefaultState()); + } + } + + @Override + @OnlyIn(Dist.CLIENT) + public void animateTick(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Random rand){ + if(rand.nextBoolean()){ + Direction direction = state.get(FACING_EXCEPT_DOWN); + double d0 = pos.getX() + 0.5D; + double d1 = pos.getY() + 0.4D; + double d2 = pos.getZ() + 0.5D; + + if(direction.getAxis().isHorizontal()){ + Direction direction1 = direction.getOpposite(); + world.addParticle(ParticleTypes.SMOKE, d0 + 0.35D * direction1.getXOffset(), d1 + 0.22D, d2 + 0.35D * direction1.getZOffset(), 0.0D, 0.0D, 0.0D); + world.addParticle(ParticleTypes.FLAME, d0 + 0.35D * direction1.getXOffset(), d1 + 0.22D, d2 + 0.35D * direction1.getZOffset(), 0.0D, 0.0D, 0.0D); + } else{ + world.addParticle(ParticleTypes.SMOKE, d0, d1, d2, 0.0D, 0.0D, 0.0D); + world.addParticle(ParticleTypes.FLAME, d0, d1, d2, 0.0D, 0.0D, 0.0D); + } + } + } + + @Nonnull + @Override + public BlockState rotate(@Nonnull BlockState state, @Nonnull Rotation rot){ + return state.with(FACING_EXCEPT_DOWN, rot.rotate(state.get(FACING_EXCEPT_DOWN))); + } + + @Nonnull + @Override + public BlockState mirror(@Nonnull BlockState state, @Nonnull Mirror mirrorIn){ + return state.rotate(mirrorIn.toRotation(state.get(FACING_EXCEPT_DOWN))); + } + + @Override + protected void fillStateContainer(@Nonnull StateContainer.Builder builder){ + builder.add(FACING_EXCEPT_DOWN); + } + +} \ No newline at end of file diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 2a42c54c7..e8e92fcf3 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -15,7 +15,7 @@ authors="Ellpeck, Shadows_of_Fire" [[dependencies.actuallyadditions]] modId="forge" mandatory=true - versionRange="[28.1.86,)" + versionRange="[28.2,)" ordering="NONE" side="BOTH" diff --git a/src/main/resources/assets/actuallyadditions/blockstates/tiny_torch.json b/src/main/resources/assets/actuallyadditions/blockstates/tiny_torch.json new file mode 100644 index 000000000..7d483ee96 --- /dev/null +++ b/src/main/resources/assets/actuallyadditions/blockstates/tiny_torch.json @@ -0,0 +1,9 @@ +{ + "variants": { + "facing=up": { "model": "actuallyadditions:block/tiny_torch_block" }, + "facing=east": { "model": "actuallyadditions:block/tiny_torch_wall_block" }, + "facing=south": { "model": "actuallyadditions:block/tiny_torch_wall_block", "y": 90 }, + "facing=west": { "model": "actuallyadditions:block/tiny_torch_wall_block", "y": 180 }, + "facing=north": { "model": "actuallyadditions:block/tiny_torch_wall_block", "y": 270 } + } +} diff --git a/src/main/resources/assets/actuallyadditions/lang/en_us.json b/src/main/resources/assets/actuallyadditions/lang/en_us.json index a28e68bd2..cc9f0a921 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_us.json +++ b/src/main/resources/assets/actuallyadditions/lang/en_us.json @@ -21,6 +21,7 @@ "block.actuallyadditions.brown_lamp": "Brown Lamp", "block.actuallyadditions.green_lamp": "Green Lamp", "block.actuallyadditions.red_lamp": "Red Lamp", - "block.actuallyadditions.black_lamp": "Black Lamp" + "block.actuallyadditions.black_lamp": "Black Lamp", + "block.actuallyadditions.tiny_torch": "Tiny Torch" } \ No newline at end of file diff --git a/src/main/resources/oldassets/actuallyadditions/models/block/block_tiny_torch.json b/src/main/resources/assets/actuallyadditions/models/block/tiny_torch_block.json similarity index 88% rename from src/main/resources/oldassets/actuallyadditions/models/block/block_tiny_torch.json rename to src/main/resources/assets/actuallyadditions/models/block/tiny_torch_block.json index df3ace8b7..2a835226b 100644 --- a/src/main/resources/oldassets/actuallyadditions/models/block/block_tiny_torch.json +++ b/src/main/resources/assets/actuallyadditions/models/block/tiny_torch_block.json @@ -1,8 +1,8 @@ { "ambientocclusion": false, "textures": { - "particle": "actuallyadditions:blocks/block_tiny_torch", - "torch": "actuallyadditions:blocks/block_tiny_torch" + "particle": "actuallyadditions:block/tiny_torch_block", + "torch": "actuallyadditions:block/tiny_torch_block" }, "elements": [ { "from": [ 7, 0, 7 ], diff --git a/src/main/resources/oldassets/actuallyadditions/models/block/block_tiny_torch_wall.json b/src/main/resources/assets/actuallyadditions/models/block/tiny_torch_wall_block.json similarity index 90% rename from src/main/resources/oldassets/actuallyadditions/models/block/block_tiny_torch_wall.json rename to src/main/resources/assets/actuallyadditions/models/block/tiny_torch_wall_block.json index 4880f0b44..8cf809fda 100644 --- a/src/main/resources/oldassets/actuallyadditions/models/block/block_tiny_torch_wall.json +++ b/src/main/resources/assets/actuallyadditions/models/block/tiny_torch_wall_block.json @@ -1,8 +1,8 @@ { "ambientocclusion": false, "textures": { - "particle": "actuallyadditions:blocks/block_tiny_torch", - "torch": "actuallyadditions:blocks/block_tiny_torch" + "particle": "actuallyadditions:block/tiny_torch_block", + "torch": "actuallyadditions:block/tiny_torch_block" }, "elements": [ { "from": [ -1, 3.5, 7 ], diff --git a/src/main/resources/oldassets/actuallyadditions/models/item/standard_item.json b/src/main/resources/assets/actuallyadditions/models/item/standard_item.json similarity index 100% rename from src/main/resources/oldassets/actuallyadditions/models/item/standard_item.json rename to src/main/resources/assets/actuallyadditions/models/item/standard_item.json diff --git a/src/main/resources/oldassets/actuallyadditions/models/item/block_tiny_torch.json b/src/main/resources/assets/actuallyadditions/models/item/tiny_torch.json similarity index 56% rename from src/main/resources/oldassets/actuallyadditions/models/item/block_tiny_torch.json rename to src/main/resources/assets/actuallyadditions/models/item/tiny_torch.json index a64c8d198..4c8975b60 100644 --- a/src/main/resources/oldassets/actuallyadditions/models/item/block_tiny_torch.json +++ b/src/main/resources/assets/actuallyadditions/models/item/tiny_torch.json @@ -1,6 +1,6 @@ { "parent": "actuallyadditions:item/standard_item", "textures": { - "layer0": "actuallyadditions:blocks/block_tiny_torch" + "layer0": "actuallyadditions:block/tiny_torch_block" } } diff --git a/src/main/resources/oldassets/actuallyadditions/textures/blocks/block_tiny_torch.png b/src/main/resources/assets/actuallyadditions/textures/block/tiny_torch_block.png similarity index 100% rename from src/main/resources/oldassets/actuallyadditions/textures/blocks/block_tiny_torch.png rename to src/main/resources/assets/actuallyadditions/textures/block/tiny_torch_block.png diff --git a/src/main/resources/data/actuallyadditions/loot_tables/blocks/tiny_torch.json b/src/main/resources/data/actuallyadditions/loot_tables/blocks/tiny_torch.json new file mode 100644 index 000000000..c7319da63 --- /dev/null +++ b/src/main/resources/data/actuallyadditions/loot_tables/blocks/tiny_torch.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "actuallyadditions:tiny_torch" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/oldassets/actuallyadditions/blockstates/block_tiny_torch.json b/src/main/resources/oldassets/actuallyadditions/blockstates/block_tiny_torch.json deleted file mode 100644 index 7c6dfbafd..000000000 --- a/src/main/resources/oldassets/actuallyadditions/blockstates/block_tiny_torch.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "variants": { - "facing=up": { "model": "actuallyadditions:block_tiny_torch" }, - "facing=east": { "model": "actuallyadditions:block_tiny_torch_wall" }, - "facing=south": { "model": "actuallyadditions:block_tiny_torch_wall", "y": 90 }, - "facing=west": { "model": "actuallyadditions:block_tiny_torch_wall", "y": 180 }, - "facing=north": { "model": "actuallyadditions:block_tiny_torch_wall", "y": 270 } - } -}