Skip to content

Commit

Permalink
[U] 1.1.0-SNAPSHOT-3
Browse files Browse the repository at this point in the history
  • Loading branch information
ClayCoffee committed Mar 23, 2020
1 parent 041776a commit 20adddb
Show file tree
Hide file tree
Showing 20 changed files with 118 additions and 54 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>club.claycoffee</groupId>
<artifactId>ClayTech</artifactId>
<version>1.1.0-SNAPSHOT-2</version>
<version>1.1.0-SNAPSHOT-3</version>
<build>
<plugins>
<plugin>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/club/claycoffee/ClayTech/ClayTech.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import club.claycoffee.ClayTech.implementation.Planets.Earth;
import club.claycoffee.ClayTech.implementation.Planets.Moon;
import club.claycoffee.ClayTech.implementation.items.Armors;
import club.claycoffee.ClayTech.implementation.items.ClayFuel;
import club.claycoffee.ClayTech.implementation.items.ClayFuelResource;
import club.claycoffee.ClayTech.implementation.items.Clay_basic;
import club.claycoffee.ClayTech.implementation.items.DrinkMakingStaff;
import club.claycoffee.ClayTech.implementation.items.Drinks;
Expand All @@ -50,7 +50,7 @@
import club.claycoffee.ClayTech.implementation.machines.RocketFuelGenerator;
import club.claycoffee.ClayTech.implementation.machines.RocketFuelInjector;
import club.claycoffee.ClayTech.implementation.machines.SpaceSuitOxygenInjector;
import club.claycoffee.ClayTech.implementation.resources.ClayFuelResource;
import club.claycoffee.ClayTech.implementation.resources.ClayFuel;
import club.claycoffee.ClayTech.listeners.*;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
Expand Down Expand Up @@ -390,6 +390,6 @@ private void registerPlanets() {
}

private void registerResources() {
new ClayFuel().register();
new ClayFuel();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ ClayTechItems.MAGIC_CLAY, new ItemStack(Material.TNT), new ItemStack(Material.FL
null };
public final static ItemStack[] KREEP_INGOT = { null, null, null, null, ClayTechItems.KREEP_ROCK, null, null, null,
null };

public final static ItemStack[] RAW_CHICKEN_FOOT = { null, null, null, null, new ItemStack(Material.CHICKEN), null, null, null, null };;
public final static ItemStack[] PLANET_BASE_SIGNER = {SlimefunItems.STEEL_PLATE,ClayTechItems.ROCKET_ANTENNA,SlimefunItems.STEEL_PLATE,SlimefunItems.HARDENED_GLASS,SlimefunItems.PROGRAMMABLE_ANDROID,SlimefunItems.HARDENED_GLASS,ClayTechItems.TEMPERATURE_RESISTANCE_OBSIDIAN,SlimefunItems.ELECTRIC_MOTOR,ClayTechItems.TEMPERATURE_RESISTANCE_OBSIDIAN};
public final static ItemStack[] TUBE = {SlimefunItems.PLASTIC_SHEET,null,SlimefunItems.PLASTIC_SHEET,SlimefunItems.PLASTIC_SHEET,null,SlimefunItems.PLASTIC_SHEET,SlimefunItems.PLASTIC_SHEET,null,SlimefunItems.PLASTIC_SHEET};
public final static ItemStack[] OXYGEN_DISTRIBUTER = {SlimefunItems.REINFORCED_ALLOY_INGOT,ClayTechItems.TUBE,SlimefunItems.REINFORCED_ALLOY_INGOT,ClayTechItems.SPACESUIT_OXYGEN_TANK,ClayTechItems.SPACESUIT_OXYGEN_TANK,ClayTechItems.SPACESUIT_OXYGEN_TANK,ClayTechItems.KREEP_INGOT,ClayTechItems.SPACESUIT_OXYGEN_TANK,ClayTechItems.KREEP_INGOT};
Expand Down
17 changes: 11 additions & 6 deletions src/main/java/club/claycoffee/ClayTech/api/Planet.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ public class Planet {
public int gravity;
public int distance;
public int harmlevel;
public boolean cold;

public Planet(String planetName, ItemStack displayItem, ChunkGenerator planetWorld, Environment environment,
boolean habitable, int gravity, int distance, int harmlevel) {
boolean habitable, int gravity, int distance, int harmlevel, boolean cold) {
this.planetName = planetName;
this.displayItem = displayItem;
this.planetWorld = planetWorld;
Expand All @@ -41,17 +42,19 @@ public Planet(String planetName, ItemStack displayItem, ChunkGenerator planetWor
this.gravity = gravity;
this.distance = distance;
this.harmlevel = harmlevel;
this.cold = cold;
}

public Planet(String planetName, ItemStack displayItem, World planetWorld, Environment environment,
boolean habitable, int gravity, int distance, int harmlevel) {
boolean habitable, int gravity, int distance, int harmlevel, boolean cold) {
this.planetName = planetName;
this.displayItem = displayItem;
this.planetWorld = planetWorld.getGenerator();
this.environment = environment;
this.habitable = habitable;
this.gravity = gravity;
this.harmlevel = harmlevel;
this.cold = cold;
}

public void register() {
Expand Down Expand Up @@ -79,16 +82,18 @@ public void register() {
}
}
ClayTech.getPlanets().add(this);

if (Bukkit.getWorld(this.planetName) == null) {
// Register
WorldCreator newWorld = new WorldCreator(this.planetName);
newWorld.environment(this.environment);
newWorld.generator(this.planetWorld);
long seed = new Random().nextLong();
newWorld.seed(seed);
newWorld.type(WorldType.NORMAL);
newWorld.generateStructures(false);
newWorld = newWorld.seed(seed);
newWorld = newWorld.type(WorldType.NORMAL);
newWorld = newWorld.generateStructures(false);
newWorld = newWorld.generator(this.planetWorld);
newWorld.createWorld();


// 多世界注册
if (Bukkit.getPluginManager().isPluginEnabled("Multiverse-Core")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public class Earth extends ChunkGenerator {
public Earth() {
new Planet(ClayTech.getOverworld(),
Utils.newItemD(Material.GREEN_GLAZED_TERRACOTTA, Lang.readPlanetsText("Earth")), this,
Environment.NORMAL, true, 1, 0, 0).register();
Environment.NORMAL, true, 1, 0, 0, false).register();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class Moon extends ChunkGenerator {

public Moon() {
new Planet("CMoon", Utils.newItemD(Material.GRAY_GLAZED_TERRACOTTA, Lang.readPlanetsText("Moon")), this,
Environment.NORMAL, false, 3, 100, 1).register();
Environment.NORMAL, false, 3, 100, 1, true).register();
}

@SuppressWarnings("deprecation")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ public void populate(@NotNull World world, @NotNull Random random, @NotNull Chun

switch (random.nextInt(6)) {
case 0:
x++;
x = Math.min(x + 1, 15);
break;
case 1:
y++;
y = Math.min(y + 1, 15);
break;
case 2:
z++;
z = Math.min(z + 1, 15);
break;
case 3:
x--;
x = Math.max(x - 1, 0);
break;
case 4:
y = Math.max(y - 1, 0);
break;
default:
z--;
z = Math.max(z - 1, 0);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.jetbrains.annotations.NotNull;

import club.claycoffee.ClayTech.ClayTechItems;
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.api.BlockStorage;

public class MoonKreepPopulator extends BlockPopulator {
Expand All @@ -22,28 +23,34 @@ public void populate(@NotNull World world, @NotNull Random random, @NotNull Chun
int count = 0;
while (random.nextDouble() < 0.8D && count <= 4) {
if (source.getBlock(x, y, z).getType() == Material.STONE) {
if(!SlimefunPlugin.getRegistry().getWorlds().containsKey(world.getName())) {
BlockStorage bs = new BlockStorage(world);
SlimefunPlugin.getRegistry().getWorlds().put(world.getName(), bs);
}
source.getBlock(x, y, z).setType(ClayTechItems.KREEP_ROCK.getType());
BlockStorage.addBlockInfo(source.getBlock(x, y, z), "id", "KREEP_ROCK",true);
count++;

}

switch (random.nextInt(6)) {
case 0:
x++;
x = Math.min(x + 1, 15);
break;
case 1:
y++;
y = Math.min(y + 1, 20);
break;
case 2:
z++;
z = Math.min(z + 1, 15);
break;
case 3:
x--;
x = Math.max(x - 1, 0);
break;
case 4:
y = Math.max(y - 1, 29);
y = Math.max(y - 1, 30);
break;
default:
z--;
z = Math.max(z - 1, 0);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package club.claycoffee.ClayTech.implementation.resources;
package club.claycoffee.ClayTech.implementation.items;

import club.claycoffee.ClayTech.ClayTechItems;
import club.claycoffee.ClayTech.utils.Slimefunutils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import club.claycoffee.ClayTech.ClayTech;
import club.claycoffee.ClayTech.ClayTechItems;
import club.claycoffee.ClayTech.ClayTechMachineRecipes;
import club.claycoffee.ClayTech.ClayTechRecipeType;
import club.claycoffee.ClayTech.utils.Lang;
import club.claycoffee.ClayTech.utils.Slimefunutils;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
Expand All @@ -14,14 +16,13 @@

public class FoodMakingStaff {
public FoodMakingStaff() {
ItemStack[] recipea = { null, null, null, null, new ItemStack(Material.CHICKEN), null, null, null, null };
ItemStack[] recipec = { null, new ItemStack(Material.BREAD), null, null, ClayTechItems.MAGIC_CLAY, null, null,
new ItemStack(Material.BREAD), null };
ItemStack[] reciped = { null, new ItemStack(Material.KELP), null, null, ClayTechItems.MAGIC_CLAY, null, null,
new ItemStack(Material.BAMBOO), null };

Slimefunutils.registerItem(ClayTechItems.C_FOODMATERIALS, "RAW_CHICKEN_FOOT", ClayTechItems.RAW_CHICKEN_FOOT,
"notresearch", 10, RecipeType.ORE_CRUSHER, recipea, false);
"notresearch", 10, ClayTechRecipeType.CLAY_FOOD_CHALKING_MACHINE, ClayTechMachineRecipes.RAW_CHICKEN_FOOT, false);
Slimefunutils.registerItem(ClayTechItems.C_FOODMATERIALS, "RAW_BREAD", ClayTechItems.RAW_BREAD, "notresearch",
10, RecipeType.ENHANCED_CRAFTING_TABLE, recipec, false);
Slimefunutils.registerItem(ClayTechItems.C_FOODMATERIALS, "RAW_VEGETABLE", ClayTechItems.RAW_VEGETABLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ public Golden_things() {
ItemStack[] recipec = { new ItemStack(Material.GOLD_INGOT), new ItemStack(Material.GOLD_INGOT),
new ItemStack(Material.GOLD_INGOT), new ItemStack(Material.GOLD_INGOT), ClayTechItems.MAGIC_CLAY,
new ItemStack(Material.GOLD_INGOT), new ItemStack(Material.GOLD_INGOT),
new ItemStack(Material.GOLD_INGOT), new ItemStack(Material.GOLD_INGOT),
new ItemStack(Material.GOLD_INGOT) };
new ItemStack(Material.GOLD_INGOT), new ItemStack(Material.GOLD_INGOT)};
ItemStack[] reciped = { ClayTechItems.ARTIFICIAL_GOLD_NUGGET, ClayTechItems.ARTIFICIAL_GOLD_NUGGET,
ClayTechItems.ARTIFICIAL_GOLD_NUGGET, ClayTechItems.ARTIFICIAL_GOLD_NUGGET, ClayTechItems.MAGIC_CLAY,
ClayTechItems.ARTIFICIAL_GOLD_NUGGET, ClayTechItems.ARTIFICIAL_GOLD_NUGGET,
Expand All @@ -37,13 +36,13 @@ public Golden_things() {
ClayTechItems.ARTIFICIAL_GOLD_BLOCK };

Slimefunutils.registerItem(ClayTechItems.C_MATERIALS, "ARTIFICIAL_GOLD_NUGGET",
ClayTechItems.ARTIFICIAL_GOLD_NUGGET, "notresearch", 10, RecipeType.COMPRESSOR, recipec, false);
ClayTechItems.ARTIFICIAL_GOLD_NUGGET, "notresearch", 10, RecipeType.ENHANCED_CRAFTING_TABLE, recipec, false);
Slimefunutils.registerItem(ClayTechItems.C_MATERIALS, "ARTIFICIAL_GOLD_INGOT_O",
ClayTechItems.ARTIFICIAL_GOLD_INGOT_O, "notresearch", 10, RecipeType.COMPRESSOR, reciped, false);
ClayTechItems.ARTIFICIAL_GOLD_INGOT_O, "notresearch", 10, RecipeType.ENHANCED_CRAFTING_TABLE, reciped, false);
Slimefunutils.registerItem(ClayTechItems.C_MATERIALS, "ARTIFICIAL_GOLD_INGOT",
ClayTechItems.ARTIFICIAL_GOLD_INGOT, "notresearch", 10, RecipeType.COMPRESSOR, recipee, false);
ClayTechItems.ARTIFICIAL_GOLD_INGOT, "notresearch", 10, RecipeType.ENHANCED_CRAFTING_TABLE, recipee, false);
Slimefunutils.registerItem(ClayTechItems.C_MATERIALS, "ARTIFICIAL_GOLD_BLOCK",
ClayTechItems.ARTIFICIAL_GOLD_BLOCK, "notresearch", 10, RecipeType.COMPRESSOR, recipef, false);
ClayTechItems.ARTIFICIAL_GOLD_BLOCK, "notresearch", 10, RecipeType.ENHANCED_CRAFTING_TABLE, recipef, false);
Slimefunutils.registerItem(ClayTechItems.C_FOOD, "ARTIFICIAL_ENCHANTED_GOLDEN_APPLE",
ClayTechItems.ARTIFICIAL_ENCHANTED_GOLDEN_APPLE, "notresearch", 10, RecipeType.ANCIENT_ALTAR, recipeg,
false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.bukkit.inventory.ItemStack;

import club.claycoffee.ClayTech.ClayTechItems;
import club.claycoffee.ClayTech.ClayTechMachineRecipes;
import club.claycoffee.ClayTech.implementation.abstractMachines.ANewContainer;
import club.claycoffee.ClayTech.utils.Lang;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
Expand Down Expand Up @@ -52,5 +53,7 @@ public void registerDefaultRecipes() {
this.registerRecipe(8, new ItemStack[] { ClayTechItems.RAW_TEA }, new ItemStack[] { ClayTechItems.TEA_POWDER });
this.registerRecipe(8, new ItemStack[] { ClayTechItems.CLAY_LEMON },
new ItemStack[] { ClayTechItems.LEMON_POWDER });
this.registerRecipe(8, ClayTechMachineRecipes.RAW_CHICKEN_FOOT,
new ItemStack[] { ClayTechItems.RAW_CHICKEN_FOOT });
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package club.claycoffee.ClayTech.implementation.items;
package club.claycoffee.ClayTech.implementation.resources;

import org.bukkit.NamespacedKey;
import org.bukkit.World.Environment;
Expand All @@ -9,11 +9,16 @@
import club.claycoffee.ClayTech.ClayTech;
import club.claycoffee.ClayTech.ClayTechItems;
import club.claycoffee.ClayTech.utils.Lang;
import club.claycoffee.ClayTech.utils.Slimefunutils;
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;

public class ClayFuel implements GEOResource {
private final NamespacedKey key = new NamespacedKey(ClayTech.getInstance(), "CLAY_FUEL");


public ClayFuel() {
Slimefunutils.registerResource(this);
}

@Override
public @NotNull NamespacedKey getKey() {
return key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.List;

import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand All @@ -12,13 +13,17 @@
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.scheduler.BukkitRunnable;

import club.claycoffee.ClayTech.ClayTech;
import club.claycoffee.ClayTech.ClayTechItems;
import club.claycoffee.ClayTech.api.ClayTechManager;
import club.claycoffee.ClayTech.api.Planet;
import club.claycoffee.ClayTech.utils.DataYML;
import club.claycoffee.ClayTech.utils.Lang;
import club.claycoffee.ClayTech.utils.PlanetUtils;
import club.claycoffee.ClayTech.utils.RocketUtils;
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
Expand All @@ -27,22 +32,31 @@ public class PlanetBaseListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void BlockPlaceEvent(BlockPlaceEvent e) {
if (SlimefunManager.isItemSimilar(e.getPlayer().getInventory().getItemInMainHand(),ClayTechItems.PLANET_BASE_SIGNER,true)) {
DataYML planetsData = ClayTech.getPlanetDataYML();
FileConfiguration pd = planetsData.getCustomConfig();
if (!pd.getBoolean(e.getPlayer().getName() + "." + e.getPlayer().getWorld().getName() + ".base")) {
pd.set(e.getPlayer().getName() + "." + e.getPlayer().getWorld().getName() + ".base", true);
pd.set(e.getPlayer().getName() + "." + e.getPlayer().getWorld().getName() + ".baseX",
e.getBlock().getX());
pd.set(e.getPlayer().getName() + "." + e.getPlayer().getWorld().getName() + ".baseY",
e.getBlock().getY() + 1);
pd.set(e.getPlayer().getName() + "." + e.getPlayer().getWorld().getName() + ".baseZ",
e.getBlock().getZ());
planetsData.saveCustomConfig();
e.getPlayer().sendMessage(Lang.readGeneralText("BaseCompleted"));
} else {
e.getPlayer().sendMessage(Lang.readGeneralText("BaseExists"));
planetsData.saveCustomConfig();
Planet p = PlanetUtils.getPlanet(e.getBlock().getWorld());
if(p != null) {
DataYML planetsData = ClayTech.getPlanetDataYML();
FileConfiguration pd = planetsData.getCustomConfig();
if (!pd.getBoolean(e.getPlayer().getName() + "." + e.getPlayer().getWorld().getName() + ".base")) {
pd.set(e.getPlayer().getName() + "." + e.getPlayer().getWorld().getName() + ".base", true);
pd.set(e.getPlayer().getName() + "." + e.getPlayer().getWorld().getName() + ".baseX",
e.getBlock().getX());
pd.set(e.getPlayer().getName() + "." + e.getPlayer().getWorld().getName() + ".baseY",
e.getBlock().getY() + 1);
pd.set(e.getPlayer().getName() + "." + e.getPlayer().getWorld().getName() + ".baseZ",
e.getBlock().getZ());
planetsData.saveCustomConfig();
e.getPlayer().sendMessage(Lang.readGeneralText("BaseCompleted"));
return;
} else {
e.getPlayer().sendMessage(Lang.readGeneralText("BaseExists"));
e.setCancelled(true);
return;
}
}
else {
e.getPlayer().sendMessage(Lang.readGeneralText("NotInPlanet"));
e.setCancelled(true);
return;
}
}
}
Expand Down Expand Up @@ -135,4 +149,23 @@ public void InventoryClickEvent(InventoryClickEvent e) {
}
}
}

@EventHandler
public void PlayerBucketEmptyEvent(PlayerBucketEmptyEvent e) {
Planet p = PlanetUtils.getPlanet(e.getBlock().getWorld());
if(p != null) {
if(p.cold && e.getPlayer().getInventory().getItemInMainHand().getType() == Material.WATER_BUCKET) {
new BukkitRunnable() {

@Override
public void run() {
e.getBlock().setType(Material.BLUE_ICE);

}

}.runTaskLater(ClayTech.getInstance(), 30);
return;
}
}
}
}
Loading

0 comments on commit 20adddb

Please sign in to comment.