WIP: portals

This commit is contained in:
Aleksey 2020-10-25 01:29:51 +03:00
parent 38a5f66a01
commit 446ca757b5
5 changed files with 164 additions and 92 deletions

View file

@ -27,10 +27,12 @@ public class DefaultEndPortalFeature extends Feature<EndPortalFeatureConfig> {
BlockState portalBlock = BlockRegistry.END_PORTAL_BLOCK.getDefaultState().with(EndPortalBlock.AXIS, config.axis);
BlockPos bottomCorner = pos;
BlockPos topCorner;
int width = config.width - 1;
int height = config.height - 1;
if (config.axis.equals(Direction.Axis.X)) {
topCorner = bottomCorner.add(3, 4, 0);
topCorner = bottomCorner.add(width, height, 0);
} else {
topCorner = bottomCorner.add(0, 4, 3);
topCorner = bottomCorner.add(0, height, width);
}
for(BlockPos position : BlockPos.iterate(bottomCorner, topCorner)) {

View file

@ -14,8 +14,13 @@ public class EndPortalFeature extends EndFeature {
this.frameBlock = frameBlock;
}
public EndPortalFeature configure(Direction.Axis axis, int width, int height, boolean active) {
this.featureConfigured = ((DefaultEndPortalFeature) this.feature).configure(EndPortalFeatureConfig.create(frameBlock, axis, width, height, active));
return this;
}
public EndPortalFeature configure(Direction.Axis axis, boolean active) {
this.featureConfigured = ((DefaultEndPortalFeature) this.feature).configure(EndPortalFeatureConfig.create(frameBlock, axis, active));
this.featureConfigured = ((DefaultEndPortalFeature) this.feature).configure(EndPortalFeatureConfig.create(frameBlock, axis, 4, 5, active));
return this;
}
}

View file

@ -15,6 +15,10 @@ public class EndPortalFeatureConfig implements FeatureConfig {
return Registry.BLOCK.getId(endPortalFeatureConfig.frameBlock).toString();
}), Codec.STRING.fieldOf("axis").forGetter(endPortalFeatureConfig -> {
return endPortalFeatureConfig.axis.getName();
}), Codec.INT.fieldOf("width").forGetter(endPortalFeatureConfig -> {
return endPortalFeatureConfig.width;
}), Codec.INT.fieldOf("heigth").forGetter(endPortalFeatureConfig -> {
return endPortalFeatureConfig.height;
}), Codec.BOOL.fieldOf("activated").forGetter(endPortalFeatureConfig -> {
return endPortalFeatureConfig.activated;
})).apply(instance, EndPortalFeatureConfig::new);
@ -23,20 +27,26 @@ public class EndPortalFeatureConfig implements FeatureConfig {
public final RunedFlavolite frameBlock;
public final Direction.Axis axis;
public final boolean activated;
public final int width;
public final int height;
private EndPortalFeatureConfig(String frameBlock, String axis, boolean active) {
private EndPortalFeatureConfig(String frameBlock, String axis, int width, int height, boolean active) {
this.frameBlock = (RunedFlavolite) Registry.BLOCK.get(new Identifier(frameBlock));
this.axis = Direction.Axis.fromName(axis);
this.activated = active;
this.width = width;
this.height = height;
}
private EndPortalFeatureConfig(RunedFlavolite frameBlock, Direction.Axis axis, boolean active) {
private EndPortalFeatureConfig(RunedFlavolite frameBlock, Direction.Axis axis, int width, int height, boolean active) {
this.frameBlock = frameBlock;
this.axis = axis;
this.activated = active;
this.width = width;
this.height = height;
}
public static EndPortalFeatureConfig create(RunedFlavolite block, Direction.Axis axis, boolean active) {
return new EndPortalFeatureConfig(block, axis, active);
public static EndPortalFeatureConfig create(RunedFlavolite block, Direction.Axis axis, int width, int height, boolean active) {
return new EndPortalFeatureConfig(block, axis, width, height, active);
}
}