mirror of
https://github.com/exituser/Brewery.git
synced 2026-09-17 08:59:01 +00:00
Better Woodtype recognition
Fixes #126 Wood type not recognized on big barrels in 1.9
This commit is contained in:
@@ -74,7 +74,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.9.4-R0.1-SNAPSHOT</version>
|
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
|||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.material.MaterialData;
|
||||||
import org.bukkit.material.Stairs;
|
import org.bukkit.material.Stairs;
|
||||||
import org.bukkit.material.Tree;
|
import org.bukkit.material.Tree;
|
||||||
|
import org.bukkit.material.Wood;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
@@ -623,63 +624,74 @@ public class Barrel implements InventoryHolder {
|
|||||||
|
|
||||||
// woodtype of the block the spigot is attached to
|
// woodtype of the block the spigot is attached to
|
||||||
public byte getWood() {
|
public byte getWood() {
|
||||||
int direction = getDirection(this.spigot);// 1=x+ 2=x- 3=z+ 4=z-
|
|
||||||
Block wood;
|
Block wood;
|
||||||
if (direction == 0) {
|
switch (getDirection(spigot)) { // 1=x+ 2=x- 3=z+ 4=z-
|
||||||
|
case 0:
|
||||||
return 0;
|
return 0;
|
||||||
} else if (direction == 1) {
|
case 1:
|
||||||
wood = this.spigot.getRelative(1, 0, 0);
|
wood = spigot.getRelative(1, 0, 0);
|
||||||
} else if (direction == 2) {
|
break;
|
||||||
wood = this.spigot.getRelative(-1, 0, 0);
|
case 2:
|
||||||
} else if (direction == 3) {
|
wood = spigot.getRelative(-1, 0, 0);
|
||||||
wood = this.spigot.getRelative(0, 0, 1);
|
break;
|
||||||
} else {
|
case 3:
|
||||||
wood = this.spigot.getRelative(0, 0, -1);
|
wood = spigot.getRelative(0, 0, 1);
|
||||||
}
|
break;
|
||||||
if (wood.getType() == Material.WOOD) {
|
default:
|
||||||
MaterialData data = wood.getState().getData();
|
wood = spigot.getRelative(0, 0, -1);
|
||||||
if (data instanceof Tree) {
|
|
||||||
TreeSpecies woodType = ((Tree) data).getSpecies();
|
|
||||||
if (woodType == TreeSpecies.GENERIC){
|
|
||||||
return 2;
|
|
||||||
} else if (woodType == TreeSpecies.REDWOOD) {
|
|
||||||
return 4;
|
|
||||||
} else if (woodType == TreeSpecies.BIRCH) {
|
|
||||||
return 1;
|
|
||||||
} else if (woodType == TreeSpecies.JUNGLE) {
|
|
||||||
return 3;
|
|
||||||
} else if (woodType == TreeSpecies.ACACIA) {
|
|
||||||
return 5;
|
|
||||||
} else if (woodType == TreeSpecies.DARK_OAK) {
|
|
||||||
return 6;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (wood.getType() == Material.WOOD_STAIRS) {
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
if (wood.getType() == Material.SPRUCE_WOOD_STAIRS) {
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
if (wood.getType() == Material.BIRCH_WOOD_STAIRS) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (wood.getType() == Material.JUNGLE_WOOD_STAIRS) {
|
|
||||||
return 3;
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (wood.getType() == Material.ACACIA_STAIRS) {
|
switch (wood.getType()) {
|
||||||
|
case WOOD:
|
||||||
|
MaterialData data = wood.getState().getData();
|
||||||
|
TreeSpecies woodType;
|
||||||
|
if (data instanceof Tree) {
|
||||||
|
woodType = ((Tree) data).getSpecies();
|
||||||
|
} else if (data instanceof Wood) {
|
||||||
|
woodType = ((Wood) data).getSpecies();
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (woodType) {
|
||||||
|
case GENERIC:
|
||||||
|
return 2;
|
||||||
|
case REDWOOD:
|
||||||
|
return 4;
|
||||||
|
case BIRCH:
|
||||||
|
return 1;
|
||||||
|
case JUNGLE:
|
||||||
|
return 3;
|
||||||
|
case ACACIA:
|
||||||
return 5;
|
return 5;
|
||||||
}
|
case DARK_OAK:
|
||||||
if (wood.getType() == Material.DARK_OAK_STAIRS) {
|
|
||||||
return 6;
|
return 6;
|
||||||
}
|
default:
|
||||||
} catch (NoSuchFieldError e) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WOOD_STAIRS:
|
||||||
|
return 2;
|
||||||
|
case SPRUCE_WOOD_STAIRS:
|
||||||
|
return 4;
|
||||||
|
case BIRCH_WOOD_STAIRS:
|
||||||
|
return 1;
|
||||||
|
case JUNGLE_WOOD_STAIRS:
|
||||||
|
return 3;
|
||||||
|
case ACACIA_STAIRS:
|
||||||
|
return 5;
|
||||||
|
case DARK_OAK_STAIRS:
|
||||||
|
return 6;
|
||||||
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (NoSuchFieldError | NoClassDefFoundError e) {
|
||||||
|
// Using older minecraft versions some fields and classes do not exist
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// returns the Sign of a large barrel, the spigot if there is none
|
// returns the Sign of a large barrel, the spigot if there is none
|
||||||
public Block getSignOfSpigot() {
|
public Block getSignOfSpigot() {
|
||||||
if (signoffset != 0) {
|
if (signoffset != 0) {
|
||||||
|
|||||||
@@ -681,7 +681,7 @@ public class Brew {
|
|||||||
BLACK(8, PotionType.WEAKNESS),
|
BLACK(8, PotionType.WEAKNESS),
|
||||||
RED(9, PotionType.STRENGTH),
|
RED(9, PotionType.STRENGTH),
|
||||||
GREY(10, PotionType.SLOWNESS),
|
GREY(10, PotionType.SLOWNESS),
|
||||||
WATER(11, PotionType.WATER_BREATHING),
|
WATER(11, P.use1_9 ? PotionType.WATER_BREATHING : null),
|
||||||
DARK_RED(12, PotionType.INSTANT_DAMAGE),
|
DARK_RED(12, PotionType.INSTANT_DAMAGE),
|
||||||
BRIGHT_GREY(14, PotionType.INVISIBILITY);
|
BRIGHT_GREY(14, PotionType.INVISIBILITY);
|
||||||
|
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ public class P extends JavaPlugin {
|
|||||||
Brew.potions.clear();
|
Brew.potions.clear();
|
||||||
Wakeup.wakeups.clear();
|
Wakeup.wakeups.clear();
|
||||||
Words.words.clear();
|
Words.words.clear();
|
||||||
|
Words.ignoreText.clear();
|
||||||
|
|
||||||
this.log(this.getDescription().getName() + " disabled!");
|
this.log(this.getDescription().getName() + " disabled!");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user