From ba690bf99e29e23ea4fc9604d482f2b0797c603c Mon Sep 17 00:00:00 2001 From: Runemoro Date: Fri, 29 Dec 2017 02:18:34 -0500 Subject: [PATCH] Improvements --- AnnotatedNBT/build.gradle | 12 +++---- .../ddutils/nbt/SavedToNBTProcessor.java | 1 - build.gradle | 34 +++++++++++++------ settings.gradle | 1 - .../java/org/dimdev/ddutils/Location.java | 4 +-- .../shared/blocks/BlockDimensionalDoor.java | 7 ++-- .../dimdoors/shared/rifts/RiftRegistry.java | 4 +-- .../tools/PocketSchematicGenerator.java | 3 +- 8 files changed, 33 insertions(+), 33 deletions(-) diff --git a/AnnotatedNBT/build.gradle b/AnnotatedNBT/build.gradle index 04df33b3..85485313 100644 --- a/AnnotatedNBT/build.gradle +++ b/AnnotatedNBT/build.gradle @@ -1,6 +1,6 @@ buildscript { repositories { - jcenter() + //jcenter() maven { url = "http://files.minecraftforge.net/maven" } } dependencies { @@ -9,15 +9,15 @@ buildscript { } plugins { - id 'io.franzbecker.gradle-lombok' + id 'io.franzbecker.gradle-lombok' /*version '1.11'*/ id 'java' } -apply plugin: 'net.minecraftforge.gradle.forge' apply plugin: 'java' +apply plugin: 'net.minecraftforge.gradle.forge' group 'org.dimdev.annotatednbt' -version '1.0' +version '1.0.0-beta' sourceCompatibility = 1.8 @@ -25,10 +25,6 @@ repositories { mavenCentral() } -dependencies { - testCompile group: 'junit', name: 'junit', version: '4.12' -} - minecraft { version = "1.12.2-14.23.1.2555" mappings = "snapshot_20171007" diff --git a/AnnotatedNBT/src/main/java/org/dimdev/ddutils/nbt/SavedToNBTProcessor.java b/AnnotatedNBT/src/main/java/org/dimdev/ddutils/nbt/SavedToNBTProcessor.java index efa75c67..98234763 100644 --- a/AnnotatedNBT/src/main/java/org/dimdev/ddutils/nbt/SavedToNBTProcessor.java +++ b/AnnotatedNBT/src/main/java/org/dimdev/ddutils/nbt/SavedToNBTProcessor.java @@ -37,7 +37,6 @@ public class SavedToNBTProcessor extends AbstractProcessor { private Map varCounter = new HashMap<>(); - @SuppressWarnings("StringConcatenationInsideStringBufferAppend") @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { // TODO: generics, inheritance, different exception for error type roundEnv.getElementsAnnotatedWith(SavedToNBT.class); diff --git a/build.gradle b/build.gradle index c31e2f64..52ffb9d4 100644 --- a/build.gradle +++ b/build.gradle @@ -13,22 +13,35 @@ plugins { id 'java' } +apply plugin: 'java' apply plugin: 'net.minecraftforge.gradle.forge' -//Only edit below this line, the above code adds and enables the nessasary things for Forge to be setup. -ext.modversion = "3.0.0-b2" +// Version info +String baseversion = "3.0.0" // Set beta to 0 after changing this +int beta = 2 // Set this to 0 for a non-beta release ext.mcversion = "1.12.2" ext.forgeversion = "14.23.1.2555" -//spongeSchematicVersion = "1" +String mcpversion = "snapshot_20171007" -version = mcversion + "-" + modversion -group = "org.dimdev.dimdoors" // http://maven.apache.org/guides/mini/guide-naming-conventions.html +String suffix = "" +String shortSuffix = "" +if (beta != 0) { + suffix += "-beta$beta" + shortSuffix = suffix + if (System.getenv("TRAVIS_BUILD_NUMBER") != null && beta != 0) { + suffix += "+${System.getenv("TRAVIS_BUILD_NUMBER")}" + } else { + suffix += "+UNOFFICIAL" + } +} +version = ext.modversion = baseversion + suffix + +group = "org.dimdev.dimdoors" archivesBaseName = "dimdoors" jar.archiveName = "dimdoors.jar" // Constant name for travis -sourceCompatibility = targetCompatibility = "1.8" // Need this here so eclipse task generates correctly. +sourceCompatibility = "1.8" compileJava { - sourceCompatibility = targetCompatibility = "1.8" options.compilerArgs += [ //"-proc:only", // TODO: have generated code available for debugging "-processor", "org.dimdev.ddutils.nbt.SavedToNBTProcessor,lombok.launch.AnnotationProcessorHider\$AnnotationProcessor" @@ -36,11 +49,10 @@ compileJava { } minecraft { - version = "1.12.2-14.23.1.2555" + version = "$mcversion-$forgeversion" runDir = "run" - mappings = "snapshot_20171007" - replace '${version}', project.version - //replace '${spongeSchematicVersion}', spongeSchematicVersion + mappings = mcpversion + replace '${version}', baseversion + shortSuffix // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. } diff --git a/settings.gradle b/settings.gradle index 0a86d8b8..559c6d56 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1 @@ include 'AnnotatedNBT' - diff --git a/src/main/java/org/dimdev/ddutils/Location.java b/src/main/java/org/dimdev/ddutils/Location.java index 20a85047..e3c00bb7 100644 --- a/src/main/java/org/dimdev/ddutils/Location.java +++ b/src/main/java/org/dimdev/ddutils/Location.java @@ -6,12 +6,10 @@ import lombok.ToString; import lombok.Value; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.WorldServer; -import net.minecraftforge.common.DimensionManager; /** * @author Robijnvogel @@ -48,7 +46,7 @@ public class Location implements Serializable { } public IBlockState getBlockState() { - return getWorld().getBlockState(this.pos); + return getWorld().getBlockState(pos); } public WorldServer getWorld() { diff --git a/src/main/java/org/dimdev/dimdoors/shared/blocks/BlockDimensionalDoor.java b/src/main/java/org/dimdev/dimdoors/shared/blocks/BlockDimensionalDoor.java index 7801e831..6a03655c 100644 --- a/src/main/java/org/dimdev/dimdoors/shared/blocks/BlockDimensionalDoor.java +++ b/src/main/java/org/dimdev/dimdoors/shared/blocks/BlockDimensionalDoor.java @@ -6,7 +6,6 @@ import org.dimdev.dimdoors.shared.rifts.RiftRegistry; import org.dimdev.dimdoors.shared.tileentities.TileEntityEntranceRift; import org.dimdev.dimdoors.shared.tileentities.TileEntityFloatingRift; import org.dimdev.dimdoors.shared.rifts.TileEntityRift; -import org.dimdev.ddutils.Location; import net.minecraft.block.Block; import net.minecraft.block.BlockDoor; import net.minecraft.block.material.Material; @@ -16,7 +15,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; @@ -31,9 +29,8 @@ public abstract class BlockDimensionalDoor extends BlockDoor implements IRiftPro @Override public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) { if (world.isRemote) return; - if (state.getValue(HALF) == EnumDoorHalf.UPPER) pos = pos.down(); - IBlockState doorState = world.getBlockState(pos); - if (!(doorState.getBlock() instanceof BlockDoor)) return; + + IBlockState doorState = world.getBlockState(state.getValue(HALF) == EnumDoorHalf.UPPER ? pos.down() : pos); // .down() because only the bottom block has open=true // Check that it's a door and that the entity portal timer is 0 if (doorState.getValue(BlockDoor.OPEN) && entity.timeUntilPortal == 0) { diff --git a/src/main/java/org/dimdev/dimdoors/shared/rifts/RiftRegistry.java b/src/main/java/org/dimdev/dimdoors/shared/rifts/RiftRegistry.java index 2eff9ff3..cc78d9bf 100644 --- a/src/main/java/org/dimdev/dimdoors/shared/rifts/RiftRegistry.java +++ b/src/main/java/org/dimdev/dimdoors/shared/rifts/RiftRegistry.java @@ -13,9 +13,7 @@ import lombok.experimental.Wither; import org.dimdev.dimdoors.DimDoors; import org.dimdev.dimdoors.shared.VirtualLocation; import org.dimdev.dimdoors.shared.rifts.RiftRegistry.RiftInfo.AvailableLinkInfo; -import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; import net.minecraft.world.World; import net.minecraft.world.storage.MapStorage; import net.minecraft.world.storage.WorldSavedData; @@ -217,7 +215,7 @@ import java.util.*; List entrances = privatePocketEntranceLists.computeIfAbsent(playerUUID, k -> new ArrayList<>()); while ((entrance == null || !(entrance.getTileEntity() instanceof TileEntityRift)) && entrances.size() > 0) { if (entrance != null) entrances.remove(entrance); - entrance = entrances.get(0); + if (entrances.size() > 0) entrance = entrances.get(0); } privatePocketEntrances.put(playerUUID, entrance); return entrance; diff --git a/src/main/java/org/dimdev/dimdoors/shared/tools/PocketSchematicGenerator.java b/src/main/java/org/dimdev/dimdoors/shared/tools/PocketSchematicGenerator.java index a5f25a38..be56d6f9 100644 --- a/src/main/java/org/dimdev/dimdoors/shared/tools/PocketSchematicGenerator.java +++ b/src/main/java/org/dimdev/dimdoors/shared/tools/PocketSchematicGenerator.java @@ -1,5 +1,6 @@ package org.dimdev.dimdoors.shared.tools; +import net.minecraft.block.Block; import org.dimdev.dimdoors.DimDoors; import org.dimdev.dimdoors.server.DDProxyServer; import org.dimdev.dimdoors.shared.blocks.BlockDimensionalDoor; @@ -46,7 +47,7 @@ public final class PocketSchematicGenerator { ModContainer mc = new DummyModContainer(md); Loader.instance().setupTestHarness(mc); Loader.instance().setActiveModContainer(mc); - ModBlocks.registerBlocks(new RegistryEvent.Register(GameData.BLOCKS, RegistryManager.ACTIVE.getRegistry(GameData.BLOCKS))); + ModBlocks.registerBlocks(new RegistryEvent.Register(GameData.BLOCKS, RegistryManager.ACTIVE.getRegistry(GameData.BLOCKS))); new DDProxyServer().registerTileEntities(); new DDProxyServer().registerRiftDestinations(); Loader.instance().setActiveModContainer(null);